Harryxun/stf_run huggingface dataset:
N, M = map(int, input().split(' '))
X = []
for i in range(N):
    X.append(list(map(int, input().split(' '))))

num_b = [i+1 for i in range(N)]
psb = [0]*N
psb[0] = 1

for i in X:
    num_b[i[0]] -= 1
    num_b[i[1]] += 1
    if num_b[i[0]] == 0:
        psb[i[0]] = 0
    if psb[i[0]] == 1:
        psb[i[1]] == 1 

print(psb.count(1))


### FIXED CODE ###

N, M = map(int, input().split(' '))
X = []
for i in range(M):
    X.append(list(map(int, input().split(' '))))

num_b = [1 for i in range(N+1)]
num_b[0] = 0
psb = [0]*(N+1)
psb[1] = 1
for i in range(M):
    num_b[X[i][0]] -= 1
    num_b[X[i][1]] += 1
    if psb[X[i][0]] == 1:
        psb[X[i][1]] = 1 
    if num_b[X[i][0]] == 0:
        psb[X[i][0]] = 0

print(psb.count(1))
a,b,c=map(int,input().split())

aa=min(a,b)
bb=min(cc,max(a,b))

print((aa*bb)//2)

### FIXED CODE ###

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

aa=min(a,b)
bb=min(c,max(a,b))

print((aa*bb)//2)
import math
N = int(input())
T = [int(input()) for _ in range(N)]
ans = T[0]
for i in range(1, N):
    ans = (ans * T[i]) // math.gcd(ans, T[i])

print(ans)

### FIXED CODE ###

import fractions
N = int(input())
T = [int(input()) for _ in range(N)]
ans = T[0]
for i in range(1, N):
    ans = (ans * T[i]) // fractions.gcd(ans, T[i])

print(ans)
import itertools

n,m = map(int,input().split())
path=[[False]*n for _ in range(n)]
for _ in range(m):
  a,b = map(int,input().split())
  a-=1
  b-=1
  path[a][b]=True
  path[b][a]=True
ans=0
for i in itertools.permutations(range(n),n):
  if i[0]==0:
    for j in rannge(n-1):
      if j ==n-1:
        ans+=1
      if not path[i[j]][i[j+1]]:
        break
print(ans)


### FIXED CODE ###

import itertools

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

path = [[False] * n for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    path[a][b] = True
    path[b][a] = True

ans = 0

# 頂点を並び替える順列を生成してループ
for i in itertools.permutations(range(n), n):
    # 頂点1が始点
    if i[0] == 0:
        # 生成した順列の中をさらにループ
        for j in range(n):
            # n - 1 まで続いたら条件を満たすパスが存在する
            if j == n - 1:
                ans += 1
                break
            # i[j] から i[j + 1] に行くパスがなければ終了
            if not path[i[j]][i[j + 1]]:
                break

print(ans)
r, D, x = map(int, input().split)


for i in range(10):
  x = (r * x) - D
  print(x)

### FIXED CODE ###

r, D, x = map(int, input().split())


for i in range(10):
  x = (r * x) - D
  print(x)
n = int(input())
other = ['0', '1', '2', '4', '6', '8', '9']
def dfs(sss):
  if(int(sss) > n):
    return 0
  r = 1 if(sss == all(s.count(c) > 0 for c in '753')) else 0
  for c in '357':
    r += dfs(sss+c)
  return r
print(dfs('0'))

### FIXED CODE ###

n = int(input())
def dfs(sss):
  if(int(sss) > n):
    return 0
  r = 1 if(all(sss.count(c) > 0 for c in '753')) else 0
  for c in '357':
    r += dfs(sss+c)
  return r
print(dfs('0'))
n, m = map(int, input().split())
a = list(map(int, input().split()))

def f(x):
    res = 0
    while x % 2 == 0:
        x/= 2
        res += 1
    return res

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd (a, b)

for i in range(n):
    a[i] //= 2

t = f(a[0])

ans = 0
for i in range(n):
    if f(a[i] != t):
        print(0)
        exit()
    a[i] >>= t

m >>= t

l = 1
for i in range(n):
    l = lcm(l, a[i])
    if l > m:
        print(0)
        exit()

m //= l
ans = (m + 1)//2
print(ans)


### FIXED CODE ###

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

def f(x):
    res = 0
    while x % 2 == 0:
        x//= 2
        res += 1
    return res

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd (a, b)

for i in range(n):
    a[i] //= 2

t = f(a[0])

ans = 0
for i in range(n):
    if f(a[i]) != t:
        print(0)
        exit()
    a[i] >>= t

m >>= t

l = 1
for i in range(n):
    l = lcm(l, a[i])
    if l > m:
        print(0)
        exit()

m //= l
ans = (m + 1)//2
print(ans)
import math
a,b=map(int,input().split())
print((a*b)//math.gcd(a, b))

### FIXED CODE ###

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def lcm(a, b):
	return a * b // gcd (a, b)

a,b=map(int,input().split())
print(lcm(a,b))
while True:
    count = 0
    num = [int(i) for i in input().split("")]
    if num[0] == 0:
        break
    for n in num:
        count += n
        print(count, end ="\n")
     

### FIXED CODE ###

while True:
    x = input()
    if x == "0":
        break
    num = [int(i) for i in x]
    print(sum(num))
# -*- coding: utf-8 -*-

import math

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()
b.sort()
c.sort()

cnum = []

takadaka = math.ceil(k ** 0.75)

for i in range(min(takadaka,x)):
    for j in range(min(takadaka,y)):
        for l in range(min(takadaka,z)):
            cnum.append(a[i] + b[j] + c[l])

cnum.sort()
cnum.reverse()

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


### FIXED CODE ###

# -*- coding: utf-8 -*-
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

if e - a <= k:
    print("Yay!")
else:
    print(":(")
s=input()
for i in range(len(s)):
    if s[i]=="0":
        ans+="0"
    elif s[i]=="1":
        ans+="1"
    else:
        ans=ans[0:-1]
print(ans)

### FIXED CODE ###

s=input()
ans=""
for i in range(len(s)):
    if s[i]=="0":
        ans+="0"
    elif s[i]=="1":
        ans+="1"
    else:
        ans=ans[0:-1]
print(ans)
n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n-k+1):
  if a[i]<a[i+k]:
    print('Yes')
  else:
    print('No')


### FIXED CODE ###

n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n-k):
  if a[i]<a[i+k]:
    print('Yes')
  else:
    print('No')
import sys
sys.setrecursionlimit(10**7)
N=int(input())
A,B=[],[]
for i in range(N):
  a,b=map(int,input().split())
  A.append((a,b,i))
  B.append((b,a,i))
A.sort()
B.sort()
ans=0
inf=float("inf")
eaten=[False]*N
for i in range(N):
  if i%2==0:
    while eaten[A[-1][2]]:
      A.pop()
    while eaten[B[-1][2]]:
      B.pop()
    a1,b0,t=A.pop()
    b1,a2,s=B.pop()
    if t==s:
      ans+=a1
      eaten[t]=True
    else:
      b2=inf    
      while B and b2>10000000000:
        if not eaten[B[-1][2]]:
          b2,a0,g=B.pop()
        else:
          B.pop()
      if a1-b1>=a2-b2:
        ans+=a1
        eaten[t]=True
        B.append((b2,a0,g))
        B.append((b1,a2,s))
      else:
        ans+=a2
        eaten[s]=True
        A.append((a1,b0,t))
        B.append((b2,a0,g))
  else:
    while eaten[A[-1][2]]:
      A.pop()
    while eaten[B[-1][2]]:
      B.pop()
    a1,b2,t=A.pop()
    b1,a0,s=B.pop()
    if t==s:
      ans-=b1
      eaten[t]=True
    else:
      a2=inf    
      while A and a2>10000000000:
        if not eaten[A[-1][2]]:
          a2,b0,g=A.pop()
        else:
          B.pop()
      if b1-a1>=b2-a2:
        ans-=b1
        eaten[s]=True
        A.append((a2,b0,g))
        A.append((a1,b2,t))
      else:
        ans-=b2
        eaten[t]=True
        A.append((a2,b0,g))
        B.append((b1,a0,s))
print(ans)        
        
      
        
        
      

### FIXED CODE ###

N=int(input())
Dinner=[[int(i) for i in input().split()] for i in range(N)]
C=[Dinner[i][0]+Dinner[i][1] for i in range(N)]
C.sort(reverse=True)
ans=0
for i in range(N):
  if i%2==0:
    ans+=C[i]
  ans-=Dinner[i][1]
print(ans)
h,w = map(int,input().split())
ff = [list(input()) for _ in range(h)]

d = [[-1,-1],[0,-1],[1,-1],
     [-1, 0],       [1, 0],
     [-1, 1],[0, 1],[1, 1]]

for hi in range(h):
  for wi in range(w):
    if f[hi][wi]=='#':
      pass
    else:
      count = 0
      for dx,dy in d:
        x = dx+wi
        y = dy+hi        
        if (0<= x < w) and (0<= y <h) :
          if ff[y][x] == '#':
            count += 1
      ff[hi][wi] = str(count)
      
for fi in ff:
  print(''.join(fi))      

### FIXED CODE ###

h,w = map(int,input().split())
ff = [list(input()) for _ in range(h)]

d = [[-1,-1],[0,-1],[1,-1],
     [-1, 0],       [1, 0],
     [-1, 1],[0, 1],[1, 1]]

for hi in range(h):
  for wi in range(w):
    if ff[hi][wi]=='#':
      pass
    else:
      count = 0
      for dx,dy in d:
        x = dx+wi
        y = dy+hi        
        if (0<= x < w) and (0<= y <h) :
          if ff[y][x] == '#':
            count += 1
      ff[hi][wi] = str(count)
      
for fi in ff:
  print(''.join(fi))
enpitu = input("N ==:")
honsuu = enpitu // 10
if honsuu == 3:
	print("bon")
elif honsuu == 0, 1, 6, 8:
	print("pon")
else:
	print("hon")


### FIXED CODE ###

n = int(input()) % 10
if n == 3:
    print("bon")
elif n in {0, 1, 6, 8}:
    print("pon")
else:
    print("hon")
tasks = sorted([int(v) for v in input.split()])
print(tasks[-1]-tasks[0])


### FIXED CODE ###

tasks = sorted([int(v) for v in input().split()])
print(tasks[-1]-tasks[0])
a,b,=int(input())
if a>=10 or b>=10:
    print(-1)
    break:
else:
    print(a*b)

### FIXED CODE ###

a,b,=map(int,input().split())
if a>=10 or b>=10:
    print(-1)
else:
    print(a*b)
# import math
# import bisect
# import heapq
# from collections import deque
import numpy as np

n,m = map(int,input().split())
s,c = [0] * m, [0] * m
for i in range(m):
    s[i],c[i] = map(int,input().split())

# replace = [False] * n
ans = list('a'* n)

for i in range(m):


    if ans[s[i]-1] != 'a' and str(c[i]) != ans[s[i]-1]:
        ans = -1
        break

    ans[s[i]-1] = str(c[i])

if not ans == -1:

    for i in range(n):
        if i == 0 and ans[i] == 'a': ans[0] = '1'
        elif ans[i] == 'a': ans[i] = '0'

    print(''.join(ans))

elif len(ans) != 1 and ans[0] == 0 : print(-1)


### FIXED CODE ###

# import math
# import bisect
# import heapq
# from collections import deque
import numpy as np

n, m = map(int, input().split())
s, c = [0] * m, [0] * m
for i in range(m):
    s[i], c[i] = map(int, input().split())

# replace = [False] * n
number = ['a'] * n
ans = 0
for i in range(m):

    if number[s[i]-1] != 'a' and str(c[i]) != number[s[i]-1]:
        ans = -1
        break

    number[s[i]-1] = str(c[i])

if not ans == -1:
    for i in range(n):
        if i == 0 and number[i] == 'a' and len(number) != 1:
            number[0] = '1'
        elif number[i] == 'a':
            number[i] = '0'
    ans = ''.join(number)

    if n != 1 and number[0] == '0':
        ans = -1
print(ans)
import numpy
str = input()
lst = str.split()
a = int(lst[0])
b = int(lst[1])
c = int(lst[2])
if b > c:
    print(int(a*c/b)-int(c/b)*a)
else:
    d = int(c/b)
    lst = np.zeros(d)
    for i in range(d):
        k = b*(i+1)-1
        lst[i] = int(a*k/b)-int(k/b)*a
    print(np.max(lst))

### FIXED CODE ###

import numpy as np
str = input()
lst = str.split()
a = int(lst[0])
b = int(lst[1])
c = int(lst[2])
if b > c:
    print(int(a*c/b)-int(c/b)*a)
else:
    d = int(c/b)
    if d > 100:
      d = 100
    lst = np.zeros(d)
    for i in range(d):
        k = b*(i+1)-1
        lst[i] = int(a*k/b)-int(k/b)*a
    print(int(np.max(lst)))
#!python3

iim = lambda: map(int, input().rstrip().split())

def resolve():
    X, Y, A, B, C = iim()
    P = list(iim())
    Q = list(iim())
    R = list(iim())

    P.sort(reverse=True)
    Q.sort(reverse=True)
    R.sort(reverse=True)

    p1 = [0]*(X+1)
    for i in range(X):
        p1[i+1] = p1[i] + P[i]
    q1 = [0]*(Y+1)
    for i in range(Y):
        q1[i+1] = q1[i] + Q[i]

    si = [X-1, Y-1]
    S = [P, Q]
    if P[si[0]] < Q[si[1]]:
        idx = 0
    else:
        idx = 1
    ans = 0
    for i in range(C):
        if S[idx][si[idx]] < R[i]:
            si[idx] -= 1
            ans += R[i]
            if P[si[0]] < Q[si[1]]:
                idx = 0
            else:
                idx = 1
        else:
            break

    print(p1[si[0]+1] + q1[si[1]+1] + ans)

if __name__ == "__main__":
    resolve()


### FIXED CODE ###

#!python3

iim = lambda: map(int, input().rstrip().split())

def resolve():
    X, Y, A, B, C = iim()
    P = list(iim())
    Q = list(iim())
    R = list(iim())

    P.sort(reverse=True)
    Q.sort(reverse=True)
    R.sort(reverse=True)

    p1 = [0]*(X+1)
    for i in range(X):
        p1[i+1] = p1[i] + P[i]
    q1 = [0]*(Y+1)
    for i in range(Y):
        q1[i+1] = q1[i] + Q[i]

    si = [X-1, Y-1]
    S = [P, Q]
    if P[si[0]] < Q[si[1]]:
        idx = 0
    else:
        idx = 1
    ans = 0
    swap = True
    for i in range(C):
        if S[idx][si[idx]] < R[i]:
            si[idx] -= 1
            ans += R[i]

            if si[idx] < 0:
                idx ^= 1
                if si[idx] <= 0:
                    break
                swap = False
            elif not swap:
                continue
            elif P[si[0]] < Q[si[1]]:
                idx = 0
            else:
                idx = 1
        else:
            break

    print(p1[si[0]+1] + q1[si[1]+1] + ans)

if __name__ == "__main__":
    resolve()
import math

A, B, H, M=map(int,input().split(""))

a = int(A)
b = int(B)
h = int(H)
m = int(M)
ang = 6*m - (30*h + 0.5*m)

cosa =math.cos(ang)

c = math.sqrt(a^2 + b^2 - 2 * a * b * cosa)


print(c)


### FIXED CODE ###

import math

A, B, H, M=map(int,input().split())

ha = (M / 60 + H)*30
ma = M*6
ang = ha - ma

cosa =math.cos(ang*math.pi/180)

c = math.sqrt(A**2 + B**2 - 2 * A * B * cosa)


print(c)
a, b, c = map(str, input())

if '1' * 1 in a, b, c:
  print('1')
elif '1' * 2 in a, b, c:
  print('2')
else:
  print('3')

### FIXED CODE ###

a, b, c = map(int, input())
k = 0
for i in a, b, c:
  if i == 1:
      k += 1
  else:
      pass
print(k)
week_list = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']
rweek_list = reversed(week_list)

print(rweek_list.index(input()) + 1)

### FIXED CODE ###

week_list = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']
week_list.reverse()

print(week_list.index(input()) + 1)
n = int(input())
if n[1] == n[2]:
    if n[0] == n[1] or n[2] == n[3]:
        print('Yes')
else:
    print('No')

### FIXED CODE ###

n = input()
if n[1] == n[2]:
    if n[0] == n[1] or n[2] == n[3]:
        print("Yes")
        exit()
print("No")
n = int(input())
h = list(map(int, input().split()))
for i in range(1,n+1):
  if h[-i] >= h[-i-1]:
    continue
  elif h[-i-1] - h[-i] == 1:
    h[-i-1] -= 1
  else:
    print("No")
    break
else:
  print("Yes")

### FIXED CODE ###

n = int(input())
h = list(map(int, input().split()))
for i in range(n-1):
  if h[n-1-i] >= h[n-2-i]:
    continue
  elif h[n-2-i] - h[n-1-i] == 1:
    h[n-2-i] -= 1
  else:
    print("No")
    break
else:
  print("Yes")
# -*- coding: utf-8 -*-
import functools
import math
n = input()
monster = list(map(int,input().split()))

gcd = functools.reduce(math.gcd, monster)
print(gcd)


### FIXED CODE ###

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

def gcd(a,b):
    if b==0:return a
    return gcd(b,a%b)

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


if n==1:
    print(x[0])
else:
    element = gcd(x[0], x[1])
    if n==2:print(element)
    else:
        for i in range(2,n):
            element=gcd(element,x[i])
        print(element)
N = int(input())
a = []
ball = []
while N != len(a):
    a.append(int(input()))
    ball.append(0)
i = N
ballcount = 0
check = 2
out = 0
while i != 0 and out != N + 1:
    while check * i <= N: 
        ballcount += ball[check * i - 1]
        check += 1
    if ballcount % 2 != a[i - 1]:
        ball[i - 1] = 1
    check = 2
    i -= 1
    ballcount = 0
    out += 1
if out == N + 1:
    i = out
    print(-1)
M = 0
while i < N:
    if ball[i] == 1:
        M += 1
    i += 1
print(M)
i = 0
while i < N:
    if ball[i] == 1:
        print(i + 1)
    i += 1

### FIXED CODE ###

N = int(input())
a = list(map(int, input().split()))
ball = [0 for c in range(N)]
i = N
ballcount = 0
check = 2
out = 0
while i != 0 and out != N + 1:
    while check * i <= N: 
        ballcount += ball[check * i - 1]
        check += 1
    if ballcount % 2 != a[i - 1]:
        ball[i - 1] = 1
    check = 2
    i -= 1
    ballcount = 0
    out += 1
if out == N + 1:
    i = out
    print(-1)
M = 0
while i < N:
    if ball[i] == 1:
        M += 1
    i += 1
print(M)
i = 0
while i < N:
    if ball[i] == 1:
        print(i + 1)
    i += 1
from collections import deque
import sys
sys.setrecursionlimit(10**7)
N,M=map(int,input().split())
A=[]
B=[]
road=[[] for i in range(N)]
for i in range(N):
  a,b=map(int,input().split())
  road[a-1].append(b-1)
  road[b-1].append(a-1)
visit=[0]*N

q=deque([0])
ans=[0]*N
visit[0]=1
def bfs(q):
  while(q):
    v=q.popleft()
    #print(v)
    for x in road[v]:
      if(visit[x]==0):
        q.append(x)
        #print(q)
        visit[x]=1
        ans[x]=v+1
        #print(x)
bfs(q)
print("Yes")
for i in range(N-1):
  print(ans[i+1])

### FIXED CODE ###

from collections import deque
import sys
sys.setrecursionlimit(10**7)
N,M=map(int,input().split())
A=[]
B=[]
road=[[] for i in range(N)]
for i in range(M):
  a,b=map(int,input().split())
  road[a-1].append(b-1)
  road[b-1].append(a-1)
visit=[0]*N

q=deque([0])
ans=[0]*N
visit[0]=1
def bfs(q):
  while(q):
    v=q.popleft()
    #print(v)
    for x in road[v]:
      if(visit[x]==0):
        q.append(x)
        #print(q)
        visit[x]=1
        ans[x]=v+1
        #print(x)
bfs(q)
print("Yes")
for i in range(N-1):
  print(ans[i+1])
import math
import sys

for line in sys.stdin:
	x,y = [int(s) for s in line.split(' ')]
	g = math.gcd(x,y)

	a = set()
	b = set()
	i = 1
	while not a & b:
		a = a | {x*i}
		b = b | {y*i}
		i += 1

	ab = a & b
	print(g,*ab)

### FIXED CODE ###

def pd(n):
    i = 2
    ans = []
    while i ** 2 <= n:
        while n % i == 0:
            n /= i
            ans.append(i)
        i += 1
    if n > 1:
        ans.append(n)
    return ans

def gcd(a, b):
    gcd = 1
    pd_a = pd(a)
    pd_b = pd(b)
    for i in pd_a:
        if i in pd_b:
            pd_b.remove(i)
            gcd *= i
    return int(gcd)

def lcm(a, b):
    lcm = a
    pd_a = pd(a)
    pd_b = pd(b)
    for i in pd_a:
        if i in pd_b:
            pd_b.remove(i)
    for j in pd_b:
        lcm *= j
    return int(lcm)

while True:
    try:
        s = input()
        a,b = [int(i) for i in s.split(' ')]
    except:
        break
    print(gcd(a, b), lcm(a, b))
N = int(input())

A = list(map(int, input().split()))
Ans = 0

for i in range(N):
    v += 1 / a[i]
print(1 / Ans)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
 
ans = 0
 
for i in range(N):
    ans = ans + 1 / A[i]
 
ans = 1 / ans 
 
print(ans)
A,B= map(int, input().split())
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(A, B))

### FIXED CODE ###

A,B= map(int, input().split())
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a

def lcm(x, y):
    return (x * y) // gcd(x, y)

print(lcm(A, B))
a, b, k = map(int, input().split())
l = list(range(a, b+1))
for i in sorted(list(set(l[:k] + l[-k:]))):
    print(i)

### FIXED CODE ###

a, b, k = map(int, input().split())
for i in range(a, min(b+1, a+k)):
    print(i)
for i in range(max(b-k+1, a+k), b+1):
    print(i)
n=str(input())
t='nt'
for(i in range(n)):
  if(n[i]=='7'):
    print("Yes")
    t='tr'
if(t='nt'):
  print("No")

### FIXED CODE ###

n=input()
n=str(n)
t='nd'
for i in n:
    if i=='7':
        print('Yes')
        t='d'
        break
if t=='nd':print('No')
a=int(input())
b=int(input())
ans="Even" if (a * b % 2) == 0 else "Odd"
print(ans)


### FIXED CODE ###

a,b=map(int,input().split())
ans="Even" if (a * b % 2) == 0 else "Odd"
print(ans)
N = int(input())
a = 0

for i in range (1,N+1):
    if i % 15 == 0 :
        a = 'FizzBuzz'
    elif i % 3 == 0:
        a = 'Fizz'
    elif i % 5 == 0:
        a = 'Buzz'
    else:
         a + i


### FIXED CODE ###

total = []

N = int(input())

for i in range(1, N + 1):
    if i % 3 == 0 and i % 5 == 0:
        pass
    elif i % 3 == 0:
        pass
    elif i % 5 == 0:
        pass
    else:
        total.append(i)

print(sum(total))
flag = True
S = input()
for i in range(1,len(S)):
  if S[i] == S[i-1]:
    flag = False

if flag:
  print("Good"):
else:
  print("Bad")
      
      

### FIXED CODE ###

flag = True
S = input()
for i in range(1,len(S)):
  if S[i] == S[i-1]:
    flag = False

if flag:
  print("Good")
else:
  print("Bad")
W, H, x, y = map(int, input().split())
bigarea = W * H

j = (bigarea/2.000000)

# print('{:6f}'.format(bigarea/2))

if j % 2 ==0:
    k = '1'
elif W /2 == x and H / 2 == y:
    k = '0'

if x == 0 and y == 0:
    j = 0

# print(j, k)
# j = str(j)
print('{:6f} {:}'.format(j,k))

### FIXED CODE ###

W, H, x, y = map(int, input().split())
bigarea = W * H

j = (bigarea/2.000000)

# print('{:6f}'.format(bigarea/2))

if W /2 == x and H / 2 == y:
    k = '1'
else:
    k = '0'

# print(j, k)
# j = str(j)
print('{:6f} {:}'.format(j,k))
while 1:
    x, y = map(int, raw_input().split())
    if x == 0 and y == 0:
        break
    print min(x, y) max(x, y)

### FIXED CODE ###

while 1:
    x, y = map(int, raw_input().split())
    if x == 0 and y == 0:
        break
    print min(x, y), 
    print max(x, y)
# C - Skip

import numpy as np
import math

N, X = map(int, input().split())
x = list(int(x) for x in input().split())
x.append(X)
x.sort()
x = np.array(x)
x = x - x[0]

ans = 10**18
if N == 1:
    print(x[1] - x[0])
else:
    for i in range(N-1):
        ans = min(ans, math.gcd(x[i], x[i+1]))
    print(ans)

### FIXED CODE ###

# C - Skip

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

N, X = map(int, input().split())
x = list(int(x) for x in input().split())
x.append(X)
x.sort()
stnd = x[0]
for i in range(N+1):
    x[i] -= stnd

ans = gcd(x[0], x[1])
for i in range(1, N):
    ans = gcd(ans, gcd(x[i], x[i+1]))
print(ans)
import math
n=int(input())
a=sorted([list(map(int,input().split())) for i in range(n)])
b=sorted(a,key=lambda x:x[1])
if n%2==1:
    print(b[n//2][1]-a[n//2][0]+1)
else:
    print((b[n//2-1][1]+b[n//2][1])-(a[n//2-1][0]-a[n//2][0]))//2)

### FIXED CODE ###

n=int(input())
a=sorted([list(map(int,input().split())) for i in range(n)])
b=sorted(a,key=lambda x:x[1])
if n%2==1:
    print(b[n//2][1]-a[n//2][0]+1)
else:
    print((b[n//2-1][1]+b[n//2][1])-(a[n//2-1][0]+a[n//2][0])+1)
n,m,x=map(int,input().split())
la=list(map(int,input().split()))
n,m,x=map(int,input().split())
la=list(map(int,input().split()))
count1=0
count2=0
while x>=0:
    for i in la:
        if x==i:
            count1+=1
    x-=1
while x<=n:
    for i in la:
        if x==i:
            count2+=1
    x+=1
if count2>count1:
    print(count1)
else:
    print(count2)

### FIXED CODE ###

n,m,x=map(int,input().split())
la=list(map(int,input().split()))
count1=0
count2=0
y=x
while y>=0:
    for i in la:
        if y==i:
            count1+=1
    y-=1

while x<=n:
    for i in la:
        if x==i:
            count2+=1
    x+=1
if count2>count1:
    print(count1)
else:
    print(count2)
def lcs(x,y):
    x = " " + x
    y = " " + y    
    c = [[0]*(len(x)+1)]*(len(y)+1)
#    for i in xrange (len(x)-1):
#        c[i][0] = 0
#    for j in xrange (len(y)-1):
#        c[0][j] = 0
    for i in xrange (len(x)):
        for j in xrange (len(y)):
            if i >= 1 and j >= 1 and x[i] == y[j]:
                c[i][j] = c[i-1][j-1] + 1
            elif i >= 1 and j >= 1 and x[i] != y[j]:
                c[i][j] = max(c[i][j-1],c[i-1][j])
    return max(max(c))

n = input()

for i in xrange (n):

 x = raw_input()
 y = raw_input()

 print lcs(x,y)

### FIXED CODE ###

def lcs():
    x, y = raw_input(), raw_input()
    b1 = [0 for k in range(len(y)+1)]
    for i in xrange(len(x)):
        a = x[i]
        b2 = b1 + []
        for j in xrange(len(y)):
            if a == y[j]:
                b1[j+1] = b2[j] + 1
            elif b1[j+1] < b1[j]:
                b1[j+1] = b1[j]
    print max(b1)
 
n = input()
for i in xrange(n):
    lcs()