#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main() {
	int n;
	while(cin >> n){
		if (n == 0) {
			break;
		}
		int m;
		cin >> m;
		int p;
		cin >> p;
		int d;
		cin >> d;
		vector< vector<int> > data(n+1, vector<int>(d+1));
		for (int i = 1; i < n+1; i++) {
			data[i][0] = i;
		}
		vector<string> str;
		string a;
		for (int i = 0; i < d; i++) {
			cin >> a;
			for (int j = 1; j < n+1; j++) {
				data[j][i+1] = data[j][i];
			}
			for (int j = 0; j < a.size(); j++) {
				if (a[j] == '1') {
					swap(data[j+1][i+1], data[j+2][i+1]);
				}
			}
			str.push_back(a);
		}/*
		for (int i = 0; i < d+1; i++) {
			for (int j = 1; j < n+1; j++) {
				cout << data[j][i] << ' ';
			}
			cout << endl;
		}*/
		if (data[m][d] == p) {
			cout << 0 << endl;
		} else {
			p = data[p][d];
			bool hantei = false;
			for (int i = 1; i < d+1; i++) {
				for (int j = 1; j < n; j++) {
					if ((data[j][i] == m && data[j+1][i] == p) || (data[j][i] == p && data[j+1][i] == m)) {
						if (str[i-1][j-1] == '0') {
							bool hantei2 = true;
							if (j-2 >= 0) {
								if (str[i-1][j-2] == '1') {
									hantei2 = false;
								}
							}
							if (j < str[i-1].size()) {
								if (str[i-1][j] == '1') {
									hantei2 = false;
								}
							}
							if (hantei2) {
								cout << i << ' ' << j << endl;
								hantei = true;
							}
						}
					}
				}
				if (hantei) {
					break;
				}
			}
			if (!hantei) {
				cout << -1 << endl;
			}
		}
	}
	return 0;
}