#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int n, m, g, d;
string s[30];

bool reach() {
  int now = m;
  for (int i = 0; i < d; i++) {
    if (now - 1 >= 0 && s[i][now - 1] == '1') now--;
    else if (now + 1 < n && s[i][now] == '1') now++;
  }
  return now == g;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  while (cin >> n, n) {
    cin >> m >> g >> d;
    m--, g--;
    for (int i = 0; i < d; i++) {
      cin >> s[i];
    }
    if (reach()) {
      cout << "0" << endl;
      continue;
    }
    bool ok = false;
    for (int i = 0; i < d; i++) {
      for (int j = 0; !ok && j < n - 1; j++) {
        if (s[i][j] == '1') continue;
        if (j - 1 >= 0 && s[i][j - 1] == '1') continue;
        if (j + 1 < n - 1 && s[i][j + 1] == '1') continue;
        s[i][j] = '1';
        if (reach()) {
          cout << i + 1 << " " << j + 1 << endl;
          ok = true;
          break;
        }
        s[i][j] = '0';
      }
    }
    if (!ok) cout << "1" << endl;
  }

  return 0;
}
