#include <iostream>
#include <string>

using namespace std;

bool input(string str, int& n, int& m, int& star, int& d, int lottery[][9])
{
	cin >> n;
	if (n==0) return false;
	cin >> m >> star >> d;
	m--; star--;
	
	for (int i=0; i<d; i++) {
		cin >> str;
		for (int j=0; j<n-1; j++) lottery[i][j] = str.at(j) - '0';
	}
	return true;
}

int main()
{
	string str;
	int n, m, star, d;
	int lottery[30][9];
	
	while (input(str, n, m, star, d, lottery)) {
		int traj_star[31];		
		traj_star[d] = star;
		for (int i=d-1; i>=0; i--) {
			traj_star[i] = traj_star[i+1];
			if (traj_star[i]>0 && lottery[i][traj_star[i]-1] == 1) traj_star[i]--;
			else if (traj_star[i]<n-1 && lottery[i][traj_star[i]] == 1) traj_star[i]++;
		}
		
		if (traj_star[0] == m) {
			cout << 0 << endl;	continue;
		}
		
		int insert_row = -1, insert_column;
		int traj_target[31];
		traj_target[0] = m;
		for (int i=1; i<d; i++) {
			bool swap_flg = false;
			traj_target[i] = traj_target[i-1];
			if (traj_target[i]>0 && lottery[i-1][traj_target[i]-1] == 1) { traj_target[i]--; swap_flg = true; }
			else if (traj_target[i]<n-1 && lottery[i-1][traj_target[i]] == 1) { traj_target[i]++; swap_flg = true; }
			if (traj_star[i] != traj_star[i-1]) swap_flg = true;
			if (!swap_flg) {
				//if (traj_target[i]-1 == traj_star[i] && lottery[i][traj_target[i]-1] == 0 ) {
				if (traj_target[i]-1 == traj_star[i] ) {
					insert_row = i; insert_column = traj_target[i]-1; break;
				}
				//else if (traj_target[i]+1 == traj_star[i] && lottery[i][traj_target[i]] == 0 ) {
				else if (traj_target[i]+1 == traj_star[i] ) {
					insert_row = i; insert_column = traj_target[i]; break;
				}
			}
		}
		if (insert_row>=0)	cout << insert_row << " " << insert_column + 1 << endl;
		else cout << 1 << endl;
		/*		
		for (int i=0; i<=d; i++) cout << traj_star[i] << " ";
		cout << endl;		
		for (int i=0; i<=d; i++) cout << traj_target[i] << " ";
		cout << endl;
		*/
	
	}	
	
	return 0;
}