#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
typedef vector<int> vi;
#define pb push_back

typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;

int n, m, g, d;
vvb hl;

void s2vb(const string& s, vb& v)
{
  v.clear();
  v.pb(0);
  for (auto& c : s) {
    if (c == '1')
      v.pb(true);
    else
      v.pb(false);
  }
  v.pb(0);
}

void solve()
{
  typedef pair<int, int> pii;
  typedef vector<pii> vp;
  vp neighbor(n+2, pii(0,0));
  vi v(n+2, 0);
  for (int i = 1; i <= n; i++) {
    v[i] = i;
  }
  for (int i = 1; i <= d; i++) {
    for (int j = 1; j <= n; j++) {
      if (hl[i][j]) {
        swap(v[j], v[j+1]);
      }
    }
    for (int j = 1; j <= n; j++) {
      if (v[j] != m)
        continue;
      int k = j - 1;
      if (v[k] && neighbor[v[k]].first == 0 && hl[i][k-1] == 0 && hl[i][k] == 0 && hl[i][k+1] == 0)
        neighbor[v[k]] = pii(i, k);
      k = j + 1;
      if (v[k] && neighbor[v[k]].first == 0 && hl[i][j-1] == 0 && hl[i][j] == 0 && hl[i][j+1] == 0)
        neighbor[v[k]] = pii(i, j);
    }
  }
  if (v[g] == m) {
    cout << 0 << endl;
  } else if (neighbor[v[g]].first) {
    cout << neighbor[v[g]].first << " " << neighbor[v[g]].second << endl;
  } else {
    cout << 1 << endl;
  }
}

int main(int argc, char **argv)
{
  for (;;) {
    cin >> n;
    if (!n)
      break;
    cin >> m >> g >> d;
    string s;
    vb h;
    hl.pb(vb(n+1, false));
    for (int i = 0; i < d; i++) {
      cin >> s;
      s2vb(s, h);
      hl.pb(h);
    }
    solve();
  }

  return 0;
}