#include <bits/stdc++.h>
using namespace std;

const int inf = 1001001001;

int n, s, g, d;
bool b[50][10];

int main() {
  while (cin >> n, n) {
    cin >> s >> g >> d;

    s--;
    g--;
    vector<int> v(n);
    for (int i = 0; i < n; ++i) v[i] = i;

    for (int i = 0; i < d; ++i) {
      for (int j = 0; j < n - 1; ++j) {
        int f;
        scanf("%1d", &f);
        b[i][j] = f;
        if (b[i][j]) swap(v[j], v[j + 1]);
      }
    }

    int G = v[g];
    if (G == s) {
      cout << 0 << endl;
      continue;
    }

    bool f = false;
    for (int i = 0; i < n; ++i) v[i] = i;

    for (int i = 0; i < d; ++i) {
      if (f) continue;
      for (int j = 0; j < n - 1; ++j) {
        if (b[i][j]) swap(v[j], v[j + 1]);
      }

      for (int j = 0; j < n; ++j) {
        if (f) continue;

        if (v[j] == s) {

          if (j != 0 && v[j - 1] == G) {
            bool c = true;
            for (int k = j - 2; k <= j; ++k)
              if (0 <= k && k < n && b[i][k]) c = false;
            if (c) {
              cout << i + 1 << " " << j << endl;
              f = true;
            }
          }

          if (j != n - 1 && v[j + 1] == G && !b[i][j]) {
            bool c = true;
            for (int k = j - 1; k <= j + 1; ++k)
              if (0 <= k && k < n && b[i][k]) c = false;
            if (c) {
              cout << i + 1 << " " << j + 1 << endl;
              f = true;
            }
          }
        }
      }
    }
    if (f) continue;

    cout << 1 << endl;
  }
}