#include<iostream> #include<climits> #include<vector> #include<algorithm> #include<numeric> #include <string> using namespace std; int main(){ int T; cin>>T; long long m,n; while(T--){ cin>>m>>n; if(m==1||n==1){ int big=max(m,n); if(big==1) cout<<1<<endl; else if(big>=2){ cout<<big-2<<endl; } }else{ cout<<(m-2)*(n-2)<<endl; } } system("pause"); return 0; }