import java.util.*; import java.util.stream.*; import static java.lang.Math.*; public class Main{ public static int[] dx={-1,0,0,1}; public static int[] dy={0,1,-1,0}; public static void main(String... args){ Scanner sc=new Scanner(System.in); int w=sc.nextInt(); int h=sc.nextInt(); int[][] m=new int[h][w]; for(int i=0;i deq=new ArrayDeque<>(); deq.add(new Cell(null,new Pair(i,j))); while(deq.size()>0){ Cell cell=deq.poll(); if(reached[cell.next.x][cell.next.y]){ //put("(x,y)=(%d,%d)",cell.next.x,cell.next.y); put("possible"); return; } reached[cell.next.x][cell.next.y]=true; for(int k=0;k<4;k++){ int x=cell.next.x+dx[k]; int y=cell.next.y+dy[k]; if(x<0||x>=h||y<0||y>=w)continue; if(m[x][y]!=num)continue; Pair next=new Pair(x,y); if(next.equals(cell.prev))continue; deq.addLast(new Cell(cell.next,next)); } } } } put("impossible"); } public static class Cell{ final Pair prev,next; Cell(Pair prev,Pair next){ this.prev=prev; this.next=next; } } public enum Direction{ UP, DOWN, LEFT, RIGHT; } public static class Pair{ final int x,y; Pair(int x,int y){ this.x=x; this.y=y; } @Override public String toString(){ return String.format("Pair(%d,%d)",x,y); } @Override public int hashCode(){ return x*1000+y; } @Override public boolean equals(Object obj){ if(obj==null)return false; if(obj instanceof Pair){ Pair pair=(Pair)obj; return x==pair.x&&y==pair.y; } return false; } } public static void print(Object object){ System.out.print(object); } public static void put(Object object) { System.out.println(object); } public static void put(){ System.out.println(); } public static void print(String format,Object... args){ System.out.print(String.format(format,args)); } public static void put(String format,Object... args) { System.out.println(String.format(format,args)); } }