#include #include #include #include using namespace std; struct Struct{ int h,w,count; bool operator<(const Struct &other)const{ if(h==other.h) return wpast){ if(now.h<0 || now.h>=H)return false; if(now.w<0 || now.w>=W)return false; if(field[now.h][now.w]!=color)return false; if(now.h==start.h && now.w==start.w && now.count>3)return true; if(past[now])return false; past[now]=true; bool response=false; for(int i=0 ; i<4 ; i++ ){ Struct next; next.h=now.h+direction[i]; next.w=now.w+direction[i+1]; next.count=now.count+1; response|=recursion(next,color,past); } return response; } int main(){ cin >> W >> H; for(int i=0 ; i> field[i][j]; for(int i=0 ; i past; start.h=i;start.w=j; Struct now; now.h=i;now.w=j;now.count=0; if(recursion(now,field[i][j],past)){ cout<<"possible"<