#include <iostream>
#include <vector>
#include <string>
#include <array>
#include <functional>
#include <algorithm>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <queue>
#include <bitset>
#include <cassert>
#include <math.h>
#include <complex>
#include <iomanip>
#include <unordered_map>
using namespace std;
#define ll long long
#define pb(x) push_back(x)
#ifdef _OLIMPOLOCAL
    #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 1337
#endif
void debug_out() { cout << "\n";}
template<typename T1, typename... T2> void debug_out(T1 A, T2... B) { cout << " " << A; debug_out(B...); }
int test = 1;
#define out(x) {cout << x << "\n";return;}
#define all(N) N.begin(),N.end()
#define allr(N) N.rbegin(),N.rend()
template<typename T1> 
void pr(vector<T1> V, int add = 0, int start = -1, int end = -1) {
    if (start < 0) start = 0;
    if (end < 0) end = V.size() - 1;
    for (int i = start; i <= end; i++) {
        cout << V[i] + add << ((i == end) ? "\n" : " ");
    }
}
template<typename T1> 
T1 chmin(T1 &x, const T1 v) { return x = min(x,v); }
template<typename T1> 
T1 chmax(T1 &x, const T1 v) { return x = max(x,v); }
#define rep(i, n) for (int i = 0; i < n; i++)
#define reps(i, s, n) for (int i = s; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define repsr(i, s, n) for (int i = n-1; i >= s; i--)
#define PI pair<int,int>
//-------------------------- ^ DONT TOUCH ^-----------------------------------------------------------------
#define MAX 50001
#define MOD 1000000007

ll gcd(ll a, ll b) {
    if (a == 0 || b == 0) return a+b;
    return gcd(b, a % b);
}

ll mult(ll a, ll b, ll m) {
    ll x = a;
    ll s = 0;
    while (b != 0) {
        if (b % 2 == 1) s = (s + x) % m;
        b /= 2;
        x = (x + x) % m;
    }
    return s;
}

ll gcdExtended(ll a, ll b, ll *x, ll *y, ll mod) 
{ 
    
    if (a == 0) 
    { 
        *x = 0; 
        *y = 1; 
        return b; 
    } 

    ll x1, y1; // To store results of recursive call 
    ll gcd = gcdExtended(b%a, a, &x1, &y1, mod); 
 
    // Update x and y using results of 
    // recursive call 
    *x = y1 - (b/a) * x1; 
    *y = x1;
 
    return gcd; 
} 

ll minT(ll t1 ,ll m1, ll t2, ll m2) {
    if(t1 == t2) return t1;
    if (t1 > t2) {
        swap(t1,t2);
        swap(m1,m2);
    }
    ll k1, k2;
    ll g = gcd(m1,m2);
    ll t = t2 - t1;
    if (t % g != 0) return LLONG_MAX;
    ll g2 = m2 / g;
    gcdExtended(m1, m2, &k1, &k2, g2);
    //k1 = (((k1 % g2) + g2) % g2);
    k1 *= t / g;
    k2 *= t / g;
    ll lcm = m1 * g2;
    ll v1 = ((mult(k1,m1, lcm) + t1) % lcm + lcm) % lcm;
    //if (k1 < 0 || k2 < 0) return LLONG_MAX;
    if (v1 % m1 != t1) {
        while(1) {}
    }
    return v1;
}

ll x, y, p, q;

void solve() {
    cin >> x >> y >> p >> q;
    ll m1 = (x + y) * 2;
    ll m2 = p + q;
    ll b = LLONG_MAX;
    rep(i, y) rep(j, q) {
        ll t1 = x + i;
        ll t2 = p + j;
        ll bb = minT(t1, m1, t2, m2);
        if (bb == LLONG_MAX) continue;
        //if(bb % m1 == t1 && bb % m2 == t2) {
            chmin(b, bb);
        //}
    }
    if (b == LLONG_MAX) {
        out("infinity");
    }
    out(b);
}
 
int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int test = 1;
    // #ifdef _OLIMPOLOCAL
         cin >> test;
    // #endif
    rep(testCase, test) {
        #ifdef _OLIMPOLOCAL
            cout << "------------------ TESTCASE: " << testCase << " -------------\n";
        #endif
        solve();
    }
    return 0;
}
//Author: A_S_M_M@sud_P@rvez
#include<bits/stdc++.h>
using namespace std;
#define    MP ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define    For(i,n) for(int i=0;i<n;i++)
#define    Forn(i,n) for(int i=1;i<=n;i++)
#define    Fors(i,s) for(int i=0;i<s.size();i++)
#define    all(v) v.begin(),v.end()
#define    sum(v) accumulate(all(v),0)
#define    gcd(a, b) __gcd(a , b)
#define    lcm(a,b) (a*(b/__gcd(a,b)))
#define    min3(a,b,c)     min(a,min(b,c))
#define    max3(a,b,c)     max(a,max(b,c))
#define    min4(a,b,c,d)   min(min(a,b),min(c,d))
#define    max4(a,b,c,d)   max(max(a,b),max(c,d))
#define    Max(a)  *max_element(a,a+sizeof(a)/sizeof(a[0]))
#define    Min(a)  *min_element(a,a+sizeof(a)/sizeof(a[0]))
#define    End    return 0
#define    gt     greater<int>()
#define    ll     long long
#define    mp     make_pair
#define    pb     push_back
#define    vi     vector<int>
#define    mod    1e9+7 //1000000007
#define    sp(n)  fixed<<setprecision(n)
#define    YES    printf("YES\n")
#define    NO     printf("NO\n")
#define    Erase(s) s.erase(unique(s.begin(),s.end()),s.end())
//%%%%%%%%%%%%%p%%%a%%%r%%%v%%%e%%%z%%%%%%%%%%%%%//

int main()
{
MP;
    //int T;cin >> T;while (T--)
    {
        int n, m, sm = 0, sm1 = 0;
        cin >> n >> m;
        if (n <= m) {
            for (int i = 1; i <= m; i++) {
                cout << -i << " "; 
                sm += i;
            }
            for (int i = 1; i < n; i++) {
                cout << i << " ";
                sm1 += i;
            }
            cout << sm - sm1;
        }
        else {
            for (int i = 1; i <= n; i++) {
                cout << i << " ";
                sm += i;
            }
            for (int i = 1; i < m; i++) {
                cout << -i << " ";
                sm1 += i;
            }
            cout << sm1 - sm;
        }
    }
    cerr<<endl<<(float)clock()/(float)CLOCKS_PER_SEC<<" sec"<<endl;
End;
}
