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

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

  cin >> n >> 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';
    }
  }

  for (int i=0; i<n; i++) b[i]=i;
  for (int i=d-1; i>=0; i--) {
    for (int j=0; j<n-1; j++) {
      if (a[i][j]) {
        t = b[j];
        b[j] = b[j+1];
        b[j+1] = t;
      }
    }
  }
  if (b[m] == o) {
    cout << "0" << endl;
    return 0;
  }

  l1 = m;
  for (int i=0; i<n; i++) {
    if (b[i] == o) {
      l2 = i;
      break;
    }
  }
  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;
}