#include <iostream>

using namespace std;

int amida[11];
int n, m, correct, d;

void init()
{
    for (int i = 1; i <= n; i++)
           amida[i] = i;
}

int main()
{
    while (cin >> n, n) {
        string inp[31];

        cin >> m >> correct >> d;
         for (int i = 0; i < d; i++)
            cin >> inp[i];
         init();

        for (int i = 0; i < d; i++) {
            for (int j = 0; j < inp[i].size(); j++)
                if (inp[i][j] == '1')
                    swap(amida[j + 1], amida[j + 2]);
        }

        if (amida[correct] == m)
            cout << 0 << endl;
        else {
            bool flag = false;
            int ans = amida[correct];

            init();
            for (int i = 0; i < d; i++) {
                for (int j = 0; j < inp[i].size(); j++)
                    if (inp[i][j] == '1')
                        swap(amida[j + 1], amida[j + 2]);

                for (int j = 1; j < n; j++) {
                    if ((amida[j] == m && amida[j + 1] == ans)
                        || (amida[j] == ans && amida[j + 1] == m)) {

                        if (inp[i][j - 1] == '1' || inp[i][j] == '1')
                            continue;
                        else if (j > 1 && inp[i][j - 2] == '1')
                            continue;
                        flag = true;
                        cout << i + 1 << " " << j << endl;

                        break;
                    }
                }
                if (flag)
                    break;
            }
            if (!flag)
                cout << 1 << endl;
        }
    }

    return 0;
}