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

#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main()
{
	int n,m,ans,d;
	cin >> n >> m >> ans >> d;

	string *s = new string[d];
	rep(i,d)
	{
		cin >> s[i];
	}

	int end;
	cin >>  end;
	if(end == 0)
	{
		int place = m;

		rep(i,d)
		{
			if(place == 1)
			{
				if(s[i][0] == '1') place = 2;
			}
			else if(place == n)
			{
				if(s[i][n-2] == '1') place = n-1;
			}
			else
			{
				if(s[i][place-2] == '1') place -= 1;
				else if(s[i][place-1] == '1') place += 1;
			}
		}

		if(place == ans)
		{
			cout << 0 << end;;
		}
		else
		{
			int a[2];
			bool flag = true;
			
			rep(i,d)
			{
				rep(j,n-1)
				{
					if(flag)
					{
						if(s[i][j] == '0')
						{
							bool temp = true;

							if(j == 0)
							{
								if(s[i][j+1] == '1') temp = false;
							}

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

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

								rep(k,d)
								{
									if(place2 == 1)
									{
										if(s[k][0] == '1') place2 = 2;
									}	
									else if(place2 == n)
									{
										if(s[k][n-2] == '1') place2 = n-1;
									}
									else
									{
										if(s[k][place2-2] == '1') place2 -= 1;
										else if(s[k][place2-1] == '1') place2 += 1;
									}
								}

								if(place2 == ans)
								{
									flag = false;
									a[0] = i+1;
									a[1] = j+1;
									break;
								}

								s[i][j] = '0';
							}						
						}
					}
				}
			}
			
			if(flag == false)
			{
				cout << a[0] << " " << a[1] << endl;
			}
			else
			{
				cout << 1 << endl;
			}
		}
	}
	return 0;
}