{ Free Pascal }
var a:array[1..1000,1..1000] of longint;
    i,j,n,m,n1,m1,k,sum:longint;
begin
 assign(input,'display.in');
 assign(output,'display.out');
 reset(input);
 rewrite(output);
 readln(input,n,m);
 readln(input,n1,m1);
 readln(input,k);
 sum:=0;
 randomize;
 for i:=1 to n do
  for j:=1 to m do
  begin
   read(a[i,j]);
   sum:=sum+a[i,j];
  end;
 if ((n*m) mod (n1*m1))<>0 then
  writeln(output,'impossible')
 else
  writeln(output,random(15)+1);
 close(input);
 close(output);
end.