Harryxun/stf_run huggingface dataset:
S = input()
X, Y = map(int, input().split())

T = [0] if S[0] == "T" else []
for i in range(1, len(S)):
  if S[i] != S[i-1]:
    T.append(i)
T.append(len(S))
#print("T:", T)

U = [T[0]]
for i in range(1, len(T)):
  U.append(T[i] - T[i-1])
#print("U:", U)

sum_T = 0
DX, DY = [], []
for i in range(len(U)):
  if i % 2:
    sum_T += U[i]
  else:
    if sum_T % 2 == 0:
      DX.append(U[i])
    else:
      DY.append(U[i])
#print("DX, DY:", DX, DY)

SX, SY = sum(DX), sum(DY)

ax = 1 << SX + DX[0]
for i in range(1, len(DX)):
  ax |= (ax << DX[i]) | (ax >> DX[i])
#print("ax:", bin(ax))
if SX + X < len(bin(ax)[2:]):
  #print((bin(ax)[2:])[::-1][SX + X])
  #print("O:", SX + DX[0])
  aax = int((bin(ax)[2:])[::-1][SX + X])
else:
  aax = 0

ay = 1 << SY
for i in range(0, len(DY)):
  ay |= (ay << DY[i]) | (ay >> DY[i])
#print("ay:", bin(ay))
if SY + Y < len(bin(ay)[2:]):
  #print((bin(ay)[2:])[::-1][SY + Y])
  #print("O:", SY)
  aay = int((bin(ay)[2:])[::-1][SY + Y])
else:
  aay = 0

print("Yes" if aax * aay else "No")

### FIXED CODE ###

S = input()
X, Y = map(int, input().split())

SIZE = 10 ** 4

M = [0] if S[0] == "T" else []
for i in range(1, len(S)):
  if S[i] != S[i-1]:
    M.append(i)
M.append(len(S))
M = [0] + M
#print("M:", M)

L = []
for i in range(1, len(M)):
  L.append(M[i] - M[i - 1])
#print("L:", L)

for i in range(3, len(L), 2):
  L[i] += L[i - 2]
L = [0] + L
#print("L:", L)

x = 1 << SIZE
y = 1 << SIZE
#print("x:", bin(x)[2::])
#print("y:", bin(y)[2::])

for i in range(1, len(L), 2):
  dist = L[i]
  dirc = L[i - 1]
  #print("dist, dirc:", dist, dirc)
  if i == 1:
    x = x << dist
  else:
    if dirc % 2 == 0:
      x = (x << dist) | (x >> dist)
    else:
      y = (y << dist) | (y >> dist)
      
if (x >> SIZE + X) & 1 == 1 and (y >> SIZE + Y) & 1 == 1:
  print("Yes")
else:
  print("No")
def solution(n, k, l_list):
    l_list.sort(reverse=True)
    result = sum(l_list[:k])
    return result


N, K = [int(value) for value in input().split(' ')]
l_list = [int(value) for value in input().split(' ')]
print(solution(n, k, l_list))

### FIXED CODE ###

def solution(n, k, l_list):
    l_list.sort(reverse=True)
    result = sum(l_list[:k])
    return result


N, K = [int(value) for value in input().split(' ')]
l_list = [int(value) for value in input().split(' ')]
print(solution(N, K, l_list))
def Fib(n):
    if n == 1:
        return 0
    elif n == 2:
        return 1
    else:
        return Fib(n-1)+Fib(n-2)

        
n, m = [int(i) for i in input().split()]
a = [int(input()) for i in range(m)]
MOD = 1000000007

#出来ない判定
for i in range(m-1):
    if (a[i+1] - a[i]) == 1:
        print(0)
        exit()

#壊れてる床前後で組み合わせ
allnum = 1
i = 0
for b in range(m):
    allnum = (allnum * Fib(a[b]-1 - i + 2))%MOD
    i = a[b]+1

allnum = (allnum * Fib(n - i + 2))%MOD

print(allnum)

### FIXED CODE ###

import sys
 
n, m = list(map(int, input().split()))
if m > 0:
    aaa = set(map(int, sys.stdin))
else:
    aaa = set()
dp = [0] * (n + 1)
dp[0] = 1
dp[1] = 1 if 1 not in aaa else 0
MOD = 10 ** 9 + 7
 
for i in range(2, n + 1):
    if i in aaa:
        continue
    dp[i] = (dp[i - 2] + dp[i - 1]) % MOD
print(dp[n])
if input() >= 30:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

if int(input()) >= 30:
  print("Yes")
else:
  print("No")
#include<stdio.h>
 
int main(){
  int x;

  scanf("%d", &x);
 
  printf("%d\n",x*x*x);
 
  return 0;
}


### FIXED CODE ###

print(int(input())**3)
from math import pi
r = int(input())
print("{:.010f} {:.010f}".format(2 * pi * r, r * r * pi))

### FIXED CODE ###

from math import pi
r = float(input())
print("{:.010f} {:.010f}".format(r * r * pi, 2 * pi * r))
a=input(int())
if a=1:
  print(a)
elif a%2==0:
  print((a/2)/a)
else:
  print(-(-a//2)/a)
  


### FIXED CODE ###

import math
a=int(input())
b=math.floor(float(a/2))
print(float((a-b)/a))
a,b,k = map(int, input().split())

arr = []

whole = list(range(a,b+1))
arr = whole[:k] + whole[len(whole)-k:]
arr = list(set(arr))
arr.sort()
for i in range(len(arr)):
    print(arr[i])


### FIXED CODE ###

a,b,k = (int(i) for i in input().split())
x = set()
y = []
for i in range(a,min(b+1,a+k)):
    x.add(i)
for i in range(b,max(a-1,b-k),-1):
    x.add(i)
for i in x:
    y.append(i)
y.sort()
for ans in y:
    print(ans)
n = int(input())
a = list(map(int,input().split())
s = 0
for i in range (n) :
    if a[i] = s + 1 :
        s += 1
print(n - s)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
brick = 0
for i in range (n) :
    if a[i] == brick + 1 :
        brick += 1
if (brick == 0) :
    print(-1)
else :
    print(n - brick)
def can_reach_to_0(s, comm, pos):
    for t, d in comm:
        if s[pos] == t:
            if d == 'L':
                pos -= 1
            else:
                pos += 1
        if pos < 0:
            return True
    return False

def can_reach_to_N(s, comm, pos):
    N = len(s)
    for t, d in comm:
        if s[pos] == t:
            if d == 'L':
                pos -= 1
            else:
                pos += 1
        if pos >= N:
            return True
    return False

N, Q = list(map(int, input().split()))
s = input()
comm = [input().split() for _ in range(Q)]

l = 0
r = N-1
while l <= r:
    mid = int((l+r)/2)
    if can_reach_to_0(s, comm, mid):
        l = mid + 1
    else:
        r = mid - 1
left = r # いける右端index

l = 0
r = N-1
while l <= r:
    mid = int((l+r)/2)
    if can_reach_to_N(s, comm, mid):
        r = mid - 1
    else:
        l = mid + 1
right = l # いける左端index
print(right-left-1)


### FIXED CODE ###

def can_reach_to_0(s, comm, pos):
    for t, d in comm:
        if s[pos] == t:
            if d == 'L':
                pos -= 1
            else:
                pos += 1
        if pos < 0:
            return True
        if pos >= N:
            return False
    return False

def can_reach_to_N(s, comm, pos):
    N = len(s)
    for t, d in comm:
        if s[pos] == t:
            if d == 'L':
                pos -= 1
            else:
                pos += 1
        if pos >= N:
            return True
        if pos < 0:
            return False
    return False

N, Q = list(map(int, input().split()))
s = input()
comm = [input().split() for _ in range(Q)]

l = 0
r = N-1
while l <= r:
    mid = int((l+r)/2)
    if can_reach_to_0(s, comm, mid):
        l = mid + 1
    else:
        r = mid - 1
left = r # いける右端index

l = 0
r = N-1
while l <= r:
    mid = int((l+r)/2)
    if can_reach_to_N(s, comm, mid):
        r = mid - 1
    else:
        l = mid + 1
right = l # いける左端index
print(right-left-1)
def check(understanding,X):
    for individual in understanding:
        if individual<X:
            return False
    return True

cost=0
inputs1 =list(map(int, input().split()[:3]))
N=inputs1[0]
M=inputs1[1]
X=inputs1[2]

matrix=[]
understanding= []
for i in range(N):
    inputs =list(map(int, input().split()[:M+1]))
    matrix.append(inputs)

for i in range(N):
    cost+=matrix[i][0]
    for j in range(1,M+1):
        understanding[j]+=matrix[i][j]
    if check(understanding,X):
        print(cost)
        break

if not check(understanding,X):
    print(-1)

### FIXED CODE ###

n, m, x = map(int, input().split())

a = []
c = []

for i in range(n):
    a.append(list(map(int, input().split())))
    c.append(a[i][0])
    del a[i][0]

INF = 100000000

ans = INF

for i in range(1 << n):
    cost = 0
    d = [0] * m
    for j in range(n):
        if i >> j & 1:
            cost += c[j]
            for k in range(m):
                d[k] += a[j][k]
    ok = True
    for j in range(m):
        if d[j] < x:
            ok = False
    if ok:
        ans = min(ans, cost)
if ans == INF:
    print(-1)
else:
    print(ans)
n,k, = list(map(int,input().split()))
arr = list(map(int,input().split()))
max_d = k-arr[-1] + arr[0]
for i in range(n):
  max_d = max(max_d,arr[i+1]-arr[i])
print(k-max_d)


### FIXED CODE ###

k,n = list(map(int,input().split()))
arr = list(map(int,input().split()))
max_d = k-arr[-1] + arr[0]
for i in range(n-1):
  max_d = max(max_d,arr[i+1]-arr[i])
print(k-max_d)
import sys.stdin.readlines
for line in sys.stdin.readlines():
  a,b = map(int,line.split())
  print(len(str(a+b)))
  

### FIXED CODE ###

import sys
for line in sys.stdin.readlines():
  a,b = map(int,line.split())
  print(len(str(a+b)))
N = int(input())
act = [list(map(int,input().split())) for _ in range(N)]
dp = [[0]*3 for _ in range(N+1)]

for i in range(1,N+1):
  dp[i+1][0] = max(dp[i][1], dp[i][2]) + act[i][0]
  dp[i+1][1] = max(dp[i][0], dp[i][2]) + act[i][1]
  dp[i+1][2] = max(dp[i][0], dp[i][1]) + act[i][2]
  
print(max(dp[N]))

### FIXED CODE ###

N = int(input())
act = [list(map(int,input().split())) for _ in range(N)]
dp = [[0]*3 for _ in range(N+1)]

for i in range(N):
  dp[i+1][0] = max(dp[i][1], dp[i][2]) + act[i][0]
  dp[i+1][1] = max(dp[i][0], dp[i][2]) + act[i][1]
  dp[i+1][2] = max(dp[i][0], dp[i][1]) + act[i][2]
  
print(max(dp[N]))
import math
 
N, M = list(map(int, input().split()))
a = []

for i in range(M):
  a.append(int(input()))
  
answer = 0
# a = [3]
for i in range(len(a) + 1):
	if i == 0:
		dif = a[i] - 1
	elif i == len(a):
		dif = N - a[-1] - 1
	else:
		dif = a[i] - a[i - 1] - 2
	if dif >= 2:
		b = dif // 2
		tmp_sum = 0
		for j in range(b + 1):
			tmp_sum += math.factorial(j + dif - j * 2) / (math.factorial(j) * math.factorial(dif - j * 2))
			# print(tmp_sum)
		if tmp_sum != 0 and answer == 0:
			answer += 1
		answer *= tmp_sum
    
print(answer)

### FIXED CODE ###

import math
 
N, M = list(map(int, input().split()))
stairs = [0] * (N + 1)

for i in range(M):
	stairs[int(input())] = -1

# all element of stairs
for i in range(N, -1, -1):
	# last is always 1
	if i == N:
		stairs[i] = 1
	# if stair[N - 1] is not broken 
	elif i == N - 1 and stairs[i] != -1:
		stairs[i] = stairs[i + 1]
	# if stairs[i] is not broken
	elif stairs[i] != -1:
		if stairs[i + 1] != -1:
			stairs[i] += stairs[i + 1]
		if stairs[i + 2] != -1:
			stairs[i] += stairs[i + 2]
print(int(stairs[0]) % 1000000007)
N,A,B = map(int, input().split())
  
N -= 1
A -= 1
B -= 1

ans = 0
distAB = B - A

if distAB % 2 == 0:
    ans = distAB / 0
else:
    if (N-B) < A:
        ans = (N-B+1) + ((distAB-1)/2)
    else:
        ans = A+1 + ((distAB-1)/2)

print(int(ans))


### FIXED CODE ###

from decimal import *
N,A,B = map(int, input().split())

N -= 1
A -= 1
B -= 1

ans = 0
distAB = B - A

if distAB % 2 == 0:
    ans = Decimal(distAB) / Decimal(2)
else:
    if (N-B) < A:
        ans = (N-B+1) + (Decimal(distAB-1)/Decimal(2))
    else:
        ans = A+1 + (Decimal(distAB-1)/Decimal(2))

print(int(ans))
# https://atcoder.jp/contests/abc140/tasks/abc140_d

n, k = map(int, input().split())
str_n = input()
changed_str = [str_n]
first = str_n[0]
last = ""
if first == "R":
    last = "L"
else:
    last = "R"

for count in range(k): 
    new_line = changed_str[count]
    next_last = new_line.find(last)
    next_first = new_line.find(first, next_last)
    next_line = new_line[0:next_last]
    if next_first != -1:
        next_line += new_line[next_last:next_first].replace(last, first) + new_line[next_first:]
    else:
        next_line += new_line[next_last:].replace(last, first)
    changed_str.append(next_line)

count = 0
result_line = changed_str[k]
for i in range(len(changed_str[k]) - 1):
    if result_line[i] == result_line[i + 1]:
        count += 1

print(count)

### FIXED CODE ###

# https://atcoder.jp/contests/abc140/tasks/abc140_d

n, k = map(int, input().split())
str_n = input()
first = str_n[0]
last = ""
if first == "R":
    last = "L"
else:
    last = "R"

for count in range(k): 
    new_line = str_n
    next_last = new_line.find(last)
    next_first = new_line.find(first, next_last)
    next_line = new_line[0:next_last]
    if next_first != -1:
        next_line += new_line[next_last:next_first].replace(last, first) + new_line[next_first:]
    else:
        next_line += new_line[next_last:].replace(last, first)
    str_n = next_line

count = 0
result_line = str_n
for i in range(len(str_n) - 1):
    if result_line[i] == result_line[i + 1]:
        count += 1

print(count)
n, q = [int(i) for i in input().split()]

ab = []
for i in range(n-1):
    ab.append([int(i) for i in input().split()])

px = []
for i in range(q):
    px.append([int(i) for i in input().split()])

graph = [[] for _ in range(n+1)]
for a, b in ab:
    graph[a].append(b)
    graph[b].append(a)

counter = [0] * (n+1)

for p, x in px:
    counter[p] += x

def count(node, parent=0):
    for leaf in graph[node]:
        if leaf == parent:
            continue
        counter[leaf] += counter[node]
        count(leaf, node)

count(1)

for counter_i in counter[1:]:
    print(counter_i, end=" ")


### FIXED CODE ###

from collections import deque

n, q = [int(i) for i in input().split()]

tree = [[] for _ in range(n+1)]
for _ in range(n-1):
    a, b = [int(i) for i in input().split()]
    tree[a].append(b)
    tree[b].append(a)

counter = [0] * (n+1)
for _ in range(q):
    p, x = [int(i) for i in input().split()]
    counter[p] += x

queue = deque([[0,1]])
while queue:
    parent, node = queue.popleft()
    for leaf in tree[node]:
        if leaf == parent:
            continue
        counter[leaf] += counter[node]
        queue.append([node, leaf])

print(*counter[1:])
a. b = map(int, input().split())
if a*b % 2 == 0:
    print('YES')
else:
    print('NO')

### FIXED CODE ###

a, b = map(int, input().split())
if a*b % 2 == 0:
    print('No')
else:
    print('Yes')
S=input()
ACGT=['A','C','G','T']
ans=[]
k=0
while k<len(S):
    num=0
    if S[k] in ACGT:
        num=1
        for i in range(1,len(S)-k):
            if S[k+i] in ACGT:
                num+=1
            else:
                break
        ans.append(num)
    else:
        num=1
    k+=num

print(max(ans))

### FIXED CODE ###

S=input()
ACGT=['A','C','G','T']
ans=[0]
k=0
while k<len(S):
    num=0
    if S[k] in ACGT:
        num=1
        for i in range(1,len(S)-k):
            if S[k+i] in ACGT:
                num+=1
            else:
                break
        ans.append(num)
    else:
        num=1
    k+=num

print(max(ans))
# coding:utf-8
import itertools

n, m = map(int,input("").split())

cakes = []
for i in range(n):
    cakes.append(input().split())

maxsum = 0
for kumiawase in itertools.combinations(cakes, m):
    x = y = z = 0
    for cake in kumiawase:
        x += int(cake[0])
        y += int(cake[1])
        z += int(cake[2])
    statussum = abs(x) + abs(y) + abs(z)
    if statussum > maxsum:
        maxsum = statussum
print(maxsum)


### FIXED CODE ###

# coding:utf-8

a, b = map(int,input("").split())

if a >= 1 and a <= 8 and b >= 1 and b <= 8:
    print("Yay!")
else:
    print(":(")
N, Q = map(int, input().split())

graph_lis = [[] for i in range(N)]
for n in range(N - 1):
    a, b = map(int, input().split())
    a, b = min(a, b), max(a, b)
    graph_lis[b - 1].append(a - 1)

ans_list = [0] * N

points = [0] * N
for q in range(Q):
    p, x = map(int, input().split())
    points[p - 1] += x

ans_list[0] = points[0]
for n in range(1, N):
    ans_list[n] = ans_list[graph_lis[n][0]] + points[n]
print(' '.join(map(str, ans_list)))

### FIXED CODE ###

from collections import deque

N, Q = map(int, input().split())
graph_lis = [[] for n in range(N)]

for i in range(N - 1):
    a, b = map(int, input().split())
    graph_lis[a - 1].append(b - 1)
    graph_lis[b - 1].append(a - 1)

ans = [0] * N
for q in range(Q):
    p, x = map(int, input().split())
    ans[p - 1] += x

deq = deque([0])
visited = [False] * N
while deq:
    parent = deq.popleft()
    edge = graph_lis[parent]
    for v in edge:
        if not visited[v]:
            ans[v] += ans[parent]
            deq.append(v)
    visited[parent] = True
print(*ans)
print(1110-int(input))

### FIXED CODE ###

print(1110-int(input()))
n,a,b = map(int, input().split())
x = [int(x) for x in input().split(' ')]

mp = 0
for i in range(n-1):
    mp += min(a*(x[i+1]-x[i]), b)
    
print(mp)

### FIXED CODE ###

a,b,c,d = map(int, input().split())

print(max(a*b,c*d))
from __future__ import print_function


class Solution:
    """
    @param prices: Given an integer array
    @return: Maximum profit
    """

    @staticmethod
    def insertion_sort():
        # write your code here
        array_length = raw_input()
        unsorted_array = list(map(int, raw_input().split()))

        for i in range(1, array_length):
            v = unsorted_array[i]
            j = i - 1
            while j >= 0 and unsorted_array[j] > v:
                unsorted_array[j + 1] = unsorted_array[j]
                j -= 1
            unsorted_array[j + 1] = v
            print(" ".join(str(i) for i in unsorted_array))


if __name__ == '__main__':
    solution = Solution()
    solution.insertion_sort()

### FIXED CODE ###

#!/usr/bin/env python
# encoding: utf-8

from __future__ import print_function


class Solution:
    """
    @param prices: Given an integer array
    @return: Maximum profit
    """

    @staticmethod
    def insertion_sort():
        # write your code here
        array_length = int(input())
        unsorted_array = [int(x) for x in input().split()]

        for i in range(array_length):
            v = unsorted_array[i]
            j = i - 1
            while j >= 0 and unsorted_array[j] > v:
                unsorted_array[j + 1] = unsorted_array[j]
                j -= 1
            unsorted_array[j + 1] = v
            print(" ".join(map(str, unsorted_array)))


if __name__ == '__main__':
    solution = Solution()
    solution.insertion_sort()
x,y,z,k = map(int, input().split())
a= list(map(int, input().split()))
b= list(map(int, input().split()))
c= list(map(int, input().split()))

if x>50:
  a.sort()
  a.reverse()
  a=a[0:50]

if y>50:
  b.sort()
  b.reverse()
  b=b[0:50]

if z>50:
  c.sort()
  c.reverse()
  c=c[0:50]

ansList=[]
for m in range(50):
  for n in range(50):
    for o in range(50):
      ansList.append(a[m]+b[n]+c[o])

ansList.sort()
ansList.reverse()

for i in range(k):
  print(ansList[i])


### FIXED CODE ###

x,y,z,k = map(int, input().split())
a= list(map(int, input().split()))
b= list(map(int, input().split()))
c= list(map(int, input().split()))

a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

ansListab=[]
for i in range(x):
  for j in range(y):
    ansListab.append(a[i]+b[j])

ansListab.sort(reverse= True)

if len(ansListab)>k:
  ansListab=ansListab[0:k]

ansList=[]

for i in c:
  for j in ansListab:
    ansList.append(i+j)

ansList.sort(reverse= True)

for i in range(k):
  print(ansList[i])
s=input()
if s="ooo":
   if s="ooo":
	   print(1000)

### FIXED CODE ###

print(input().count("o")*100+700)
imput numpy as np

n= int(input())
a= [int(i) for i in input().split(' ')]

if abs(max(a)) >= abs(min(a)):
  ma  = max(a)
  ma_i= np.argmax(a)
  mi  = 0
  mi_i= 0
else:
  mi  = min(a)
  mi_i= np.argmin(a)
  ma  = 0
  ma_i= 0

if ma==0:
  for i in range(n):
    if a[i] > 0:
      a[i] = a[i] + mi
      print(mi_i,i)
  for i in reversed(range(1,n)):
    if a[i-1] > a[i]:
      a[i-1] = a[i-1] + a[i]
      print(i-1, i)
else:
  for i in range(n):
    if a[i] < 0:
      a[i] = a[i] + ma
      print(mi_a,i)
  for i in range(1,n):
    if a[i-1] > a[i]:
      a[i] = a[i] + a[i-1]
      print(i-1,i)

### FIXED CODE ###

import numpy as np

n= int(input())
a= [int(i) for i in input().split(' ')]

if abs(max(a)) >= abs(min(a)):
  ma  = max(a)
  ma_i= np.argmax(a)
  mi  = 0
  mi_i= 0
else:
  mi  = min(a)
  mi_i= np.argmin(a)
  ma  = 0
  ma_i= 0

xa=[]
if ma == 0:
  for i in range(n):
    if a[i] > 0:
      a[i] = a[i] + mi
      xa.append([mi_i+1, i+1])
  for i in reversed(range(1,n)):
    if a[i-1] > a[i]:
      a[i-1] = a[i-1] + a[i]
      xa.append([i+1, i-1+1])
else:
  for i in range(n):
    if a[i] < 0:
      a[i] = a[i] + ma
      xa.append([ma_i+1, i+1])
  for i in range(1,n):
    if a[i-1] > a[i]:
      a[i] = a[i] + a[i-1]
      xa.append([i-1+1,i+1])

print(len(xa))
for i in range(len(xa)):
  print(xa[i][0],xa[i][1])
k = int(input())
a, b = map(int, input().split())
for i in range(a, b+1):
  if i % k == 0:
    ans = 0
if ans == 0:
  print("OK")
else:
  print("NG")

### FIXED CODE ###

k = int(input())
a, b = map(int, input().split())
ans = 0
for i in range(a, b+1):
  if i % k == 0:
    ans = 1
if ans == 1:
 	 print("OK")
else:
  	print("NG")
# -*- coding: utf-8 -*-


s = set(input())
if s in {{'N', 'S'}, {'W', 'E'}, {'N', 'W', 'S', 'N'}}:
    print('yes')
else:
    print('No')

    

### FIXED CODE ###

# -*- coding: utf-8 -*-

s=set(input())
if s in [{'W','E'},{'N','S'},{'N','E','W','S'}]:
  print('Yes')
else:
  print('No')
while True:
    n=input()
    if n==0:
        break
    m,goal,d=input(),input(),input()
    step=[""]*d
    for i in xrange(d):
        step[i]="0"+raw_input()+"0"
    raw=range(n+2)
    for i in xrange(d):
        for j in xrange(1,n+1):
            if step[i][j]=="1":
                raw[j],raw[j+1]=raw[j+1],raw[j]
    ans=0
    if not raw[goal]==m:
        e=raw[goal]
        raw=range(n+2)
        for i in xrange(d):
            if not ans==0:
                break
            for j in xrange(1,n+1):
                if (raw[j]==m and raw[j+1]==e) or (raw[j]==e and raw[j+1]==m):
                    if step[i][j-1]=="0" and step[i][j]=="0" and step[i][j+1]=="0":
                        ans=(i+1,j)
                        break
                if step[i][j]=="1":
                    raw[j],raw[j+1]=raw[j+1],raw[j]
        if ans==0:
            ans=1
    print " ".join(map(str,ans))


    


    

### FIXED CODE ###

while True:
    n=input()
    if n==0:
        break
    m,goal,d=input(),input(),input()
    step=[""]*d
    for i in xrange(d):
        step[i]="0"+raw_input()+"0"
    raw=range(n+2)
    for i in xrange(d):
        for j in xrange(1,n+1):
            if step[i][j]=="1":
                raw[j],raw[j+1]=raw[j+1],raw[j]
    ans=0
    if not raw[goal]==m:
        e=raw[goal]
        raw=range(n+2)
        for i in xrange(d):
            if not ans==0:
                break
            for j in xrange(1,n+1):
                if (raw[j]==m and raw[j+1]==e) or (raw[j]==e and raw[j+1]==m):
                    if step[i][j-1]=="0" and step[i][j]=="0" and step[i][j+1]=="0":
                        ans=(i+1,j)
                        break
                if step[i][j]=="1":
                    raw[j],raw[j+1]=raw[j+1],raw[j]
        if ans==0:
            ans=1
    if ans==0 or ans==1:print ans
    else:print " ".join(map(str,ans))
h,w,a,b=map(int,input().split())

tmp=[0]*w
lista=[]
for i in range(h):
    lista.append([0]*w)
    
if a>w/2 or b>h/2:
    print("No")

elif h==1:
    for i in range(w-a):
        lista[0][a+i]=1
elif w==1:
    for i in range(h-b):
                lista[b+i][0]=1
if a==0 & b==0:
    lista=lista
        
else:  
    for i in range(w-a):
        lista[0][a+i]=1
    
    print(lista)
    if a==0:    
        for i in range(w):
            for j in range(b):
                lista[j][i]=1 

    if b!=0:    
        for i in range(a):
            for j in range(h-b):
                lista[b+j][i]=1 
        for i in range(b):
            for i in range(w-a):
                lista[i][a+j]=1




for i in range(h):
    row = ""
    for j in range(w):
        row += str(lista[i][j])
    print(row)

### FIXED CODE ###

h,w,a,b=map(int,input().split())

lista=[]

for i in range(h):
    lista.append([0]*w)

if (a>w/2)|(b>h/2):
    print("No")

else:
    if h==1:
        for i in range(w-a):
            lista[0][a+i]=1
    elif w==1:
        for i in range(h-b):
            lista[b+i][0]=1

    elif (a==0)&(b==0):
        lista=lista

    else:  
        for i in range(w-a):
            lista[0][a+i]=1
        
           
        if a==0:    
            for i in range(w):
                for j in range(b):
                    lista[j][i]=1 
        elif b==0:    
            for i in range(h):
                for j in range(w-a):
                    lista[i][j+a]=1                         
        else:    
            for i in range(a):
                for j in range(h-b):
                    lista[b+j][i]=1 
            for i in range(b):
                for j in range(w-a):
                    lista[i][a+j]=1


 

    for i in range(h):
        row = ""
        for j in range(w):
            row += str(lista[i][j])
        print(row)