#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

signed main() {
	bool a[35][15];
	for (int n; cin >> n&&n;) {
		fill(a[0], a[35], false);
		int m, g, d; cin >> m >> g >> d;
		rep(h, 0, d)rep(i, 1, n) { char c; cin >> c; a[h][i] = c - '0'; }
		//rep(h, 0, d)dumpc(a[h]);
		{
			int cur = m;
			rep(j, 0, d) {
				if (a[j][m - 1])cur--;
				else if (a[j][m])cur++;
			}
			if (cur == g) {
				cout << 0 << endl;
				continue;
			}
		}
		bool flag = true;
		rep(h, 0, d)rep(i, 1, n) {
			if (a[h][i - 1] || a[h][i] || a[h][i + 1])continue;
			a[h][i] = true;
			//cerr << h << " "; dumpc(a[h]);
			int cur = m;
			rep(j, 0, d) {
				if (a[j][cur - 1])cur--;
				else if (a[j][cur])cur++;
				//dump(cur);
			}
			if (cur == g) {
				cout << (h + 1) << " " << i << endl;
				i = n - 1; h = d; flag = false; break;
			}
			a[h][i] = false;
		}
		if (flag)cout << 1 << endl;
	}
	return 0;
}