while n = gets.to_i
  break if n == 0
  m = gets.to_i
  init = Array.new(n){0}
  init[m-1] = 1
  hit = gets.to_i
  ans = Array.new(n){0}
  ans[hit-1] = 1
  d = gets.to_i

  trial = init.clone
  arr = []
  candidate = []
  d.times{|i|
    arr[i] = gets.chomp.split("").map(&:to_i)
    candidate << [i, 0] if arr[i][0] == 0 && arr[i][1] == 0
    1.upto(n-3){|j|
      candidate << [i, j] if arr[i][j-1] == 0 && arr[i][j] == 0 && arr[i][j+1] == 0
    }
    candidate << [i, n-2] if arr[i][n-3] == 0 && arr[i][n-2] == 0
    (n-1).times{|j|
      trial[j], trial[j+1] = trial[j+1], trial[j] if arr[i][j] == 1
    }
  }
  if trial == ans
    puts 0
  else
    flag = false
    candidate.each{|x, y|
      b = arr.map(&:dup)
      b[x][y] = 1
      trial = init.clone
      d.times{|i|
        (n-1).times{|j|
          trial[j], trial[j+1] = trial[j+1], trial[j] if b[i][j] == 1
        }
      }
      if trial == ans
        puts "#{x+1} #{y+1}"
        flag = true
        break
      end
    }
    if flag == false
      puts 1
    end
  end
end