uses
  Math;
var
  f: TextFile;
  n, m, b, r1, c1, r2, c2, i, r, c, mn, mx, q: Integer;
  a: array[1..100] of String;
begin
  AssignFile(f, 'input.txt'); Reset(f);
  Readln(f, n, m, b, r1, c1, r2, c2);
  for i := r1 to r2 do Readln(f, a[i - r1 + 1]);
  CloseFile(f);

  mx := b; mn := 0;
  for r := r1 to r2 do
    for c := c1 to c2 do begin
      q := ((r - 1) * m + c - 1) mod b + 1;
      if a[r - r1 + 1, c - c1 + 1] = '=' then
        mn := Max(q, mn)
      else
        mx := Min(q - 1, mx);
    end;

  AssignFile(f, 'output.txt'); Rewrite(f);
  Writeln(f, n * m div b * mn, ' ', n * m div b * mx);
  CloseFile(f);
end.
