import std.stdio,std.string,std.conv;

int main()
{
	int n;
	while(( n = readln.chomp.to!int) != 0)
	{
		int m = readln.chomp.to!int;
		int ans = readln.chomp.to!int;
		int d = readln.chomp.to!int;

		char[][] c = new char[][](d,m-1);
		foreach(i;0..d)
		{
			string s = readln.chomp;
			c[i] = s.dup;
		}


		int place = m;

		foreach(i;0..d)
		{
			if(place == 1)
			{
				if(c[i][0] == '1') place = 2;
			}
			else if(place == n)
			{
				if(c[i][n-2] == '1') place = n-1;
			}
			else
			{
				if(c[i][place-2] == '1') place -= 1;
				else if(c[i][place-1] == '1') place += 1;
			}
		}

		if(place == ans)
		{
			writeln(0);
		}
		else
		{
			int a[2];
			bool flag = true;

			foreach(i;0..d)
			{
				foreach(j;0..n-1)
				{
					if(flag && c[i][j] == '0')
					{
						bool temp = true;

						if(j == 0)
						{
							if(c[i][j+1] == '1') temp = false;
						}
						else if(j == n-2)
						{
							if(c[i][n-3] == '1') temp = false;
						}
						else
						{
							if(c[i][j-1] == '1' || c[i][j+1]  == '1') temp = false;
						}

						if(temp)
						{
							c[i][j] = '1';
							int place2 = m;

							foreach(k;0..d)
							{
								if(place2 == 1)
								{
									if(c[k][0] == '1') place2 = 2;
								}	
								else if(place2 == n)
								{
									if(c[k][n-2] == '1') place2 = n-1;
								}
								else
								{
									if(c[k][place2-2] == '1') place2 -= 1;
									else if(c[k][place2-1] == '1') place2 += 1;
								}
							}

							if(place2 == ans)
							{
								flag = false;
								a[0] = i+1;
								a[1] = j+1;
								break;
							}
							c[i][j] = '0';
						}
					}
				}
			}
			if(flag == false)
			{
				writeln(a[0]," ",a[1]);
			}
			else
			{
				writeln(1);
			}

		}
	}
	return 0;
}