_Revenge_ @ 2023-04-02 13:01:51
https://codeforces.com/contest/1810/submission/200328316
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
const int N=1e5+50;
const int M=1e5+50;
const int Mod=1e9+7;
#define int long long
inline int read(){
int x=0,f=1;
char ch=getchar();
while(ch<'0'||ch>'9'){
if(ch=='-')
f=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9'){
x=(x<<1)+(x<<3)+(ch^48);
ch=getchar();
}
return x*f;
}
int t,q;
signed main()
{
t=read();
while(t--){
q=read();
int l=-1ll,r=-1ll;
while(q--){
int opt=read();
if(opt==1ll){
int a=read(),b=read(),n=read();
int lh=max(n-2ll,0ll)*(a-b)+a+1ll,rh=(n-1ll)*(a-b)+a;
if(lh>rh) swap(lh,rh);
if(n==1ll) lh=1ll,rh=a;
if(l==-1ll&&r==-1ll){
l=lh,r=rh;
}else{
if(l>rh||r<lh){
printf("0 ");
continue;
}
if(l<=lh&&r>=rh){
l=lh,r=rh;
}else
if(lh<=l&&rh>=r){
l=l,r=r;
}else
if(l<=lh&&r<=rh){
l=lh,r=r;
}else
if(lh<=l&&rh<=r){
l=l,r=rh;
}
}
printf("1 ");
}else{
int a=read(),b=read();
if(l==-1ll&&r==-1ll){
printf("-1 ");
}else{
int nl=ceil((l-a)*1.0/(a-b))+1ll;
int nr=ceil((r-a)*1.0/(a-b))+1ll;
if(a>=l) nl=1ll;
if(a>=r) nr=1ll;
if(nl!=nr){
printf("-1 ");
}else{
printf("%lld ",nl);
}
}
}
}
puts("");
}
return 0;
}