Harryxun/stf_run huggingface dataset:
N = [int(i) for i in str(input())]
m = len(N)
K = int(input())
dp = [[[0 for i in range(m + 1)],[0 for i in range(m + 1)]]   for i in range(m)]
#初期条件
dp[0][1][0] = 1
dp[0][0][1] = 1
dp[0][1][1] = N[0] - 1
for i in range(1,m):
    for t in range(0,i+2):
        if N[i] != 0:
            if t == 0:
                dp[i][1][t] = dp[i-1][1][t]
            else:
                dp[i][0][t] = dp[i-1][0][t-1]
                dp[i][1][t] = dp[i-1][0][t] + dp[i-1][0][t-1] * (N[i]-1) + dp[i-1][1][t] + dp[i-1][1][t-1] * 9
        else :
            if t == 0:
                dp[i][0][t] = dp[i-1][0][t]
                dp[i][1][t] = dp[i-1][1][t] * 1
            else :
                dp[i][0][t] = dp[i-1][0][t] + dp[i-1][1][t] + dp[i-1][1][t-1] * 9
print(dp[-1][0][K]+dp[-1][1][K])


### FIXED CODE ###

N = [int(i) for i in str(input())]
m = len(N)
K = int(input())
dp = [[[0 for i in range(K + 1)],[0 for i in range(K + 1)]]   for i in range(m)]
#初期条件
dp[0][1][0] = 1
dp[0][0][1] = 1
dp[0][1][1] = N[0] - 1
for i in range(1,m):
    for t in range(0,min(i+2,K+1)):
        if N[i] != 0:
            if t == 0:
                dp[i][1][t] = dp[i-1][1][t]
            else:
                dp[i][0][t] = dp[i-1][0][t-1]
                dp[i][1][t] = dp[i-1][0][t] + dp[i-1][0][t-1] * (N[i]-1) + dp[i-1][1][t] + dp[i-1][1][t-1] * 9
        else :
            if t == 0:
                dp[i][0][t] = dp[i-1][0][t]
                dp[i][1][t] = dp[i-1][1][t] 
            else :
                dp[i][0][t] = dp[i-1][0][t]
                dp[i][1][t] = dp[i-1][1][t] + dp[i-1][1][t-1] * 9
print(dp[-1][0][K]+dp[-1][1][K])
N = int(input())
A = list(map(int, input().split()))

from itertools import accumulate


ans = float("inf")
if N == 4:
    ans = min(ans, (max(A) - min(A)))
else:
    cs = accumulate(A)
    for i in range(2, N - 2):
        left_cs = cs[:i]
        right_cs = cs[i:]
        for l, v in enumerate(left_cs):
            if v + left_cs[l + 1] >= left_cs[-1]:
                P = left_cs[l]
                Q = left_cs[-1] - P
                break
        for r, v in enumerate(right_cs):
            if v + right_cs[r + 1] >= right_cs[-1]:
                R = right_cs[r]
                S = right_cs[-1] - R
                break
        ans = min(ans, (max(P, Q, R, S) - min(P, Q, R, S)))

print(ans)

### FIXED CODE ###

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

from itertools import accumulate


ans = float("inf")
if N == 4:
    ans = min(ans, (max(A) - min(A)))
else:
    cs = list(accumulate(A))
    l = 0
    r = 0
    for i in range(1, N - 2):
        while cs[i] > cs[l] + cs[l+1]:
            l += 1
        while cs[-1] + cs[i] > cs[r] + cs[r+1]:
            r += 1
        P = cs[l]
        Q = cs[i] - P
        R = cs[r] - P - Q
        S = cs[-1] - cs[r]
        ans = min(ans, (max(P, Q, R, S) - min(P, Q, R, S)))

print(ans)
from collections import OrderedDict
import math


def submit():
    a, b = map(int, input().split())
    s = min(a, b)
    l = max(a, b)

    if s == 1:
        print(1)
        return

    # 公約数を求める
    divisors = OrderedDict()
    for x in range(2, math.ceil(math.sqrt(s)) + 1):
        if s % x == 0 and l % x == 0:
            divisors[x] = True
    if l % s == 0:
        divisors[s] = True

    # ふるいにかけて素数のみ数える
    ans = 0
    lst = next(reversed(divisors))
    for d, v in divisors.items():
        if v:
            ans += 1
            c = 2*d
            while c <= lst:
                if c in divisors.keys():
                    divisors[c] = False
                c += d
    print(ans + 1)

        
if __name__ == "__main__":
    submit()    


### FIXED CODE ###


import math


def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x % y)


def prime_fact(x):
    prime_pow = {}
    check_ceil = math.ceil(math.sqrt(x))
    for p in range(2, check_ceil + 1):
        p_cnt = 0
        while x % p == 0:
            x //= p
            p_cnt += 1
        if p_cnt:
            prime_pow[p] = p_cnt
    if x > 1:
        prime_pow[x] = 1
    return prime_pow


def submit():
    a, b = map(int, input().split())
    g = gcd(a, b)
    # gcdの素因数分解して素因数の数を求める
    p = prime_fact(g)
    print(len(p) + 1)


if __name__ == "__main__":
    submit()
S,W = map(int, input().split())
if S > W:
  print(safe)
 else :
  print(unsafe)

### FIXED CODE ###

S,W = map(int, input().split())
if S > W:
  print('safe')
else :
  print('unsafe')
import math


def main():
    a, b, c, d = map(int, input().split())
    l =  (c * d) // math.gcd(c, d)
    cntb = b - (b // c + b // d - b // l)
    cnta = (a-1) - ((a-1) // c + (a-1) // d - (a-1) // l)
    ans = cntb - cnta

    print(ans)

if __name__ == '__main__':
    main()

### FIXED CODE ###

import fractions

def main():
    a, b, c, d = map(int, input().split())
    l =  (c * d) // fractions.gcd(c, d)
    cntb = b - (b // c + b // d - b // l)
    cnta = (a-1) - ((a-1) // c + (a-1) // d - (a-1) // l)
    ans = cntb - cnta

    print(ans)

if __name__ == '__main__':
    main()
N, Q = map(int,input().split())
tree = [[0] for i in range(N+1)]
for i in range(N-1):
    a,b = map(int,input().split())
    if tree[a] == [0]:
        tree[a] = [b]
    else:
        tree[a].append(b)
counter = [0 for i in range(N+1)]
def dfs(p,x):
    counter[p] += x
    for i in tree[p]:
        if i != 0:
            dfs(i,x)
               
    
for i in range(Q):
    p,x = map(int,input().split())
    dfs(p,x)
counter = [str(i) for i in counter]
ans = ' '.join(counter[1:])
print(ans)

### FIXED CODE ###

import sys
def input():
    return sys.stdin.readline()[:-1]
 
n,q = map(int, input().split())
#長さn個のリストを入れ子にしたリストの作成：adj
adj = [[] for i in range(n)]
 
#adjに繋がっている要素を上流下流関わらず全て加える。
for j in range(n-1):
    a,b=map(int, input().split())
    adj[a-1].append(b-1)
    adj[b-1].append(a-1) 
 
#加算する値を合計したリストの作成
queries = [0 for i in range(n)]
for j in range(q):
    p, x = map(int, input().split())
    queries[p-1] += x
 
ans = [0 for i in range(n)]
 
#aの値，直前の値，直前のaの値
st = [(0, 0, -1)] 
 
#つながってる奴の一番後ろから処理していく。
#０スタート→1,2繋がってるなら2にいく。2に3が繋がってるなら次は3。
#3に繋がってるのがなければ1に戻る。
#この際，aの直前の値をタプルで保持したままリストに挿入して保管しておく。
while st:
    #stの先頭を取り出す。初期値は末尾のため-1
    l = st.pop()  
    ans[l[0]] = l[1] + queries[l[0]]
    for v in adj[l[0]]:
        if v != l[2]:
            st.append((v, ans[l[0]], l[0]))
 
print(*ans)
input_num = input()
input_num = int(input_num)
ans_flag = False;
for i in range(1,100,1):
  for j in range(1,100,1):
    if input_num == i * J:
      print("Yes")
      ans_flag = True
      break;
if not ans_flag:
	print("No")

### FIXED CODE ###

input_num = input()
input_num = int(input_num)
for i in range(1,10,1):
  flag = False
  for j in range(1,10,1):
    if input_num == i * j:
      print("Yes")
      flag = True
      break
  if flag:
    break
if not flag:
	print("No")
S=input()
let=['a','b','c']
k=S.count('a')
l=S.count('b')
m=S.count('c')

if abs(k-l)<=1 and abs(l-m)<=1 and abs(m-k)<=1:
    print('YES')
else:
    pritn('NO')

### FIXED CODE ###

S=input()
k=S.count('a')
l=S.count('b')
m=S.count('c')

if abs(k-l)<=1 and abs(l-m)<=1 and abs(m-k)<=1:
    print('YES')
else:
    print('NO')
a, b, c = map(int, input().split())
if a+b=c or a+c=b or b+c=a:
  print('Yes')
else:
  print('No

### FIXED CODE ###

a, b, c = map(int, input().split())
if a+b==c or a+c==b or b+c==a:
  print('Yes')
else:
  print('No')
R =int(input())
print("2 * 3.1415926535 * R)


### FIXED CODE ###

r = float(input())
print(2 * r * 3.14159265)
n=int(input())
a,b=[None]*100000,[None]*100000
for i in range(100000):
    a[i]=[None]*2
    a[i][0]=0
    a[i][1]=i
    b[i]=[None]*2
    b[i][0]=0
    b[i][1]=i
l=list(map(int,input().split()))
for i in range(n//2):
    a[l[2*i]-1][0]+=1
    b[l[2*i+1]-1][0]+=1
a.sort(reverse=True)
b.sort(reverse=True)
if a[0][1]==b[0][1]:
    print(n-max(a[0][0]+b[1][0],a[1][0]+b[0][0]))
else:
    print(n-a[0][0]-b[0][0])

### FIXED CODE ###

n=input()
l=""
for i in range(3):
    if n[i]=="1":
        l+="9"
    elif n[i]=="9":
        l+="1"
    else:
        l+=n[i]
print(l)
import bisect
n = int(input())
 
l = list(map(int, input().split()))
l.sort()
a = 0
 
for i in range(n-2):
    for j in range(i+1,n-1):
        s = bisect.bisect_left(l[i]+l[j])
        a =a + n - s+1


print(a)

### FIXED CODE ###

import bisect
n = int(input())
 
l = list(map(int, input().split()))
l.sort()
a = 0
#print(l)
for i in range(n-2):
    for j in range(i+1,n-1):
        s = bisect.bisect_left(l,l[i]+l[j])-j-1
        a+=s


print(a)
def age_check(age):
  if age ==3:
    print('YES')
  else age == 5:
    print('YES')
  else age == 7:
    print('YES')
  else:
    print('NO')

age = input()

age_check(age) 


### FIXED CODE ###

def age_check(age):
  if age == 3 or age == 5 or age == 7:
    print('YES')
  else:
    print('NO')
 
age = int(input())
 
age_check(age)
n,m=map(int, input().split(" "))
l=[]
for i in range(m):
  l.append(list(map(int,input().split(" "))))


d=[n+1 for i in range(n)]
d[0]=0

an,m=map(int, input().split(" "))
l=[]
for i in range(m):
  l.append(list(map(int,input().split(" "))))


d=[n+3 for i in range(n)]
d[0]=0

for i in range(n):
    for j in l:
        if j[0]-1==i:
            d[j[1]-1]=min(d[j[1]-1], d[i]+1)
            l.remove(j)
        elif j[1]-1==i:
            d[j[0]-1]=min(d[j[0]-1],d[i]+1)
            l.remove(j)
            
            
j="Yes"
for i in range(n):
    if d[i]==n+3:
        j="No"
print(j)
for i in range(1,n):
    print(d[i])

### FIXED CODE ###

#

import sys
from collections import deque
input=sys.stdin.readline

def main():
    N,M=map(int,input().split())
    adj=[[] for i in range(N)]
    for i in range(M):
        A,B=map(int,input().split())
        adj[A-1]+=[B-1]
        adj[B-1]+=[A-1]
    parent=[-1]*N
    qu=deque([0])
    qup=qu.popleft
    qua=qu.append
    parent[0]=0
    while(len(qu)>0):
        v=qup()
        for nv in adj[v]:
            if parent[nv]!=-1:
                continue
            else:
                parent[nv]=v
                qua(nv)
    print("Yes")
    for i in range(1,N):
        print(parent[i]+1)
        
    
    
if __name__=="__main__":
    main()
X,A=map(int,input().split())
print(10*(A=<X))


### FIXED CODE ###

X,A=map(int,input().split())
print(10*(A<=X))
N,M = map(int,input().split())
A_s = list(map(int,input().split()))
A_s = sorted(A_s)
for _ in M:
  B,C = map(int,input().split())
  limit = -1
  for i in range(B):
    if A_s[i] > C:
      break
    else:
      limit = i+1
  A_s[:limit] = [C] * limit
  A_s = sorted(A_s)
print(A_s)

### FIXED CODE ###

N,M = map(int,input().split())
A_s = list(map(int,input().split()))
BC_s = []
for _ in range(M):
  tempB,tempC = map(int,input().split())
  BC_s.append([tempB,tempC])
BC_s = reversed(sorted(BC_s, key=lambda x:x[1]))
D = []
A_s = sorted(A_s)

A_s_size = N
for BC in BC_s:
    B = BC[0]
    C = BC[1]
    if A_s_size == 0:
        break
    elif A_s_size < B:
        D.extend([C]*A_s_size)
        A_s_size -= A_s_size
    else:
        D.extend([C]*B)
        A_s_size -= B
minLength = min(N,len(D))
for i in range(minLength):
    if A_s[i] < D[i]:
        A_s[i] = D[i]
    else:
        break
print(sum(A_s[-N:]))
import math
n=int(input)
l=[int(input) for _ in range(5)]
print(math.ceil(n/min(l)+4))


### FIXED CODE ###


import math
n=int(input())
l=[int(input()) for _ in range(5)]
print(math.ceil(n/min(l)+4))
import math
ni = int(input())
xi = map(int, raw_input().split(
yi = map(int, raw_input().split(

p1 = []
p2 = []
p3 = []
p4 = []
for x, y in zip(xi, yi):
    p1.append(abs(x - y))
    p2.append(abs(x - y)**2)
    p3.append(abs(x - y)**3)
    p4.append(abs(x - y))

print '%.8f' % reduce(lambda x, 
print '%.8f' % reduce(lambda x, 
print '%.8f' % reduce(lambda x, 
print '%.8f' % max(p4)

### FIXED CODE ###

import math
ni = int(input())
xi = map(int, raw_input().split())
yi = map(int, raw_input().split())

p1 = []
p2 = []
p3 = []
p4 = []
for x, y in zip(xi, yi):
    p1.append(abs(x - y))
    p2.append(abs(x - y)**2)
    p3.append(abs(x - y)**3)
    p4.append(abs(x - y))

print '%.8f' % reduce(lambda x, y: x + y, p1)
print '%.8f' % reduce(lambda x, y: x + y, p2) ** (1.0/2.0)
print '%.8f' % reduce(lambda x, y: x + y, p3) ** (1.0/3.0)
print '%.8f' % max(p4)
n,k = map(int,input().split())
L = list(map(int,input().split()))
X = [0]*(n+1)
X[0] = 1
for i in range(n):
  if L[X[i]-1] in X:
    X[i+1] = L[X[i]-1]  
    break
  X[i+1] = L[X[i]-1]
    
def f(lst,value):
  return [i for i,x in enumerate(lst) if x == value]
for x in X:
  if X.count(x) == 2:
    a = f(X,x)
    X_ans = X[a[0]:a[1]]
    break

if k <= a[0]:
  print(X[k])
else:
  b = (k - a[0] + 1) % (a[1]-a[0])
  print(X_ans[b-1])



### FIXED CODE ###

S = input()
T = input()
if len(T) == len(S) + 1 and T[:len(S)] == S:
  print('Yes')
else:
  print('No')
#入力
HPlist = list(map(int, input().split()))
HPlist[0] = A
HPlist[1] = B
HPlist[2] = C
HPlist[3] = D


#高橋の攻撃何発分か
if C % B == 0:
    aokiDeath = C // B
else:
    aokiDeath = C // B + 1 

#青木の攻撃何回分か
if A % D == 0:
    takahashiDeath = A // D
else:
    takahashiDeath = A // D + 1

if aokiDeath <= takahashiDeath:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

#入力
A, B, C, D = map(int, input().split())


#高橋の攻撃何発分か
if C % B == 0:
    aokiDeath = C // B
else:
    aokiDeath = C // B + 1 

#青木の攻撃何回分か
if A % D == 0:
    takahashiDeath = A // D
else:
    takahashiDeath = A // D + 1

if aokiDeath <= takahashiDeath:
    print("Yes")
else:
    print("No")
n = int(input())
t,a = map(int,input().split())
temp = list(map(int,input().split()))
tmp = 10**9
index= 1

for i in temp:
  if abs(a- (t - tmp)) > abs(a- (t - i * 0.006)):
    tmp = t - i * 0.006
    index = temp.index(i)+1


print(index)

### FIXED CODE ###

x,y = map(int,input().split())
print(x+int(y/2))
import numpy as np

N, K = map(int, input().split())
A = [int(a) for a in input().split()]

K_str = format(K, 'b')
max_order = len(K_str)

B = np.array([list(format(a, '0{}b'.format(max_order)))
              for a in A]
             ).astype('i')[:, :max_order]
B = B.sum(axis=0)
B = np.where(B < N/2, 1, 0)

X_str = ''.join(map(str, B))

for i in range(max_order):
    if K_str[i] < X_str[i]:
        X_str[i] = 0

X = int(X_str, 2)

print(sum(map(lambda a: X ^ a, A)))

### FIXED CODE ###

import numpy as np

N, K = [int(a) for a in input().split()]
A = [int(a) for a in input().split()]

K = format(K, 'b')
B = [format(a, 'b') for a in A]
max_order = len(max(B + [K], key=len))

K = K.zfill(max_order)
B = np.array([list(b.zfill(max_order)) for b in B], dtype='i')
B = B.sum(axis=0)
B = np.where(B < N/2, '1', '0')

for i, k, b in zip(range(max_order), K, B):
    if k < b:
        B[i] = '0'
    elif k > b:
        break

X = int(''.join(map(str, B)), 2)

print(sum(map(lambda a: X ^ a, A)))
N,M = input().split()
s,c,a = [],[],[]
number = []
for i in range(int(M)):
    a_i = input().split()
    a.append(a_i)
    s.append(int(a_i[0]))
    c.append(int(a_i[1]))
ans = True
for i in range(int(N)):
    number.append('')
for i in range(int(M)):
    if s[i]==1 and c[i]==0 and int(N)>1:
        if ans:
            print('-1')
            ans = False
    elif s[i] > N:
        if ans:
            print('-1')
            ans = False
    elif number[s[i]-1] == '' or number[s[i]-1] == c[i]:
        number[s[i]-1] = c[i]
    else:
        if ans:
            print('-1')
            ans = False
for i,elem in enumerate(number):
    if number[i] == '' and i == 0:
        number[i] = 1
    elif elem == '':
        number[i] = 0
if ans:
    strs = '' 
    for i in number:
        strs += str(i)
    print(int(strs))


### FIXED CODE ###

N,M = input().split()
s,c,a = [],[],[]
number = []
for i in range(int(M)):
    a_i = input().split()
    a.append(a_i)
    s.append(int(a_i[0]))
    c.append(int(a_i[1]))
ans = True
for i in range(int(N)):
    number.append('')
for i in range(int(M)):
    if s[i]==1 and c[i]==0 and int(N)>1:
        if ans:
            print('-1')
            ans = False
    elif s[i] > int(N):
        if ans:
            print('-1')
            ans = False
    elif number[s[i]-1] == '' or number[s[i]-1] == c[i]:
        number[s[i]-1] = c[i]
    else:
        if ans:
            print('-1')
            ans = False
for i,elem in enumerate(number):
    if number[i] == '' and i == 0 and int(N) >1:
        number[i] = 1
    elif elem == '':
        number[i] = 0
if ans:
    strs = '' 
    for i in number:
        strs += str(i)
    print(int(strs))
n = input()
p = list(map(int,input().split()))
a = 0
for i in range(1,n):
  if p[i-1] < p[i] < p[i+1] or p[i+1] < p[i] < p[i-1]:
    a += 1
print(a)

### FIXED CODE ###

n = int(input())
p = list(map(int,input().split()))
a = 0
for i in range(1,n-1):
  if p[i-1] < p[i] < p[i+1] or p[i+1] < p[i] < p[i-1]:
    a += 1
print(a)
n,m=map(int,input().split())
ans=(n*(n-1))//2
l=[-1]*n
a=[1]*n
b=[input().split() for _ in range(m)]
c=[0]*m+[ans]
def r(s):
  t=l[s]
  return s if t<0 else r(t)
def f(s):
  return r(int(s)-1)
for i in range(m-1,-1,-1):
  x,y=map(f,b[i])
  if x!=y:
    l[x]=y
    ans-=a[x]*a[y]
    a[y]+=a[x]
  c[i]=ans
for x in c[1:]:
  print(x)

### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readline
n,m=map(int,input().split())
z=n*(n-1)//2
l=[-1]*n
a=[1]*n
b=[input().split() for _ in range(m)]
c=[0]*m+[z]
def r(s):
  t=l[s]
  if t<0:
    return s
  else:
    l[s]=r(t)
    return l[s]
def f(s):
  return r(int(s)-1)
for i in range(m-1,-1,-1):
  x,y=map(f,b[i])
  if x!=y:
    l[x]=y
    z-=a[x]*a[y]
    a[y]+=a[x]
  c[i]=z
for x in c[1:]:
  print(x)
import numpy as np
N = int(input())
divisors = np.array([0] * N, dtype = 'int64')
ans = 0
for i in range(N):
    num = i+1
    divisors[i:N:num] += 1
    ans += num * divisors[i]
print(ans)

### FIXED CODE ###

N = int(input())
ans = 0
for i in range(1, N+1):
    ans += i * (N // i) * (N // i + 1) // 2
print(ans)
import math
chou = int(input())
tan = int(input())
ji = int(input())
hun = int(input())
ans = float(0)
kakudo = abs(((ji*30 + hun*.6) - (hun*6)))

if kakudo > 180:
    kakudo = kakudo-360
kakudo = abs(kakudo)
print(kakudo)
kakudo = math.cos(math.radians(kakudo))
print(kakudo)
ans =( chou**2 + tan**2 - 2*chou*tan*kakudo)
print((ans)**0.5)

### FIXED CODE ###

import math
chou, tan, ji, hun = map(int,input().split())

kakudo = abs(((ji*30 + hun*.5) - (hun*6)))

if kakudo > 180:
    kakudo = 360 - kakudo

kakudo = abs((math.radians(kakudo)))
ans =( chou**2 + tan**2 - 2*chou*tan*math.cos(kakudo))**.5
print(ans)
import numpy as np

S=input()

print(sum(np.array(list(S[int(len(S)/2)+1:]))!=np.array(list(S[:int(len(S)/2)][::-1]))))

### FIXED CODE ###

import numpy as np

S=input()

half_a=''
half_b=''

if len(S)%2==0:
    half_a=np.array(list(S[int(len(S)/2):]))
    half_b=np.array(list(S[:int(len(S)/2)][::-1]))
    
if len(S)%2==1:
    half_a=np.array(list(S[int(len(S)/2)+1:]))
    half_b=np.array(list(S[:int(len(S)/2)][::-1]))


print(np.sum(half_a!=half_b))
def resolve():
    n = int(input())
    heights = list(map(int, input().split()))
    dp = [-1] * n
    dp[0] = 0

    print(jump(n - 1, heights, dp))

# i番目の足場にたどり着いたときの、コストの最小値を返す関数
def jump(i, heights, dp):
    # 足場 0 のコスト
    if i == 0:
        return 0

    if dp[i] != -1:
        return dp[i]

    res = jump(i - 1, heights, dp) + abs(heights[i] - heights[i - 1])
    if i > 1:
        res = min(res, jump(i - 2, heights, dp) + abs(heights[i] - heights[i - 2]))
    dp[i] = res
    return res
  
resolve()

### FIXED CODE ###

n = int(input())
li = list(map(int, input().split()))

dp = [float('inf')] * n

dp[0] = 0

for i in range(1, n):

  dp[i] = min(dp[i], dp[i-1] + abs(li[i] - li[i-1]))
  if i > 1:
    dp[i] = min(dp[i], dp[i-2] + abs(li[i] - li[i-2]))

print(dp[n - 1])
h,w = list(map(int,input().split()))

mat = []
for i in range(h):
    array = list(map(int,input().split()))
    mat.append(array)

count=0
s=""

for i in range(0,(h+1)//2,2):
    for j in range(w):
        if mat[i][j]%2 !=0:
            mat[i][j]-=1
            count+=1
            if (j+1)==w:
                mat[i+1][j]+=1
                s+=' '.join(map(str,[i+1,j+1,i+2,j+1]))
                s+='\n'
            else:
                mat[i][j+1]+=1
                s+=' '.join(map(str,[i+1,j+1,i+1,j+2]))
                s+='\n'
    
    i+=1
    for j in range(w-1,0,-1):
        if mat[i][j]%2!=0:
            mat[i][j]-=1
            count+=1
            if (j-1)==0:
                mat[i-1][j]+=1
                s+=' '.join(map(str,[i+1,j+1,i,j+1]))
                s+='\n'
            else:
                mat[i][j-1]+=1
                s+=' '.join(map(str,[i+1,j+1,i+1,j]))
                s+='\n'

if h%2!=0:
    i=h-1
    for j in range(w):
        if mat[i][j]%2 !=0:
            if(j+1!=w):
                mat[i][j]-=1
                mat[i][j+1]+=1
                s+=' '.join(map(str,[i+1,j+1,i+1,j+2]))
                s+='\n'
                count+=1                

print(count)
print(s)


### FIXED CODE ###

H,W = map(int,input().split())
src =[list(map(int,input().split())) for i in range(H)]

order=[]
for i in range(H):
    if i%2==0:
        for j in range(W):
            order.append((i,j))
    else:
        for j in reversed(range(W)):
            order.append((i,j))

ans=[]

for(y1,x1),(y2,x2) in zip(order,order[1:]):
    if src[y1][x1]%2:
        ans.append((y1+1,x1+1,y2+1,x2+1))
        src[y2][x2]+=1
print(len(ans))
for row in ans:
    print(*row)
a,b,c = list(map(int, input().split()))
d = c-(a-b)
if d >= 0:
  print(d)
else if:
  print(0)


### FIXED CODE ###

a,b,c = list(map(int, input().split()))
d = c-(a-b)
if d >= 0:
  print(d)
else:
  print(0)
from decimal import * 
import math
a,b,x = map(int,input().split())
X = x/a
P = X /(a*b)
if P >= 0.5 :
    print(math.degrees(math.atan((2*b*(1-P)/a))))
else:
    print(math.degrees(math.atan((a*b**2/(2*x)))))

### FIXED CODE ###

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
M = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
 
for i in range(2, M + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

a, b = map(int, input().split())
N = (a+b)//3
A = (N -abs(a-b))//2
B = (N +abs(a-b))//2
if (a+b)%3!=0 or A<0 :
    print(0)
else :
    print(cmb(N, A, p))
q = int(input())
l = []
r = []
for i in range(q):
    li, ri = map(int, input().split())
    l.append(li)
    r.append(ri)

r_max = max(r) + 10
is_prime = [True] * r_max
is_prime[0] = is_prime[1] = False
for i in range(2, r_max):
    if is_prime[i]:
        for j in range(2, r_max // i + 1):
            is_prime[i*j] = False

# print(is_prime)
a = [0] * r_max
for i in range(3, r_max):
    a[i] = a[i-1]
    if is_prime[i] and is_prime[(i+1)//2]:
        a[i] += 1
# print(a)

for i in range(q):
    print(a[r[i]] - a[l[i]-1])


### FIXED CODE ###

import math
q = int(input())
l = []
r = []
for i in range(q):
    li, ri = map(int, input().split())
    l.append(li)
    r.append(ri)

r_max = max(r) + 10
is_prime = [True] * (r_max+1)
is_prime[0] = is_prime[1] = False
for i in range(2, r_max):
    if is_prime[i]:
        for j in range(2, r_max // i + 1):
            is_prime[i*j] = False

# print(is_prime)
a = [0] * r_max
for i in range(3, r_max):
    a[i] = a[i-1]
    if is_prime[i] and is_prime[(i+1)//2]:
        a[i] += 1
# print(a)

for i in range(q):
    print(a[r[i]] - a[l[i]-1])
import numpy as np
N=int(input())
p=list(map(int,input().split()))
x=np.prod(p,axis=1)
if x<10**18:
  print(x)
else:
  print(-1)

### FIXED CODE ###

N=int(input())
a=list(map(int,input().split()))
a.sort()
a.reverse()
if a.count(0)>0:
  print(0)
else:
  ans=a[0]
  flag=0
  for i in range(1,N):
    ans*=a[i]
    if ans>10**18:
      flag+=1
      print(-1)
      break
  if flag==0:
    print(ans)
import sys
"""
a=[]
while True:
	n=input()
	if n==-1:
		break
	a.append(n)
"""
for line in sys.stdin:
	a.append(int(line))
for x in a:
	out=1
	while x:
		if x&1:
			print out,
		x/=2
		out*=2
	print 

### FIXED CODE ###

import sys

for line in sys.stdin:
	x=int(line)
	out=1
	ret=""
	while x:
		if x&1:
			ret+=" "+str(out)
		x/=2
		out*=2
	print ret[1::]