#include <iostream>

using namespace std;

int main() {
  for (;;) {
    int n, m, h, d, a[9];
    char l[30][10];
    cin >> n;
    if (!n) return 0;
    cin >> m >> h >> d;
    m--;
    h--;
    for (int i = 0; i < d; i++)
      cin >> l[i];
    for (int i = 0; i < n; i++)
      a[i] = i;
    for (int i = 0; i < d; i++)
      for (int j = 0; j < n-1; j++)
        if (l[i][j] == '1')
          swap(a[j], a[j+1]);
    int p = a[h];
    if (m == p) {
      cout << 0 << endl;
      goto next;
    }
    for (int i = 0; i < n; i++)
      a[i] = i;
    for (int i = 0; i < d; i++) {
      for (int j = 0; j < n-1; j++)
        if (l[i][j] == '0' && (!j || l[i][j-1] == '0') && (j == n-2 || l[i][j+1] == '0') &&
            (a[j] == m && a[j+1] == p || a[j] == p && a[j+1] == m)) {
          cout << i+1 << ' ' << j+1 << endl;
          goto next;
        }
      for (int j = 0; j < n-1; j++)
        if (l[i][j] == '1')
          swap(a[j], a[j+1]);
    }
    cout << 1 << endl;
next:;
  }
}