{ Free Pascal }
var f,g:text;
    s,j,i,n,m,n1,m1,k:longint;
    pole:array[1..1000,1..1000] of longint;
    odnak:boolean;

BEGIN
 assign(f,'display.in'); reset(f); assign(g,'display.out'); rewrite(g);
 Read(f,n,m,n1,m1,k);
 odnak:=true;
 s:=0;
 for i:=1 to n do for j:=1 to m do begin
  read(f,pole[i,j]);
  if pole[i,j]<>0 then inc(s,k-pole[i,j]);
 end;
 i:=1; j:=1;
 while (odnak) and (i<=n) do
  If pole[i,j]<>pole[1,1] then odnak:=false
  else begin
   if j=m then begin
    inc(i);
    j:=1;
   end else inc(j);
  end;

 If odnak then writeln(g,(k-pole[1,1])*m*n)
 else if (n1=1) and (m1=1) then writeln(g,s)
 else if (n1=n) and (m1=m) then writeln(g,'impossible')
 else begin
  j:=(n-n1+1)*(m-m1+1)-1;
  if (((n-n1) mod 2 = 0) or ((m-m1) mod 2 = 0)) and (j mod 2 = 1) then odnak:=true;
  if odnak then writeln(g,j)
  else writeln(g,'impossible');
 end;
 close(f); close(g);
END.