#include <iostream>
#include <string>
using namespace std;

int main() {
  int n, m, o, d, t, l1, l2;
  string str;
  bool a[10][30], x;

  while (cin >> n) {
    cin >> m >> o >> d;
    --m; --o;
    for (int i=0; i<d; i++) {
      cin >> str;
      for (int  j=0; j<n-1; j++) {
        a[i][j] = str.at(j)-'0';
      }
    }
    cin >> t;

    l1 = m;
    l2 = o;
    for (int i=d-1; i>=0; i--) {
      if (l2<n-1 && a[i][l2]) ++l2;
      else if (l2 && a[i][l2-1]) --l2;
    }
    if (l1 == l2) {
      cout << "0" << endl;
      continue;
    }

    x = false;
    for (int i=0; i<d; i++) {
      t = 0;
      if (l1<n-1 && a[i][l1]) ++l1;
      else if (l1 && a[i][l1-1]) --l1;
      else ++t;
      if (l2<n-1 && a[i][l2]) ++l2;
      else if (l2 && a[i][l2-1]) --l2;
      else ++t;
      if (t==2 && (l1==l2+1 || l2==l1+1)) {
        cout << i+1 << " " << ((l1<l2) ? l2 : l1) << endl;
        x = true;
        break;
      }
    }
    if (!x) {
      cout << "1" << endl;
    }
  }

  return 0;
}