eval'W,H,*A='+$<.read.split*?, p=*i=0...W*H r=->u{u==p[u]?u:p[u]=r[p[u]]} print i.any?{|z|[z+W,z+1].any?{|e|A[z]==A[e]&&(p[u=r[z]]=r[e])==u}}?'':'im',:possible