#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;
vvi vl;

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 build()
{
  vl.clear();
  vi v;
  for (int i = 0; i <= n; i++) {
    v.pb(i);
  }
  v.pb(0);
  vl.pb(v);
  for (int i = 1; i <= d; i++) {
    v.clear();
    v.pb(0);
    for (int j = 1; j <= n; j++) {
      if (hl[i][j]) {
        v.pb(vl[i-1][j+1]);
        v.pb(vl[i-1][j]);
        j++;
      } else {
        v.pb(vl[i-1][j]);
      }
    }
    v.pb(0);
    vl.pb(v);
  }
}

bool addline(int i, int j)
{
  return (vl[i][j] == vl[0][m]) && !hl[i][j-1] && !hl[i][j+1];
}

void solve()
{
  build();
  if (vl[d][g] == vl[0][m]) {
    cout << 0 << endl;
    return;
  }
  for (int i = 1; i <= d; i++) {
    for (int j = 1; j <= n; j++) {
      if (vl[i][j] != vl[d][g]) 
        continue;
      if (addline(i, j-1)) {
        cout << i << " " << j-1 << endl;
        return;
      }
      if (addline(i, j+1)) {
        cout << i << " " << j-1 << endl;
        return;
      }
    }
  }
}

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;
}