#include<stdio.h> #include<string.h> int col[10005],row[10005]; int main() { int t,n,m,i,j,x,y; scanf("%d",&t); while(t--){ scanf("%d%d",&n,&m); memset(row,0,sizeof(row)); memset(col,0,sizeof(col)); i = j = x = y = 1; while(x<=n && y<=m){ //len(i到n) = n-i+1; //len(j到m) = m-j+1; if(n-i+1 < m-j+1 ){ j=j+(n-i+1); i=n+1; } //这里不容易啊 // i先到最底层,要返回 else if(n-i+1 > m-j+1 ){ i = i+(m-j+1); j=m+1;} // j先到最底层 else { i = n+1; j = m+1; } // 同时到最底层 if(i>n) { // i到达最底层 i = 1; if(j<=m){ if(row[j]) break; row[j] = 1; y++; }else {row[1] = 1;y++;} } if(j>m) { // j 到达最底层 j = 1; if(i<=n){ if(col[i]) break; col[i] = 1;x++; }else {col[1]=1;x++;} } } if(x ==n+1 && y == m+1) puts("Possible"); else puts("Impossible"); } return 0; } /* 3 2 3 2 2 3 6 */