#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define M 100000
#define mod 1000000007

int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r",stdin);
    freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    lli t;
    cin >> t;
    while(t--){
        lli x, y;
        cin >> x >> y;
        lli s1 = 0, s2 = 0, prev = y, m =0;
        while(s1!=x || s2!=y){
            if(s1!=x && prev == y){
                s1++;
                prev = x;
                continue;
            }
            else if(s2!=y && prev == x){
                s2++;
                prev = y;
                continue;
            }
            else if(s1==x && prev == y){
                m++;
                prev = x;
                continue;
            }
            else if(s2==y && prev == x){
                m++;
                prev = y;
                continue;
            }
        }
        if(x<y)
        cout << s1 + s2 + m-1 << endl;
        else cout << s1 + s2 + m << endl;
    }
}

/**/