#include<bits/stdc++.h>
#include<ctime>
///#include<fstream>
///#include<windows.h>
using namespace std;

#define ll long long
#define ld long double
#define ull unsigned long long int
#define pb push_back
#define pf push_front
#define en cout<<endl;
#define yes cout<<"YES\n";
#define no  cout<<"NO\n";
#define no1 {cout<<-1<<'\n'; r0}
#define no0 {cout<<0<<'\n'; r0}
#define yes_r { cout<<"YES\n"; return ; }
#define no_r { cout<<"NO\n"; return ; }
#define r0 return ;
#define fr first
#define sc second
#define srt(name) sort(name.begin(), name.end());
#define rev(name) reverse(name.begin(), name.end());
#define TT { ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0) ; int tt; cin>>tt; while (tt--) not_main(); }
#define TT1 { not_main(); }
#define TTi { while(1) not_main(); }
#define IMP { cout<<"Impossible\n"; r0 }
#define PII pair<int, int>

const int INF=1e9+1;
const int mod=1e9+7;
const int N=1e5+1;

string all = "abcdefghijklmnopqrstuvwxyz";
string Call= "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string Vow = "aeiou";

ll gs(ll h)
{
    return (h*(h+1))/2 + h-1;
}

void not_main()
{
    ll h, w;
    cin>>h>>w;
ll ans=h*w;

    while (h!=1 or w!=1){
        if (h>=w){
            ans+=gs(w);
            h--;
            ans+=h*w;

        }else{
            ans+=gs(h);
            w--;
            ans+=h*w;
        }
            ///cout<<h<<' '<<w<<' '<<ans<<'\n';
    }
    cout<<ans;
}
int main()
{
    ios_base::sync_with_stdio(0) ;
    cin.tie(0) ;
    TT1
}