Harryxun/stf_run huggingface dataset:
import numpy as np
import sys
import collections
import copy
deque=collections.deque
fastinput=sys.stdin.readline
whites=deque()
firstwhite=deque()
H,W=map(int,input().split())
A=[list(fastinput().rstrip()) for j in range(W)]
rinsetsu=np.zeros((H*W,H*W))
F=np.zeros((1,H*W))

def printsix(l):
    for i in range(5):
        print(l[6*i:6*i+6])

def UDLR(i,j):#各フラグごとに、白なら隣接追加　黒ならfirstwhite追加
    ID=W*i+j
    next2black=0
    rinsetsu[ID][ID]=1
    if i!=0:
        if A[i-1][j]==".":
            rinsetsu[ID][ID-W]=1
        else:F[0][ID]=1
    if i!=H-1:
        if A[i+1][j]==".":
            rinsetsu[ID][ID+W]=1
        else:F[0][ID]=1
    if j!=0:
        if A[i][j-1]==".":
            rinsetsu[ID][ID-1]=1
        else:F[0][ID]=1
    if j!=W-1:
        if A[i][j+1]==".":
            rinsetsu[ID][ID+1]=1
        else:F[0][ID]=1      

for k,i in enumerate(A):
    for l,j in enumerate(i):
        if j==".":
            whites.append(W*k+l)
            UDLR(k,l)
whitess=len(whites)
rinsetsuMatrix=np.matrix(rinsetsu)
ct=1
for i in range(5):
    ct+=1
    F=np.dot(F,rinsetsuMatrix)
    sums=np.array(np.sum(F, axis=0))
    if sum([bool(i) for i in sums[0]])==whitess:
        print(ct)
        break

### FIXED CODE ###

import collections
H,W=map(int,input().split())
went=[[False]*W for i in range(H)]
queue=collections.deque()
for hoge in range(H):
    for huga,t in enumerate(input()):
        if t=="#":
            went[hoge][huga]=True
            queue.append([hoge,huga,0])
while queue:
    curx,cury,ct=queue.popleft()
    for dx,dy in [[1,0],[-1,0],[0,1],[0,-1]]:
        newx,newy=curx+dx,cury+dy
        newct=ct+1
        if 0<=newx<H and 0<=newy<W and (not went[newx][newy]):
            went[newx][newy]=True
            queue.append([newx,newy,newct])
print(ct)
s=input()
ans=False
if s[0]==s[1]:
    if s[0]!=s[2] and a[2]==s[3]:
        ans=True
elif s[0]==s[2]:
    if s[0]!=s[1] and s[1]==s[3]:
        ans=True
elif s[0]==s[3]:
    if s[0]!=s[1] and s[1]==s[2]:
        ans=True
if ans:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

s=input()
ans=False
if s[0]==s[1]:
    if s[0]!=s[2] and s[2]==s[3]:
        ans=True
elif s[0]==s[2]:
    if s[0]!=s[1] and s[1]==s[3]:
        ans=True
elif s[0]==s[3]:
    if s[0]!=s[1] and s[1]==s[2]:
        ans=True
if ans:
    print('Yes')
else:
    print('No')
N = int(input())
ans = [0]*N
n = int((N)**(0.5))+1
for x in range(1, n):
    for y in range(1, n):
        for z in range(1, n):
            i = x**2+y**2+z**2+x*y+x*z+y*z
            if i > N:
                break
            else:
                ans[i] += 1
for a in ans:
    print(a)

### FIXED CODE ###

N = int(input())
ans = [0]*N
if N > 3:
    n = int((N-3)**(0.5))+1
    nums = [i for i in range(1, n)]
    for x in range(1, n):
        for y in range(1, n):
            for z in range(1, n):
                i = x**2+y**2+z**2+x*y+x*z+y*z
                if i > N:
                    break
                else:
                    ans[i-1] += 1
for a in ans:
    print(a)
ink= input().split()
ink=[int(i) for i in ink]
in1=ink[0]
in2=ink[1]
in3=ink[2]

def nibun(a,e,h):
    #a=int(input("何乗？"))
    b=2#何進法でもできるようにする予定だった
    c=[]
    d=0
    while d==0:
        for i in range(999):
            if b**i<=a and a<b**(i+1):
                c.append(1)
                d=i

    a=a-b**d
    for x in range(d-1,-1,-1):
        if b**(x)<=a:
            a=a-(b**x)
            c.append(1)
        else:
            c.append(0)
        d=d-1
    #print(c)

    #e=int(input("何を？"))
    f=1
    g=0
    #h=int(input("mod?"))#mod
    j=1
    for i in range(len(c)-1,-1,-1):
        j=e
        if c[i]==1:
            for x in range(g):
                j=j*j%h
            f=f*j%h
        g=g+1
    return f
f=nibun(in1,2,10**9+7)

def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m

def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m

######################################################
p=10**6

#pは素数とする

#fact[i] : i! modp (0<= i <p) O(p)
fact = [1]
k = 1
for i in range(1,p):
    k = k*i%p
    fact.append(k)


#n! = a p^eとしたときのeを求める (O(logp n)
def mod_e(n,p):
    res = 0
    while n >= p:
        res += n//p
        n = n//p
    return res

#n! = a p^eとしたときのa mod pを求める  (O(logp n)
def mod_fact(n,p):
    if n==0:
        return 1


    res = mod_fact(n//p,p)

    if n//p %2 != 0:
        return res*(p-fact[n%p])%p
    return res*fact[n%p]%p

######################################################

#nCk mod p
def mod_comb(n,k,p):
    if n < 0 or k < 0 or n<k:
        return 0
    e1 = mod_e(n,p)
    e2 = mod_e(k,p)
    e3 = mod_e(n-k,p)
    #pで割り切れる場合
    if e1 > e2 + e3:
        return 0

    #pで割り切れない場合
    a1 = mod_fact(n,p)
    a2 = mod_fact(k,p)
    a3 = mod_fact(n-k,p)
    return a1 * mod_inv(a2*a3%p,p) %p

p =10**9+7

#fact[i] : i! modp (0<= i <p) O(p)
#上だとO(p)なのでnまでにして O(n)にする
fact = [1]
k = 1
for i in range(1,10**5+1):
    k = k*i%p
    fact.append(k)

#10000C4000 mod 10**9+7

j=mod_comb(in1,in2,p)
k=mod_comb(in1,in3,p)
x=(f-1-j-k)
print(x)


### FIXED CODE ###

a = input().split()
a=[int(i) for i in a]
n,r=a[0],a[1]
if n>=10:
    b=r
else:
    b=r+1000-100*n
print(b)
S = input()
    for i in range(len(S) - 1, 0, -1):
        if(S[0:i//2] == S[i//2:i]):
            print(i)
            break


### FIXED CODE ###

S = input()
for i in range(len(S) - 1, 0, -1):
    if(S[0:i//2] == S[i//2:i]):
        print(i)
        break
A,B = map(int,raw_input().split())
ans = long(A)
for i in range(A+1,B+1):
  ans = ans^i
print ans


### FIXED CODE ###

A,B = map(long,raw_input().split())

sum = B-A+1

if sum % 2 == 0:
  if A % 2 == 0:
    if sum/2%2 == 0:
      print "0"
    else:
      print "1"
  else:
    if sum/2%2 == 1:
      print A^B^0
    else:
      print A^B^1
else:
  if A % 2 == 0:
    if sum/2%2 == 0:
      print 0^B
    else:
      print 1^B
  else:
    if sum/2%2 == 1:
      print 1^A
    else:
      print 0^A
import sys
sys.setrecursionlimit(10**6)
N = int(input())
A=list(map(int,input().split()))
A.sort()
Q = int(input())
BC = [map(int, input().split()) for _ in range(Q)]
B, C = [list(i) for i in zip(*BC)]
sum=0
D=[0]*(10**5)
for i in range(N):
    sum+=A[i]
    D[A[i]]+=1
for i in range(Q):
    D[C[i]]+=D[B[i]]
    sum+=D[B[i]]*(C[i]-B[i])
    D[B[i]]=0
    print(sum)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
N = int(input())
A=list(map(int,input().split()))
Q = int(input())
BC = [map(int, input().split()) for _ in range(Q)]
B, C = [list(i) for i in zip(*BC)]
sum=0
D=[0]*(10**5+1)
for i in range(N):
    sum+=A[i]
    D[A[i]]+=1
for i in range(Q):
    D[C[i]]+=D[B[i]]
    sum+=D[B[i]]*(C[i]-B[i])
    D[B[i]]=0
    print(sum)
import math

def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]

n = int(input())
a = list(map(int,input().split()))
maxval = max(a)
p = get_sieve_of_eratosthenes(maxval)
d = [-1]*1000010
m = [-1]*1000010
flag = True


for i in p[::-1]:
  tmp = i
  multi = 2
  while(tmp<=maxval):
    d[tmp] = i
    tmp = tmp*multi
    multi += 1
    
for i in a:
  while(d[i]!=i):
    if(m[d[i]]==1):
      flag = False
      break
    m[d[i]] = 1
    i = i // d[i]
  m[d[i]] = 1
  if(flag == False):
    break
  
if(flag):
  print("pairwise coprime")
else:
  ans = a[0]
  for i in range(1, n):
    ans = math.gcd(ans, a[i])
  if ans==1:
    print("setwise coprime")
  else:
    print("not coprime")

### FIXED CODE ###

import sys, math
input= sys.stdin.readline

N = int(input())
A_lst = list(map(int, input().split()))
lst=[0]*(10**6+1)

# 割れる最大の素数を出す
for i in range(2, 10**6+1):
  if not lst[i]:
    for j in range(i, 10**6+1, i):
      lst[j] = i
      
# not coprimeか判定する
ans = 'not coprime'
GCD = A_lst[0]
for i in range(N):
  GCD = math.gcd(GCD, A_lst[i])
  
if GCD != 1:
  print(ans)
else:
  ans = 'setwise coprime'
  post = 1
  visited = [0]*(10**6+1)
  for i in range(N):
    a = A_lst[i]
    while a > 1:
      dv = lst[a]
      if visited[dv]:
        post = 0
        break
      while a % dv == 0:
        a //= dv
      visited[dv] = 1
  
  if post:
    ans = 'pairwise coprime'
  print(ans)
s=input()
bf='01'*(len(s)//2)
wf='10'*(len(s)//2)
if len(s)%2==1:
  bf+='0'
  wf+='1'
ans=min(len([x!=y if x,y in zip(list(s),list(bf))]),len([x!=y if x,y in zip(list(s),list(wf))]))
print(ans)

### FIXED CODE ###

#!/usr/bin/env python3
S = input()
bf = '01' * (len(S) // 2) + '0' * (len(S) & 1)
wf = '10' * (len(S) // 2) + '1' * (len(S) & 1)
ans = 10**5
ans = min(ans, [x != y for x, y in zip(S, bf)].count(True))
ans = min(ans, [x != y for x, y in zip(S, wf)].count(True))
print(ans)
import math

r = float(input())
area = math.pi * r * r
circumference = 2 * math.pi * r
print(area, circumferene)

### FIXED CODE ###

import math

r = float(input())
area = math.pi * r * r
circumference = 2 * math.pi * r
print(area, circumference)
import numpy as np
import sys
import collections
deque=collections.deque
fastinput=sys.stdin.readline
whites=deque()
firstwhite=deque()
H,W=map(int,input().split())
A=[list(fastinput().rstrip()) for j in range(W)]
rinsetsu=np.zeros((H*W,H*W),dtype="bool")
F=np.zeros((1,H*W),dtype="bool")

def UDLR(i,j):#各フラグごとに、白なら隣接追加　黒ならfirstwhite追加
    ID=W*i+j
    next2black=0
    rinsetsu[ID][ID]=1
    if i!=0:
        if A[i-1][j]==".":
            rinsetsu[ID][ID-W]=1
        else:F[0][ID]=1
    if i!=H-1:
        if A[i+1][j]==".":
            rinsetsu[ID][ID+W]=1
        else:F[0][ID]=1
    if j!=0:
        if A[i][j-1]==".":
            rinsetsu[ID][ID-1]=1
        else:F[0][ID]=1
    if j!=W-1:
        if A[i][j+1]==".":
            rinsetsu[ID][ID+1]=1
        else:F[0][ID]=1      

for k,i in enumerate(A):
    for l,j in enumerate(i):
        if j==".":
            whites.append(W*k+l)
            UDLR(k,l)
whitess=len(whites)
rinsetsuMatrix=np.matrix(rinsetsu)
ct=1
while 1:
    ct+=1
    F=np.dot(F,rinsetsuMatrix)
    sums=np.array(np.sum(F, axis=0))
    if sum([bool(i) for i in sums[0]])==whitess:
        print(ct)
        break

### FIXED CODE ###

import collections
H,W=map(int,input().split())
went=[[False]*W for i in range(H)]
queue=collections.deque()
for hoge in range(H):
    for huga,t in enumerate(input()):
        if t=="#":
            went[hoge][huga]=True
            queue.append([hoge,huga,0])
while queue:
    curx,cury,ct=queue.popleft()
    for dx,dy in [[1,0],[-1,0],[0,1],[0,-1]]:
        newx,newy=curx+dx,cury+dy
        newct=ct+1
        if 0<=newx<H and 0<=newy<W and (not went[newx][newy]):
            went[newx][newy]=True
            queue.append([newx,newy,newct])
print(ct)
A = []
B = []
s = True
while(s):
    try:
        a,b = map(int, input().split())
    except ValueError:
        break
    A.append(a)
    B.append(b)

for i in range(len(A)):
    sum = A[i] + B[i]
    digits = 1
    while(sum//10 != 0):
        digits += 1
        sum //= 10
    print(str(digits))


### FIXED CODE ###


A = []
B = []
s = True
while(s):
    try:
        a,b = map(int, input().split())
    except:
        break
    A.append(a)
    B.append(b)

for i in range(len(A)):
    sum = A[i] + B[i]
    digits = 1
    while(sum//10 != 0):
        digits += 1
        sum //= 10
    print(str(digits))
A = str(input())
B = str(input())
C = str(input())

if A == B and B == C:
    print('YES')
else:
    print('NO')

### FIXED CODE ###

a, b, c = input().split()

if a[len(a)-1] == b[0] and b[len(b)-1] == c[0]:
    print('YES')
else:
    print('NO')
# coding: utf-8
# Your code here!
N,P=map(int,input().split())

i=1
ans=1

if N==1:
    print(P)
else:
    while i**N<=P:
        if P%(i**N)==0:
            ans=i
        i+=1
    print(ans)

### FIXED CODE ###

# coding: utf-8
# Your code here!
# coding: utf-8
# Your code here!
N,P=map(int,input().split())
l=[0]*int(-(-P**0.5//1)+1)

if N==1:
    print(P)
    exit()

for i in range(2,int(-(-P**0.5//1)+1))[::-1]:
    p=P
    count=0
    while p%i==0:
        p/=i
        count+=1
        if count==N:
            print(i)
            exit()
print(1)
S=int(input())

a=S/100
b=S%100

if(a>12 and b>12):
    print("NA")

elif(a==0 and b==0):
    print("NA")

elif((a>12 or a==0) and 1<=b<=12):
        print("YYMM")

elif(1<=a<=12 and (b>12 or b==0)):
        print("MMYY")

elif(1<=a<=12 and 1<=b<=12):
        print('AMBIGUOU')

else:
    print("NA")


### FIXED CODE ###

N,K=(int(i) for i in input().split())
s=input()
S=list(s)

if(S[K-1]=='A'):
    S[K-1]='a'
elif(S[K-1]=='B'):
    S[K-1]='b'
elif(S[K-1]=='C'):
    S[K-1]='c'

A=''.join(S)
print(A)
N, M = map(int, input().split())
C = [set([]) for i in range(N)]


def dfs(n, y):
    seen[n] = True
    y += 1
    for c in C[n]:
        if seen[c]:
            continue
        else:
            y = dfs(c, y)
    return y


for i in range(M):
    a, b = map(int, input().split())
    C[a - 1].add(b - 1)
    C[b - 1].add(a - 1)

ans = 0
seen = [False] * N
for i in range(N):
    if seen[i]:
        continue
    x = 0
    x = dfs(i, x)
    ans = max(ans, x)

print(ans)


### FIXED CODE ###

import sys

sys.setrecursionlimit(1000000)


N, M = map(int, input().split())
C = [set([]) for i in range(N)]


def dfs(n, y):
    seen[n] = True
    y += 1
    for c in C[n]:
        if seen[c]:
            continue
        else:
            y = dfs(c, y)
    return y


for i in range(M):
    a, b = map(int, input().split())
    C[a - 1].add(b - 1)
    C[b - 1].add(a - 1)

ans = 0
seen = [False] * N
for i in range(N):
    if seen[i]:
        continue
    x = 0
    x = dfs(i, x)
    ans = max(ans, x)

print(ans)
def main():
    height, width, target_count = [int(x) for x in input().split()]
    count_by_height = [0] * height
    count_by_width = [0] * width
    bomb_is = [[False] * width for _ in range(height)]
    for _ in range(target_count):
        bom_h, bom_w = [int(x) - 1 for x in input().split()]
        count_by_height[bom_h] += 1
        count_by_width[bom_w] += 1
        bomb_is[bom_h][bom_w] = True
    max_h, max_w = max(count_by_height), max(count_by_width)
    max_h_is = [i for i, x in enumerate(count_by_height) if x == max_h]
    max_w_is = [i for i, x in enumerate(count_by_width) if x == max_w]
    no_cross = any(not bomb_is[hh][ww] for hh in max_h_is for ww in max_w_is)
    return max_h + max_w - (not no_cross)


if __name__ == '__main__':
    ans = main()
    print(ans)


### FIXED CODE ###

from collections import defaultdict


def main():
    height, width, target_count = [int(x) for x in input().split()]
    count_by_height = defaultdict(int)
    count_by_width = defaultdict(int)
    bomb_is = set()
    for _ in range(target_count):
        bom_h, bom_w = [int(x) - 1 for x in input().split()]
        count_by_height[bom_h] += 1
        count_by_width[bom_w] += 1
        bomb_is.add((bom_h, bom_w))
    max_h = max(v for v in count_by_height.values())
    max_w = max(v for v in count_by_width.values())
    max_h_index = [i for i, x in count_by_height.items() if x == max_h]
    max_w_index = [i for i, x in count_by_width.items() if x == max_w]
    no_cross = any(
        (hh, ww) not in bomb_is for hh in max_h_index for ww in max_w_index)
    return max_h + max_w - (not no_cross)


if __name__ == '__main__':
    ans = main()
    print(ans)
_in = input()

result = _in.isupper()

if result ? :
  print('A')
else:
  print('a')
  

### FIXED CODE ###

_in = input()

result = _in.isupper()

if result:
  print('A')
else:
  print('a')
import numpy as np
 
H, W = map(int, input().split())
S = np.array([list(input()) for _ in range(H)])

for i in range(H):
  for j in range(W):
    if S[i, j] == '#':
      if np.sum(np.concatenate(S[i-1:i, j], S[i, j-1:j], S[i+1:i, j], S[i, j+1:j]) == '#') == 0:
        print('No')
        break
else:
  print('Yes')

### FIXED CODE ###

import numpy as np
import itertools
 
H, W = map(int, input().split())
S = np.array([list(input()) for _ in range(H)])

def f(H, W, S):
  for i, j in itertools.product(range(H), range(W)):
    if S[i, j] == '#':
      if np.sum(np.concatenate([S[i-1:i, j], S[i, j-1:j], S[i+1:i+2, j], S[i, j+1:j+2]]) == '#') == 0:
        return False
  return True

if f(H, W, S):
  print('Yes')
else:
  print('No')
# -*- coding: utf-8 -*-

def sum_digits(val):
    work = 0
    while True:
        work += val % 10
        val //= 10
        if val == 0:
            break
    return work
   
n = int(input())

values = []
for a in range(2, n + 1):
    b = n - a
    if b < 2:
        continue
    # print("{}, {} / {}, {}".format(a, sum_digits(a), b, sum_digits(b)))
    values.append(sum_digits(a) + sum_digits(b))

values.sort()
# print(values)
print(values[0])

### FIXED CODE ###

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

def sum_digits(val):
    work = 0
    while True:
        work += val % 10
        val //= 10
        if val == 0:
            break
    return work
   
n = int(input())

values = []
for a in range(1, n + 1):
    b = n - a
    if b < 1:
        continue
    # print("{}, {} / {}, {}".format(a, sum_digits(a), b, sum_digits(b)))
    values.append(sum_digits(a) + sum_digits(b))

values.sort()
# print(values)
print("0" if len(values) == 0 else values[0])
from math import gcd

N=int(input())
A=list(map(int, input().split()))

c=max(A)
D=[0]*(c+1)
div=[0]*(c+1)
P=[]

for i in range(2,c+1):
    if D[i]==0:
        P.append(i)
        D[i]=i
    for j in P:
        if i*j>c and i>D[j]:
           break
        D[i*j]=j

for i in A:
    c=gcd(c,i)
    if i==1:
        continue
    temp=i
    if temp==D[temp]:
        div[temp]+=1
        continue
    while temp!=D[temp]:
        div[D[temp]]+=1
        temp=temp//D[temp]

if max(div)<=1:
    print('pairwise coprime')

elif c==1:
    print('setwise coprime')

else:
    print('not coprime')

### FIXED CODE ###

from functools import reduce
from math import gcd

N=int(input())
A=list(map(int, input().split()))

c=max(A)+1
D=[0]*c
div=[0]*c
P=[]

for i in range(2,c):
    if D[i]==0:
        P.append(i)
        D[i]=i
    for j in P:
        if i*j>=c  or j>D[i] :
           break
        D[i*j]=j
f=0
for i in A:
    if i==1:
        continue
    temp=i
    while temp!=1:
        if div[D[temp]]==1:
            f=1
            break
        div[D[temp]]+=1
        temp2=D[temp]
        while temp%temp2==0 and temp>=temp2:
            temp=temp//temp2
    if f==1:
        break
        


if max(div)<=1 and f==0:
    print('pairwise coprime')

elif reduce(gcd, A) == 1:
    print('setwise coprime')

else:
    print('not coprime')
n,k = (int(x) for x in input().split())
town = [int(i) for i in input().split()]
warp  = [1]
checklist = [0]+[-1]*n
i = 0
j = 0
while j<=n:
    #print(town[i])
    warp.append(town[i])
    #print(warp,checklist)
    if checklist[town[i]-1]!=-1:
        s = checklist[town[i]-1]
        warp = warp[s:j]
        #print(checklist[town[i]-1],j)
        #print("a",warp)
        break
    checklist[town[i]-1] = j
    i = town[i]-1
    j += 1


m = len(warp)
print(warp[(k-s)%m])

### FIXED CODE ###

n,k = (int(x) for x in input().split())
town = [int(i) for i in input().split()]
warp  = [1]
checklist = [0]+[-1]*n
i = 0
j = 1
s = 0
while j<=n:
    warp.append(town[i])
    if checklist[town[i]-1]!=-1:
        s = checklist[town[i]-1]
        loop = warp[s:j]
        break
    checklist[town[i]-1] = j
    i = town[i]-1
    j += 1
if k>=s:
    m = len(loop)
    print(loop[(k-s)%m])
else:
    print(warp[k])
import numpy as np
h, w = map(int, input().split())
m = np.array([list(map(int, input().split())) for i in range(h)])

n = list()
r = True
act = list()
for i in range(h):
  r = not r
  for j in sorted(range(w), reverse=r):      
    if not r:
      # 下に進む
      if j == w-1:
        if i == w:
          break
        next_i = i + 1
        next_j = j
      # 右に進む
      else:
        next_i = i
        next_j = j + 1
    else:
      # 下に進む
      if j == 0:
        if i == w:
          break
        next_i = i
        next_j = j + 1
      # 左に進む
      else:
        next_i = i
        next_j = j - 1
    #print(m[i, j], i, j, r, m[next_i, next_j])
    
    if m[i, j] % 2 == 1:
      m[i, j] -= 1
      m[next_i, next_j] += 1
      act.append((i, j, next_i, next_j))

print(len(act))
[print(*x) for x in act]  
#print(m)


### FIXED CODE ###

import numpy as np
h, w = map(int, input().split())
m = np.array([list(map(int, input().split())) for i in range(h)])

r = True
act = list()
for i in range(1, h+1):
  r = not r
  for j in sorted(range(1, w+1), reverse=r):
    if m[i-1, j-1] % 2 == 1:
      if not r:
        # 下に進む
        if j == w:
          if i == h:
            break
          m[i, j-1] += 1
          act.append((i, j, i+1, j))
        # 右に進む
        else:
          m[i-1, j] += 1
          act.append((i, j, i, j+1))
      else:
        # 下に進む
        if j == 1:
          if i == h:
            break
          m[i, j-1] += 1
          act.append((i, j, i+1, j))
        # 左に進む
        else:
          m[i-1, j-2] += 1
          act.append((i, j, i, j-1))
    #print(m[i, j], i, j, r, m[next_i, next_j])
    
print(len(act))
[print(*x) for x in act]  
#print(m)
from math import floor

A, B, N = list(map(int, input().split()))
# print(A, B, N)

x = None
if N < B:
    x = N

answer = floor(A * x / B) - A * floor(x / B)

print(answer)


### FIXED CODE ###

from math import floor

A, B, N = list(map(int, input().split()))
# print(A, B, N)

x = None
if N < B:
    x = N
else:
    x = B
    x = B - 1
    # max_diff = 0
    # for _x in range(B, N + 1):
    #     diff = (x / B) - floor(x / B)
    #     if max_diff <= diff:
    #         max_diff = diff
    #         x = _x

answer = floor(A * x / B) - A * floor(x / B)

print(answer)
def solve():
    d = 0
    c = 0
    for i in range(D):
        d += p[i][0]
    dp = [[0]*(d+1) for i in range(D)]
    for i in range(D):
        for j in range(p[i][0]+1):
            if i == 0:
                if j == p[i][0]:
                    dp[i][j] += p[i][1]
                dp[i][j] += 100*j
            else:
                for k in range(c+1):
                    if j == p[i][0]:
                        dp[i][k+j]=max(dp[i][k+j],dp[i-1][k]+100*j*(i+1)+p[i][1])
                    else:
                        dp[i][k+j]=max(dp[i][k+j],dp[i-1][k]+100*j*(i+1))
        c += p[i][0]
    for i in range(d+1):
        if dp[D-1][i]>=G:
            print(i)
            break    
    
if __name__=="__main__":
    D,G = list(map(int, input().split()))
    pc = [list(map(int, input().split())) for _ in range(D)]
    solve()


### FIXED CODE ###


def solve():
    d = 0
    c = 0
    for i in range(D):
        d += p[i][0]
    dp = [[0]*(d+1) for i in range(D)]
    for i in range(D):
        for j in range(p[i][0]+1):
            if i == 0:
                if j == p[i][0]:
                    dp[i][j] += p[i][1]
                dp[i][j] += 100*j
            else:
                for k in range(c+1):
                    if j == p[i][0]:
                        dp[i][k+j]=max(dp[i][k+j],dp[i-1][k]+100*j*(i+1)+p[i][1])
                    else:
                        dp[i][k+j]=max(dp[i][k+j],dp[i-1][k]+100*j*(i+1))
        c += p[i][0]
    for i in range(d+1):
        if dp[D-1][i]>=G:
            print(i)
            break    
    
if __name__=="__main__":
    D,G = list(map(int, input().split()))
    p = [list(map(int, input().split())) for _ in range(D)]
    solve()