#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mkp make_pair
#define pb push_back
#define sz(v) (int)(v).size()
typedef long long LL;
typedef double db;
template<class T>bool ckmax(T&x,T y){return x<y?x=y,1:0;}
template<class T>bool ckmin(T&x,T y){return x>y?x=y,1:0;}
#define rep(i,x,y) for(int i=x,i##end=y;i<=i##end;++i)
#define per(i,x,y) for(int i=x,i##end=y;i>=i##end;--i)
#define int long long
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=0;ch=getchar();}
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
void exgcd(int&x,int&y,int&d,int a,int b){
	if(!b)return x=1,y=0,d=a,void();
	exgcd(y,x,d,b,a%b),y-=a/b*x;
}

int a[5],b[5];
int mul(int x,int y,int mod){
	int res=0;
	while(y){
		if(y&1)(res+=x)%=mod;
		y>>=1,(x<<=1)%=mod;
	}
	return res;
}
int excrt(){
	int res=a[1],lcm=b[1];
	for(int i=2;i<=2;++i){
		int x,y,d,t=((a[i]-res)%b[i]+b[i])%b[i];
		exgcd(x,y,d,lcm,b[i]);
		if(t%d)return -1;
		res+=lcm*mul(x,t/d,b[i]/d);
		lcm=lcm/d*b[i];
		res=(res+lcm)%lcm;
	}
	return res;
}
signed main(){
	for(int T=read();T;--T){
		int x=read(),y=read(),p=read(),q=read(),ans=9e18;
		int t1=2*x+2*y,t2=p+q;
		rep(i,x,x+y-1){
			rep(j,p,p+q-1){
//				if((j-i)%d)continue;
//				exgcd(t1,-t2,A,B);
//				A=(A%t2+t2)%t2;
//				A=A*(j-i)/d,B=B*(j-i)/d;
//				ckmin(ans,t1*A+i);
				a[1]=i,b[1]=t1;
				a[2]=j,b[2]=t2;
				int t=excrt();
				if(t!=-1)ckmin(ans,t);
			}
		}
		if(ans==9e18)puts("infinity");
		else printf("%lld\n",ans);
	}
}
#include <bits/stdc++.h>

using namespace std;

#define pii pair<long long, long long>
#define FOR(x, j) for(int x = 0; x < j; x++)
typedef long long ll;

const int INF = 2e9;
const int maxN = 3e5+10;
const int LEAF = (1 << 19);
int TREE[2*LEAF];
int A[maxN];
int n, q;

void add(int x, int v){
    x += LEAF;
    while(x >= 1){
        TREE[x] ^= v;
        x /= 2;
    }
}

int query(int x){
    if(x < 0) return 0;
    x += LEAF;
    int ans = TREE[x];
    while(x > 1){
        if(x%2 == 1)
            ans ^= TREE[x-1];
        x /= 2;
    }
    return ans;
}

int query(int l, int r){
    return (query(r)^query(l-1));
}


void solve(){
    cin >> n >> q;
    for(int i = 0; i < n; i++)
        cin >> A[i];
    for(int i = 0; i < n; i++)
        add(i, A[i]);
    for(int i = 0; i < q; i++){
        int t, x, y;
        cin >> t >> x >> y;
        if(t == 1){
            add(x-1, y);
        }
        else
            cout << query(x-1, y-1) << "\n";
    }
}


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    bool multitest = false;
   // multitest = true;
    if (multitest) {
        int t; cin >> t;
        while (t--)
            solve();
    }
    else
        solve();
}
