Harryxun/stf_run huggingface dataset:
import collections
n, m = map(int, input().split())
par = [i for i in range(0, n + 1)]
# print(par)
s = list()
"""
# union find(parには0も入れているので、par[1]=1になる)
def find(x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
"""


def find(x):

    while par[x] != x:
        tmp = par[x]
        par[x] = par[par[x]]
        x = par[x]

    return x


def union(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return 0
    else:
        par[x] = y


# 各要素をunionする
for j in range(m):
    a, b = map(int, input().split())
    union(a, b)

# 1～nの親を探してsに入れていき、一番多い親を答えにする
for k in range(1, n + 1):
    s.append(find(k))
# print(s)
c = collections.Counter(s)
print(max(c.values()))


### FIXED CODE ###

from math import gcd

from math import factorial as f

from math import ceil, floor, sqrt
import math

import bisect
import re
import heapq

from copy import deepcopy
import itertools
from itertools import permutations

from sys import exit

ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(map(int, input().split()))

yes = "Yes"
no = "No"


def main():
    d, t, s = mi()

    if s * t >= d:
        print(yes)
    else:
        print(no)


main()
n,m=map(int,input().split())
dp=[0]*(n+1)
dp[0]=1
a=int(input())
b=0
for i in range(1,n+1):
  if i==a:
    b+=1
    if b<m:a=int(input())
  else:dp[i]=(dp[i-1]+dp[i-2])%(10**9+7)
print(dp[-1])

### FIXED CODE ###

n,m=map(int,input().split())
dp=[0]*(n+1)
dp[0]=1
a=b=0
if b<m:a=int(input())
for i in range(1,n+1):
  if i==a:
    b+=1
    if b<m:a=int(input())
  else:
    dp[i]=dp[i-1]
    if i>1:dp[i]+=dp[i-2]
  dp[i]%=(10**9+7)
print(dp[-1])
def f(x):
	if x % 2 == 0:
    	return x//2
	else:
		return 3*x+1

s = int(input())
a = [s]
m = 1
while True:
	t = f(s)
    m += 1
    if t not in a:
    	a.append(t)
        s = t
	else:
    	break
print(m)

### FIXED CODE ###

def f(x):
	if x % 2 == 0:
		return x//2
	else:
		return 3*x+1
 
s = int(input())
a = [s]
m = 1
while True:
	t = f(s)
	m += 1
	if t not in a:
		a.append(t)
		s = t
	else:
		break
print(m)
H,W,D = list(map(int, input().split()))
X = [[0,0] for i in range(H*W+1)]

for i in range(1, H+1):
	A = list(map(int, input().split()))
	for idx, a in enumerate(A):
		X[a] = [i, idx+1]

Q = int(input())
L = []
R = []
S = [0]*(H*W+1)

for i in range(Q):
	l,r = list(map(int, input().split()))
	L.append(l)
	R.append(r)

for i in range(D+1, H*W+1):
	S[i] = S[i-D] + abs(X[i][0]-X[i-D][0])+abs(X[i][1]-X[i-D][1])

for i in range(Q):
	print(S[R[i]] - S[L[i]])


### FIXED CODE ###

n = int(input())
out = int(n / 3)
print(out)
def f(x):
    p=0
    cnt=0
    for i in range(n-1,-1,-1):
        while a[i]+a[p]<x:
            p+=1
            if p==n: return cnt
        cnt+=n-p
    return cnt

n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()

l,r=a[0]*2,a[n-1]*2

while r-l>0:
    if r-l<=1: md=l;break
    md=(r+l)//2
    k=f(md)
    if k==m: break
    elif k>m: l=md
    else: r=md

p=0
cnt=0
ans=0
for i in range(n-1,-1,-1):
    while p<n and a[i]+a[p]<=md:
        p+=1
    if p==n: break
    cnt+=n-p
    ans+=a[i]*(n-p)*2


ans+=(m-cnt)*md
print(ans)

### FIXED CODE ###

import sys

def f(x):
    p=0
    cnt=0
    for i in range(n-1,-1,-1):
        while p<n and a[i]+a[p]<x:
            p+=1
        cnt+=n-p
    return cnt

n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()

l,r=a[0]*2,a[n-1]*2
md=(r+l)//2
while r-l>0:
    if r-l<=1:
        if f(r)==m: md=r;break 
        else: md=l;break
    md=(r+l)//2
    k=f(md)
    if k==m: break
    elif k>m: l=md
    else: r=md

p=0
cnt=0
ans=0

for q in range(n-1,-1,-1):
    try:
        while p<n and a[q]+a[p]<=md:
            p+=1
    except:
        b=1
        while True:
            b+=1

    if p==n: break
    cnt+=n-p
    ans+=a[q]*(n-p)*2


ans+=(m-cnt)*md
print(ans)
import math
while True:
    s=input().split()
    if s[1]==?:
        break
    if s[1]==+:
        print(int(s[0])+int(s[2]))
    if s[1]==-:
        print(int(s[0])-int(s[2]))
    if s[1]==*:
        print(int(s[0])*int(s[2]))
    if s[1]==/:
        print(math.floor(int(s[0])/int(s[2])))


### FIXED CODE ###

import math
while True:
    s=input().split()
    if s[1]=="?":
        break
    elif s[1]=="+":
        print(int(s[0])+int(s[2]))
    elif s[1]=="-":
        print(int(s[0])-int(s[2]))
    elif s[1]=="*":
        print(int(s[0])*int(s[2]))
    elif s[1]=="/":
        print(math.floor(int(s[0])/int(s[2])))
n, a, b = [int(s) for in input().split(" ")]

print("%d" % min(n * a, b))

### FIXED CODE ###

n, a, b = [int(s) for s in input().split(" ")]

print("%d" % min(n * a, b))
# input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *
import copy
K=int(input())
A=list(map(int,input().split()))
if A[-1]!=2:
    print(-1)
    exit()

maX=2
miN=2

for i in range(K-1,-1,-1):

    if A[i]//maX>=2:
        print(unko)
    if A[i]//miN>=2:
        miN=A[i]
    if miN%A[i]==0:
        pass
    else:
        miN=(miN//A[i] +1) *A[i]
    maX=(maX//A[i]) *A[i] + A[i]-1
print(miN,maX)


### FIXED CODE ###

# input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *
import copy
K=int(input())
A=list(map(int,input().split()))
if A[-1]!=2:
    print(-1)
    exit()

maX=2
miN=2

for i in range(K-1,-1,-1):

    if A[i]//maX>=2:
        print(-1)
        exit()
    if A[i]//miN>=2:
        miN=A[i]
    else:
        if miN%A[i]==0:
            pass
        else:
            miN=(miN//A[i] +1) *A[i]
    maX=maX-maX%A[i] + A[i]-1

mmaX=maX
for i in range(K):
    mmaX-=mmaX%A[i]
if mmaX==2:
    print(miN,maX)
else:
    print(-1)
n = int(input())
AC = 0
WA = 0
TLE = 0
RE = 0
for _ in range(n):
  a = input()
  if a = "AC":
    AC += 1
  elif a = "WA":
    WA += 1
  elif a = "TLE":
    TLE += 1
  else:
    RE += 1
  
print("AC x "+ AC)
print("WA x "+ WA)
print("TLE x "+ TLE)
print("RE x "+ RE)


### FIXED CODE ###

n = int(input())
A = [input() for _ in range(n)]

print("AC x " + str(A.count("AC")))
print("WA x " + str(A.count("WA")))
print("TLE x " + str(A.count("TLE")))
print("RE x " + str(A.count("RE")))
x,y,z,k=list(map(int,input().split()))
    a=list(map(int,input().split()))
    b=list(map(int,input().split()))
    c=list(map(int,input().split()))
      
    li=[]
    for i in a:
      for j in b:
        li.append(i+j)
    li.sort(reverse=True)
     
    ansli=[]
    for i in c:
      for j in range(min(k,len(li))):
        ansli.append(i+li[j])
    ansli.sort(reverse=True)
     
    for i in range(k):
      print(ansli[i])

### FIXED CODE ###

from heapq import *

x,y,z,k=list(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)

q=[]
li=[]
heappush(q,((a[0]+b[0]+c[0]) * (-1),0,0,0))

for i in range(k):
  node=heappop(q)
  
  print(node[0]*-1)
  if node[1]+1 != x:
    node_a = ((a[node[1]+1]+b[node[2]]+c[node[3]])*(-1), node[1]+1, node[2], node[3])
    if node_a not in q:
      heappush(q,node_a)
  
  if node[2]+1 != y:
    node_b = ((a[node[1]]+b[node[2]+1]+c[node[3]])*(-1), node[1], node[2]+1, node[3])
    if node_b not in q:
      heappush(q,node_b)
  
  if node[3]+1 != z:
    node_c = ((a[node[1]]+b[node[2]]+c[node[3]+1])*(-1), node[1], node[2], node[3]+1)
    if node_c not in q:
      heappush(q,node_c)
a = list(input())
b = list(input())
c = list(input())

if a[len(a)] = b[0] and b[len(b)] = c[0]:
  print("YES")
else:
  print("NO")

### FIXED CODE ###

a, b, c = map(list, input().split())
if a[len(a)-1] == b[0] and b[len(b)-1] == c[0]:
  print("YES")
else:
  print("NO")
a = int(input())
y = a//100
m = a%100
if y <= 12 and y >= 1:
	if m <= 12 and n >= 1:
    	print('AMBIGUOUS')
    else:
     	print('MMYY')
else:
	if m <= 12 and n >= 1:
    	print('YYMM')
    else:
     	print('NA')


### FIXED CODE ###

a = int(input())
y = a//100
m = a%100
if 1 <= y <= 12 and 1 <= m <= 12:
	print('AMBIGUOUS')
elif 1 <= y <= 12:
	print('MMYY')
elif 1 <= m <= 12:
	print('YYMM')
else:
	print('NA')
N, M= (int(i) for i in input().split())
for num in range(N):
    lst[num] = [int(i) for i in input().split()]
    
food = np.zeros((N,M))
for i in range(N):
    for j in range(lst[i][0]):
        #print(lst[i][j+1])
        food[i][lst[i][j+1]-1] = 1
#print(food)
s = np.sum(food, axis=0)
print(len(s[s==N]))

### FIXED CODE ###

N, M= (int(i) for i in input().split())
lst = [[int(i) for i in input().split()] for i in range(N)]
import numpy as np
food = np.zeros((N,M))
for i in range(N):
    for j in range(lst[i][0]):
        #print(lst[i][j+1])
        food[i][lst[i][j+1]-1] = 1
#print(food)
s = np.sum(food, axis=0)
print(len(s[s==N]))
n=int(input())
A=map(int,input().split())
c=0
loop=True
while(loop):
  for a in A:
    if a%2!=0:
      loop=False
      break
  a = map(lambda a//2, a)
  count+=1
print(c)

### FIXED CODE ###

n=int(input())
A=list(map(int,input().split()))
c=0
loop=True
while(loop):
    for a in A:
        if a%2!=0:
            loop=False
            break
    if loop:
        A = list(map(lambda i:i//2, A))
        c+=1
    else:
        break
print(c)
n, k  = map(int, input().split())
x = 0
for k in range(k, n+2):
  a =k * (k-1)//2
  b = k * (2*n+1-k)//2

  x += b- a +1
  
  
  
print(x%(10^9+7))




### FIXED CODE ###

x = int(input())
pi = 3.14159

print(2 * x * pi)
N=int(input())
L=list(map(int,input().split()))
A=1
for i in range(N):
  A=A*L[i]
  if 10**18<A:
  print(-1)
  exit()
  else:
  print(A)

### FIXED CODE ###

N=int(input())
L=list(map(int,input().split()))
A=1
if 0 in L:
  print(0)
  exit()
for i in range(N):
  A=A*L[i]
  if 10**18<A:
    print(-1)
    exit()
print(A)
n, k = map(int, input().split())
lis = []
for i in range(k*2):
    lis.append(input().split())
lis2 = []
j = 1
while j < k*2:
    for k in lis[j]:
        li2.append(k)
    j += 2
lis2 = set(lis2)
print(n - len(lis2))

### FIXED CODE ###

n, k = map(int, input().split())
li = []
for x in range(k*2):
    li.append(input().split())
li2 = []
i = 1
while i < k*2:
    for j in li[i]:
        li2.append(j)
    i += 2
li2 = set(li2)
print(n - len(li2))
n,m = map(int,input().split())
a = list(map(int,input().split()))
bc = [list(map(int,input().split()))for i in range(m)]
p =[]
d = []
a.sort()
for i in range(m):
    b = bc[i][0]
    c = bc[i][1]
    p.append([c,b])
p.sort(reverse = True)
look = 0
for i in range(n):
    if look > m-1:break
    if p[look][1] >0:
        d.append(p[look][0])
        p[look][1]-=1
    else:
        look+=1
        d.append(p[look][0])
        p[look][1]-=1
sm = sum(a)
updatefrom = 0
updateto = 0
ans = 0
for x in range(n):
    updatefrom +=a[x]
    updateto +=d[x]
    ans = max(ans,sm-updatefrom +updateto)
print(ans)
    

    
    

### FIXED CODE ###

n,m = map(int,input().split())
a = list(map(int,input().split()))
bc = [list(map(int,input().split()))for i in range(m)]
p =[]
d = []
a.sort()
for i in range(m):
    b = bc[i][0]
    c = bc[i][1]
    p.append([c,b])
p.sort(reverse = True)
look = 0
for i in range(n):
    if look > m-1:break
    if p[look][1] >0:
        d.append(p[look][0])
        p[look][1]-=1
    
    else:
        if look ==m-1:break
        look+=1
        d.append(p[look][0])
        p[look][1]-=1
sm = sum(a)
updatefrom = 0
updateto = 0
ans = sm
for x in range(n):
    if x >= len(d):break
    updatefrom +=a[x]
    updateto +=d[x]
    ans = max(ans,sm-updatefrom +updateto)
print(ans)
s = str(input())
t = str(input())

slen = len(s)
tlen = len(t)

i = tlen
n = 0
a = 0
tuu = [0] * tlen
ans = [0] * tlen
max_count = 0
while i <= slen:
    ps = s[ n : i + tlen -1 ]
    count = 0
    for j in range(tlen):
        if ps[j] == t[j]:
            count += 1
            tuu[j] = "True"
#             print("通った")
#     print(count)
    if max_count < count:
        max_count = count
#         print("通った")
        a = n
        ans = tuu
        
#     print(a)    
    n += 1
    i += 1
# print(a)
# print(ans)

for h in range(tlen):
    if ans[h] == "True":
        pass
    else:
        t[h] = s[a + h]  

### FIXED CODE ###

s = str(input())
t = str(input())

slen = len(s)
tlen = len(t)

i = tlen
n = 0
a = 0
# tuu = [0] * tlen
# ans = [0] * tlen
max_count = 0
while i <= slen:
    ps = s[ n : i + tlen -1 ]
    count = 0
    for j in range(tlen):
        if ps[j] == t[j]:
            count += 1
#             tuu[j] = "True"
#             print("通った")
#     print(count)
    if max_count < count:
        max_count = count
    n += 1
    i += 1
print(tlen - max_count)
S = input()
Slist = [S[i] for i in range(len(S))]
Q = int(input())
Query = [list(input().split()) for i in range(Q)]
Qlen = len(Query)
reverse = False
back = []
head = []

for idx, value in enumerate(Query):
    if value[0] == "1":
        reverse ^= True
        head, back = back, head
    else:
        if value[1] == "1":
            back = back + [value[2]]
        else:
            head = head + [value[2]]
if reverse == False:
    print( "".join(head.reverse()) + "".join(Slist) + "".join(back) )

else:
    print( ''.join(reversed(head)) + "".join(Slist[::-1]) + "".join(back))

### FIXED CODE ###

S = input()
Slist = [S[i] for i in range(len(S))]
Q = int(input())
Query = [list(input().split()) for i in range(Q)]
Qlen = len(Query)
reverse = False
back = []
head = []

for idx, value in enumerate(Query):
    if value[0] == "1":
        reverse ^= True
        head, back = back, head
    else:
        if value[1] == "1":
            head += [value[2]]
        else:
            back += [value[2]]

if reverse == False:
    head.reverse()
    print("".join(head + Slist + back))
else:
    head.reverse()
    print("".join(head + Slist[::-1] + back))
N, W = map(int, input().split())
items = [list(map(int, input().split())) for _ in range(N)]


dp = [[float('-inf') for _ in range(1000)] for _ in range(10)]
dp[0][0] = 0
for i, (item_weight, item_value) in enumerate(items):  # i番目の品
    for total_weight in range(W+10):                   # 重さの合計
        dp[i+1][total_weight] = max(dp[i][total_weight], dp[i+1][total_weight])
        dp[i+1][total_weight+item_weight] = max(dp[i][total_weight]+item_value, dp[i+1][total_weight+item_weight])
        
print(dp[N][W])

### FIXED CODE ###

N, W = map(int, input().split())
items = [list(map(int, input().split())) for _ in range(N)]

dp = [[0 for _ in range(W+10)] for _ in range(N+10)]

for i, (item_weight, item_value) in enumerate(items):
    for total_weight in range(W+1):
        if (total_weight-item_weight) >= 0:
            dp[i+1][total_weight] = max(dp[i][total_weight-item_weight] + item_value, dp[i+1][total_weight])
        dp[i+1][total_weight] = max(dp[i+1][total_weight], dp[i][total_weight])
        
print(dp[N][W])
# -*- coding: utf-8 -*-
import math 
# 整数の入力
k = int(input())

for n in range(1,k+1):
    if (n % 9) == 0:
        print ("9" * math.floor(n/9))
    else:
        print(str((n % 9)) + "9" * math.floor(n/9))


### FIXED CODE ###

# -*- coding: utf-8 -*-
# 整数の入力
s = input()

res = 0
for i in s:
    if("+" == i):
        res += 1
    else:
        res -= 1

# 出力
print("{}".format(res))
n,x,y = map(int, input().split())
ans = [0]*n
for i in range(0 , n):
  for j in range(i+1 ,n+1):
    ans= ans(min(abs(j-i), abs(x-i), abs(y-j)+1)+1
    
for i in range(1,n):
  print(ans[i])

### FIXED CODE ###

n,x,y = map(int, input().split())
ans = [0]*n
for i in range(1 , n):
  for j in range(i+1 ,n+1):
    ans[min(abs(j-i),abs(x-i)+abs(y-j)+1)]+=1
    
for i in range(1,n):
  print(ans[i])
N, K = map(int, input().split())

ans = 0

while(n_k > 1):
  n_k = N/K
  ans += 1
  
  
print(ans)

### FIXED CODE ###

N, K = map(int, input().split())

ans = 0

while(N >= 1):
    N= N/K
    ans += 1
  
  
print(ans)
import itertools

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

total = 0

memo = []
number = []
for i in range(m):
    number.append(i+1)
len = m

for j in range((m+3-1)*(m+2-1)*(m)//6):
    memo.append(0)


a = list(itertools.combinations_with_replacement(number,n))
for i in range(q):
    num = list(map(int,input().split()))
    for j in range((m+3-1)*(m+2-1)*(m)//6):
        if int(a[j][num[1]-1])-int(a[j][num[0]-1]) == int(num[2]):
            memo[j] += num[3]
print(max(memo))



### FIXED CODE ###

import itertools

n,m,q = map(int,input().split())
num = [list(map(int,input().split())) for i in range(q)]

number = []
for i in range(m):
    number.append(i+1)
a = list(itertools.combinations_with_replacement(number,n))
length = len(a)
memo = [0] * length
ans = 0

for i in range(length):#組み合わせの数回す
    sum = 0
    for j in range(q):
       if a[i][num[j][1]-1] - a[i][num[j][0]-1]  == num[j][2]:
            sum += num[j][3]
    ans = max(sum,ans)
print(ans)
S, W = int(inpit())

if S <= W:
    print('unsafe')
else S > W:
    print('safe')
    


### FIXED CODE ###

S, W = map(int, input().split())

if S <= W:
    print('unsafe')
else:
    print('safe')
n = input()
d = map(int, input().split())
sum = 0
for i in range(n-1):
  for j in range(i+1, n):
    sum += d[i] * d[j]
print(sum)


### FIXED CODE ###

n = int(input())
d = list(map(int, input().split()))
sum = 0
for i in range(n-1):
  for j in range(i+1, n):
    sum += d[i] * d[j]
print(sum)
n,k=map(int,input().split())
ans=0
for i in range(1,N+1):
  if i>=k:
    ans+=1/n
  else:
    cnt=1/n
    while i<k:
      cnt*=(1/2)
      i=2*i
    ans+=cnt
print(ans)

### FIXED CODE ###

n,k=map(int,input().split())
ans=0
for i in range(1,n+1):
    if i>=k:
        ans+=1/n
    else:
        cnt=1/n
        while i<k:
            cnt*=(1/2)
            i=2*i
        ans+=cnt
print(ans)
import itertools

n,m,q = input().split()
n = int(n)
m = int(m)
q = int(q)
num_list = []
a = list(range(1, n+1))
for i in range(q):
    num_list.append(list(map(int,input().split())))
num_list = sorted(num_list, reverse=True, key=lambda x: x[3])
ff = list(itertools.combinations_with_replacement(a, m))
max = 0
for i in range(len(ff)):
  s = 0
  for j in range(q):
    a,b,c,d = num_list[j]
    if ff[i][b-1] - ff[i][a-1] == c:
      s = s + d
  if max < s:
        max = s
print(max)

### FIXED CODE ###

import itertools

n,m,q = input().split()
n = int(n)
m = int(m)
q = int(q)
num_list = []
a = list(range(1, n+1))
for i in range(q):
    num_list.append(list(map(int,input().split())))
ff = list(itertools.combinations_with_replacement(range(1, m + 1), n))
max = 0
for i in range(len(ff)):
  s = 0
  for j in range(q):
    a,b,c,d = num_list[j]
    if ff[i][b-1] - ff[i][a-1] == c:
      s = s + d
  if max < s:
        max = s
print(max)
s = input()
if s == 'A':
    print('T')
elif s== 'T':
    print('A')
elif s == G:
    print('C')
else:
    print('G')

### FIXED CODE ###

s = input()
if s == 'A':
    ans = 'T'
elif s== 'T':
    ans = 'A'
elif s == 'G':
    ans = 'C'
elif s == 'C':
    ans = 'G'
else:
    print("error")
    
print(ans)
#B - Bishop △(TLE,WA)
H,W = map(int,input().split())

count = 0
if H == 1 or W == 1:#コーナーケース(H,Wが1の時どこにも動けない)
if H % 2 == 0:
    count = (H // 2)*W
else :
    count = (H // 2)*W + ((W + 2 - 1) // 2)#x/yの切り上げ:(x+y-1)//y
print(count)

### FIXED CODE ###

#B - Bishop △(TLE,WA)
H,W = map(int,input().split())

count = 0
if H == 1 or W == 1:#コーナーケース(H,Wが1の時どこにも動けない)
    count = 1
elif H % 2 == 0:
    count = (H // 2)*W
else :
    count = (H // 2)*W + ((W + 2 - 1) // 2)#x/yの切り上げ:(x+y-1)//y
print(count)
import math
N, X = map(int,input().split())
x = list(map(int,input().split()))
ma = 0
for i in range(N):
  ma = math.gcd(ma,abs(x[i]-X))
print(ma)

### FIXED CODE ###

import fractions
N, X = map(int, input().split())
x = list(map(int, input().split()))
tmp = abs(x[0] - X)
for i in range(1,N):
  tmp = fractions.gcd(tmp,abs(x[i]-X))
print(tmp)
def solve(string):
    ins = string.split("\n")
    h, w = map(int, ins[0].split(" "))
    a = [list(map(int, _i.split(" "))) for _i in ins[1:]]
    move = []
    for j in range(h):
        for i in range(w):
            if a[j][i] % 2 == 0:
                continue
            a[j][i] -= 1
            if i < w - 1:
                a[j][i + 1] += 1
                move.append("{} {} {} {}".format(j + 1, i + 1, j + 1, i + 2))
            elif j < h - 1:
                a[j + 1][i] += 1
                move.append("{} {} {} {}".format(j + 1, i + 1, j + 2, i + 1))
    return "{}\n{}".format(len(move), "\n".join(move)) if len(move) > 0 else "0"


if __name__ == '__main__':
    line = input()
    tmp = [line]
    for _ in range(int(line[0])):
        tmp.append(input())
    print(solve('\n'.join(tmp)))


### FIXED CODE ###

h,w = map(int,input().split())
a = []
for i in range(h):
    tmp = list(map(lambda x:int(x)%2,input().split()))
    a.append(tmp)
result = []
 
for i in range(h):
    for j in range(w-1):
        if a[i][j] == 1:
            #a[i][j] == 0
            a[i][j+1] = 1 ^ a[i][j+1]
            result.append((i+1,j+1,i+1,j+2)) 
for i in range(h-1):
    if a[i][w-1] == 1:
        a[i+1][w-1] = 1 ^ a[i+1][w-1]
        result.append((i+1,w,i+2,w))
print(len(result))
for row in result:
    print("{} {} {} {}".format(row[0],row[1],row[2],row[3]))
n = int(input())
a = list(map(int, input().split()))
m = sum(i<0 for i in a)
if m%2==0:
    print(sum(map(abs, a)))
else:
    print(sum(map(abs, a)) - min(i for i in a if i>=0)*2)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
m = sum(i<0 for i in a)
if m%2==0:
    print(sum(map(abs, a)))
else:
    print(sum(map(abs, a)) - min(map(abs, a))*2)
class Bridge:
    def __init__(self, nodeA, nodeB):
        self.edges = [nodeA, nodeB]
    def another(self, node):
        return self.edges[1 if node == self.edges[0] else 0]

class Node:
    def __init__(self, id):
        self.id = id
        self._bridges = []
        self.parent = None
    def addEdge(self, bridgeEdge):
        self._bridges.append(bridgeEdge)
    def bridges(self):
        return ((self, br.another(self) ) for br in self._bridges)
    def __repr__(self):
        return str((self.id, None if self.parent is None else self.parent.node.id))

N, M = map(int, input().split())

nodes = [Node(i) for i in range(N+1)]
bridges = []
for A, B in (map(int, input().split()) for _ in range(N)):
    bridges.append(Bridge(nodes[A], nodes[B]))


### FIXED CODE ###

class Bridge:
    def __init__(self, nodeA, nodeB):
        self.edges = [BridgeEdge(nodeA, self), BridgeEdge(nodeB, self)]
        nodeA.addEdge(self.edges[1])
        nodeB.addEdge(self.edges[0])
        self.dir = True
        self.vec = None
    def __repr__(self):
        return str((self.vec, self.dir))

class BridgeEdge:
    def __init__(self, node, edge):
        self.edge = edge
        self.node = node
    def another(self):
        return self.edge.edges[1 if self.edge.edges[0] == self else 0]

class Node:
    def __init__(self, id):
        self.id = id
        self.bridges = []
        self.parent = None
        self.judge = True
    def addEdge(self, bridgeEdge):
        self.bridges.append(bridgeEdge)
    def __repr__(self):
        return str((self.id, None if self.parent is None else self.parent.node.id, self.judge))

N, M = map(int, input().split())

nodes = [Node(i) for i in range(N+1)]
bridges = []
for A, B in (map(int, input().split()) for _ in range(M)):
    bridges.append(Bridge(nodes[A], nodes[B]))

s = [(0, nodes[1])]
idx = 0
while len(s) > 0:
    level, cur = s.pop()

    nxtlevel = level + 1
    for nxt in cur.bridges:
        if nxt.edge.vec is None:
            cur.judge ^= True
            nxt.edge.vec = (cur.id, nxt.node.id)
            if nxt.node.parent is None:
                nxt.node.parent = nxt.another()
                s.append((nxtlevel, nxt.node))

    if len(s) > 0:
        nl = s[-1][0]
    else:
        nl = 1
    while level >= nl:
        if not cur.judge:
            cur.judge ^= True
            cur.parent.node.judge ^= True
            cur.parent.edge.dir ^= True
        level -= 1
        cur = cur.parent.node
  
if all(node.judge for node in nodes[1:]):
    for br in bridges:
        if br.dir:
            print("{} {}".format(br.vec[0], br.vec[1]))
        else:
            print("{} {}".format(br.vec[1], br.vec[0]))
else:
    print("-1")