/* #pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define rep(i,n) for(long long i=0;i=0;--i) #define debug(output) if(debugFlag)cout<<#output<<"= "< P; const bool debugFlag=true; const lint linf=1.1e18;const lint inf=1.01e9; constexpr int MOD=1000000007; templatebool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; } templatebool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; } void solve(){ int h,w;cin>>h>>w; vector> a(h+5,vector(w+5,-1)); vector> s={ {2,2,1}, {2,2,1}, {1,1,0} }; rep(i,h/3*3)rep(j,w/3*3){ a[i+1][j+1]=s[i%3][j%3]; } if(h%3==1){ if(w%3==1){ rep(j,w-1)a[0][j+1]=s[2][j%3]; rep(i,h-1)a[i+1][0]=s[i%3][2]; a[0][0]=0; } else if(w%3==2){ rep(j,w-2)a[0][j+1]=s[2][j%3]; rep(i,h-1){ a[i+1][w-1]=s[i%3][0]; a[i+1][w]=s[i%3][1]; } a[0][w-1]=1; a[0][w]=1; } else rep(j,w)a[0][j+1]=s[2][j%3]; } else if(h%3==2){ if(w%3==1){ rep(i,h)a[i+1][0]=s[i%3][2]; rep(j,w-1){ a[h-1][j+1]=s[0][j%3]; a[h][j+1]=s[1][j%3]; } } else if(w%3==2){ rep(i,h){ a[i+1][w-1]=s[i%3][0]; a[i+1][w]=s[i%3][1]; } rep(j,w){ a[h-1][j+1]=s[0][j%3]; a[h][j+1]=s[1][j%3]; } } else{ rep(j,w){ a[h-1][j+1]=s[0][j%3]; a[h][j+1]=s[1][j%3]; } } } else{ if(w%3==1)rep(i,h)a[i+1][0]=s[i%3][2]; else if(w%3==2){ rep(i,h){ a[i+1][w-1]=s[i%3][0]; a[i+1][w]=s[i%3][1]; } } } rep(i,h+5){ rep(j,w+5){ if(a[i][j]==-1)continue; cout<>t; rep(i,t)solve(); return 0; }