#include <iostream>
#include <algorithm>
using namespace std;

int N, M, Goal, D, G[50];

bool existLine(int x, int y, int dir) {
  int i = x + (dir == -1 ? -1 : 0);
  if(i < 0 || i >= N) return false;
  return (G[y] & (1<<i));
}

bool simulation() {
  int x = M;
  for(int i = 0; i < D; ++i) {
    for(int d = -1; d <= 1; d += 2) {
      if(existLine(x, i, d)) {
	x += d;
	break;
      }
    }
  }
  return x == Goal;
}

void solve() {
  if(simulation()) {
    cout << 0 << endl;
    return;
  }
  for(int i = 0; i < D; ++i) {
    for(int j = 0; j < N-1; ++j) {
      if(!(G[i] & (1<<j))) {
	int mem = G[i];
	G[i] |= (1<<j);
	if(simulation()) {
	  cout << i+1 << " " << j+1 << endl;
	  return;
	}
	G[i] = mem;
      }
    }
  }
}

int main() {
  while(cin >> N && N) {
    cin >> M;
    cin >> Goal;
    cin >> D;
    --M; --Goal;
    for(int i = 0; i < D; ++i) {
      G[i] = 0;
      for(int j = 0; j < N-1; ++j) {
	char c;
	cin >> c;
	if(c == '1') G[i] |= (1<<j);
      }
    }
    solve();
  }
  return 0;
}