loop do
  n = gets.to_i
  break if n==0
  m = gets.to_i
  g = gets.to_i
  d = gets.to_i
  b = d.times.map{gets.chomp.chars.map(&:to_i)}

  map = Array.new(d+1){Array.new(n,0)}
  n.times do |i|
    map[0][i] = i+1
  end

  d.times do |j|
    n.times do |i|
      if i<n && b[j][i] == 1 
        map[j+1][i] = map[j][i+1]
      elsif i>0 && b[j][i-1] == 1
        map[j+1][i] = map[j][i-1]
      else
        map[j+1][i] = map[j][i]
      end
    end
  end

  if map[d][g-1] == m
    puts 0
  elsif
    k = map[d][g-1]

    catch(:br) do
      d.times do |j|
        i = map[j].find_index(m)
        if i<n-1 && b[j][i] == 0 && (i<=0 || b[j][i-1] == 0) && (i>=n-2 || b[j][i+1] == 0)
          if map[j][i+1] == k
            puts [j+1, i+1].join(' ')
            throw :br
          end
        elsif i>0 && b[j][i-1] == 0 && (i>=n-1 || b[j][i] == 0) && (i<2 || b[j][i-2] == 0)
          if map[j][i-1] == k
            puts [j+1, i].join(' ')
            throw :br
          end
        end
      end
      puts '1'
    end

  end
end