import sys

import itertools



def one_step(lo,lis):

    nu = [ e for e in lis ]

    for j in range(len(nu)):

        if lo[0][j] == 1:

            nu[j],nu[j+1] = nu[j+1],nu[j]

    return lo[1:],nu



def solve(lo,lis):

    if len(lo) == 0:

        return lis

    nu = [ e for e in lis]

    lo2,nu2 = one_step(lo,nu)

    return solve(lo2,nu2)



while True:

    n = eval(input())

    if n == 0: exit()

    m = eval(input())

    star = eval(input())

    d = eval(input())

    lis = list(range(n+1))

    lots = []

    for i in range(d):

        lots.append( [0] + list(map(int,input())) + [0])

    if solve(lots,lis)[star] == m: print(0);continue

    for i,j in itertools.product(range(d),range(1,n)):

        if lots[i][j-1] + lots[i][j] + lots[i][j+1] == 0:

            lots[i][j] = 1

            if solve(lots,lis)[star] == m: print(i+1,j);break

            lots[i][j] = 0

    else: print(1)
import sys

import itertools



def one_step(lo,lis):

    nu = [ e for e in lis ]

    for j in range(len(nu)):

        if lo[0][j] == 1:

            nu[j],nu[j+1] = nu[j+1],nu[j]

    return lo[1:],nu



def solve(lo,lis):

    if len(lo) == 0:

        return lis

    nu = [ e for e in lis]

    lo2,nu2 = one_step(lo,nu)

    return solve(lo2,nu2)



def func(lots,lis,n,m,star,d):

    for i in range(d):

        for j in range(1,n):

            if lots[0][j-1] + lots[0][j] + lots[0][j+1] == 0:

                lots[0][j] = 1

                if solve(lots,lis)[star] == m: print(i+1,j);return True

                lots[0][j] = 0

        lots,lis = one_step(lots,lis)

    return False



while True:

    n = eval(input())

    if n == 0: exit()

    m = eval(input())

    star = eval(input())

    d = eval(input())

    lis = list(range(n+1))

    lots = []

    for i in range(d):

        lots.append( [0] + list(map(int,input())) + [0])

    if solve(lots,lis)[star] == m: print(0);continue

    elif func(lots,lis,n,m,star,d): continue

    else: print(1)
import sys
import itertools


def one_step(lo, lis):
    nu = [e for e in lis]
    for j in range(len(nu)):
        if lo[0][j] == 1:
            nu[j], nu[j + 1] = nu[j + 1], nu[j]
    return lo[1:], nu


def solve(lo, lis):
    if len(lo) == 0:
        return lis
    nu = [e for e in lis]
    lo2, nu2 = one_step(lo, nu)
    return solve(lo2, nu2)


while True:
    n = eval(input())
    if n == 0:
        exit()
    m = eval(input())
    star = eval(input())
    d = eval(input())
    lis = list(range(n + 1))
    lots = []
    for i in range(d):
        lots.append([0] + list(map(int, input())) + [0])
    if solve(lots, lis)[star] == m:
        print(0)
        continue
    for i, j in itertools.product(range(d), range(1, n)):
        if lots[i][j - 1] + lots[i][j] + lots[i][j + 1] == 0:
            lots[i][j] = 1
            if solve(lots, lis)[star] == m:
                print(i + 1, j)
                break
            lots[i][j] = 0
    else:
        print(1)

import sys
import itertools


def one_step(lo, lis):
    nu = [e for e in lis]
    for j in range(len(nu)):
        if lo[0][j] == 1:
            nu[j], nu[j + 1] = nu[j + 1], nu[j]
    return lo[1:], nu


def solve(lo, lis):
    if len(lo) == 0:
        return lis
    nu = [e for e in lis]
    lo2, nu2 = one_step(lo, nu)
    return solve(lo2, nu2)


def func(lots, lis, n, m, star, d):
    for i in range(d):
        for j in range(1, n):
            if lots[0][j - 1] + lots[0][j] + lots[0][j + 1] == 0:
                lots[0][j] = 1
                if solve(lots, lis)[star] == m:
                    print(i + 1, j)
                    return True
                lots[0][j] = 0
        lots, lis = one_step(lots, lis)
    return False


while True:
    n = eval(input())
    if n == 0:
        exit()
    m = eval(input())
    star = eval(input())
    d = eval(input())
    lis = list(range(n + 1))
    lots = []
    for i in range(d):
        lots.append([0] + list(map(int, input())) + [0])
    if solve(lots, lis)[star] == m:
        print(0)
        continue
    elif func(lots, lis, n, m, star, d):
        continue
    else:
        print(1)

+def func(lots, lis, n, m, star, d): +    for i in range(d): +        for j in range(1, n): +            if lots[0][j - 1] + lots[0][j] + lots[0][j + 1] == 0: +                lots[0][j] = 1 +                if solve(lots, lis)[star] == m: +                    print(i + 1, j) +                    return True +                lots[0][j] = 0 +        lots, lis = one_step(lots, lis) +    return False + + -    for i, j in itertools.product(range(d), range(1, n)): -        if lots[i][j - 1] + lots[i][j] + lots[i][j + 1] == 0: -            lots[i][j] = 1 -            if solve(lots, lis)[star] == m: -                print(i + 1, j) -                break -            lots[i][j] = 0 +    elif func(lots, lis, n, m, star, d): +        continue