{$apptype console}
// ACM 2009
// Problem E (incorrect)
// (C) Chistyakov T. S.

uses
  Math;

const
 DX: array [0..3] of integer = (0, -1, 0, 1);
 DY: array [0..3] of integer = (-1, 0, 1, 0);

var
  fi, fo: textfile;
  lab: array of string;
  steps: array of array of array of integer;
  n, x, y, s: integer;
  step, dir, dirSteps: integer;
  i, j: integer;
  nx, ny: integer;
  inLoop: boolean;
begin
  assignfile(fi, 'input.txt');
  assignfile(fo, 'output.txt');
  reset(fi);
  rewrite(fo);

  readln(fi, n, x, y, s);
  setlength(lab, n);
  setlength(steps, n, n, 4);
  for i := 0 to n - 1 do begin
    readln(fi, lab[i]);
    for j := 0 to n - 1 do
      for dir := 0 to 3 do
        steps[i, j, dir] := -1;
  end;

  dir := 0;
  if InRange(x, 1, n) and InRange(y, 1, n) then
    steps[y - 1, x - 1, dir] := 0;

  step := 1;
  dirSteps := 0;
  inLoop := false;
  while step <= s do begin
    for i := 1 to 4 do begin
      nx := x + DX[dir];
      ny := y + DY[dir];
      if
        not InRange(nx, 1, n) or
        not InRange(ny, 1, n) or (lab[ny - 1, nx] = '.')
      then
        Break;
      dir := (dir + 1) mod 4;
      dirSteps := 0;
    end;
    Inc(dirSteps);
    x := nx;
    y := ny;
    if dirSteps > 2000 then begin
      Inc(x, (s - step) * DX[dir]);
      Inc(y, (s - step) * DY[dir]);
      break;
    end;
    if InRange(x, 1, n) and InRange(y, 1, n) then
      if steps[y - 1, x - 1, dir] = -1 then
        steps[y - 1, x - 1, dir] := step
      else if not inLoop then begin
        inLoop := true;
        step := s - (s - step) mod (step - steps[y - 1, x - 1, dir]);
      end;
    Inc(step);
  end;

  writeln(fo, x, ' ', y);

  closefile(fi);
  closefile(fo);
end.