#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>
#include <fstream>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

int m, k, a, d;
vector<string> g(9);

bool solve() {
  int x = k - 1;
  rep(y, 9) {
    if(g[y][x]) x++;
    else if(x && g[y][x-1]) x--;
  }
  return x == a - 1;
}

int main() {

  while(cin >> m >> k >> a >> d && m) {
    rep(i, 9) cin >> g[i];
    rep(i, 9) for(auto& e: g[i]) e -= '0';
    if(solve()) {
      cout << "0\n";
      goto next;
    }
    rep(i, 9) rep(j, m - 1) {
      if(!g[i][j] && (j == 0 || !g[i][j-1]) && (j + 1 == m || !g[i][j+1])) {
        g[i][j] = 1;
        if(solve()) {
          cout << i + 1 << " " << j + 1 << endl;
          goto next;
        }
        g[i][j] = 0;
      }
    }
    cout << "1\n";
  next:;
  }
  
  return 0;
}