Harryxun/stf_run huggingface dataset:
N=int(input())
*V,=map(int,input().split())
import collections import Counter

c1=Counter(V[0::2]).most_common()+[(0,0)]
c2=Counter(V[1::2]).most_common()+[(0,0)]
if c1[0][0]!=c2[0][0]:
    print(N-c1[0][1]-c2[0][1])
else:
    print(min(N-c1[0][1]-c2[1][1],N-c1[1][1]-c2[0][1]))

### FIXED CODE ###

N=int(input())
*V,=map(int,input().split())
import collections

import collections

c1=collections.Counter(V[0::2])
c1=sorted(c1.items(), key=lambda x: x[1], reverse=True)
e=c1[0][0]

c2=collections.Counter(V[1::2])
c2=sorted(c2.items(), key=lambda x: x[1], reverse=True)
o=c2[0][0]

cnt=0
if e!=o:
    cnt=sum(e!=i for i in V[0::2])
    cnt+=sum(o!=i for i in V[1::2])
else:
    if len(c1)==1 and len(c2)==1:
        cnt=N//2
    elif len(c1)==1:
        cnt1=sum(e!=i for i in V[0::2])
        cnt1+=sum(c2[1][0]!=i for i in V[1::2])
        
        cnt2=sum(e!=i for i in V[0::2])
        cnt2+=sum(c2[1][1]!=i for i in V[1::2])
        cnt=min(cnt1,cnt2)
    elif len(c2)==1:
        cnt1=sum(c1[1][0]!=i for i in V[0::2])
        cnt1+=sum(o!=i for i in V[1::2])

        cnt2=sum(c1[1][1]!=i for i in V[0::2])
        cnt2+=sum(o!=i for i in V[1::2])
        cnt=min(cnt1,cnt2)
    else:    
        cnt1=sum(e!=i for i in V[0::2])
        cnt1+=sum(c2[1][0]!=i for i in V[1::2])
        
        cnt2=sum(c1[1][0]!=i for i in V[0::2])
        cnt2+=sum(o!=i for i in V[1::2])
        cnt=min(cnt1,cnt2)
print(cnt)
n=int(input())

if n==1:
  print(2)
elif n==2:
  print(1)
else:
  ans=0
  num_1=2
  num_2=1
  for i in range(n-1):
    ans = num_1+num_2
    num_1,num_2 = num_2, ans

print(ans)

### FIXED CODE ###

n=int(input())

if n==1:
  print(1)
elif n==2:
  print(3)
else:
  ans=0
  num_1=2
  num_2=1
  for i in range(n-1):
    ans = num_1+num_2
    num_1,num_2 = num_2, ans
  print(ans)
admission = []
n = int(input())
admission.append(map(int,input().split()))

for i in range(n-1):
    if admission[n-1] % 2 == 0:
        if admission[n-1] % 3 == 0 or admission[n-1] % 5 == 0:
            print("APPROVED")
        else:
            print("DENIED")

### FIXED CODE ###

n = int(input())
a = map(int,input().split())
for l in a:
    if l % 2 ==0:
        if l % 3 == 0 or l % 5 == 0:
            continue
        else:
            print("DENIED")
            quit()
print("APPROVED")
from collections import Counter
n = int(input())
s = [list(map(int,input().split())) for i in range(n)]

t1 = []
for i in range(n):
    t1.append(str(s[i][0])+" "+str(s[i][1]))


t3 = Counter(t1)
t2 = list(set(t1))
c = []
for i in range(len(t2)):
    for j in range(i+1,n):
        x = abs(int(t2[j][0]) - int(t2[i][0]))
        y = abs(int(t2[j][2]) - int(t2[i][2]))
        e = min(t3[t2[i]],t3[t2[j]])
        for l in range(e):
            c.append(str(x) + " " + str(y))


r = Counter(c)
q = list(r.values())
q1 = max(q)
print(n-q1)


### FIXED CODE ###

from collections import defaultdict
n = int(input())
s = [list(map(int,input().split())) for i in range(n)]
s.sort()
c = []
if n == 1:
    print(1)
else:
    for i in range(n):
        for j in range(i+1,n):
            x = s[j][0] - s[i][0]
            y = s[j][1] - s[i][1]
            c.append(str(x) + " " + str(y))
    r = defaultdict(int)
    for g in c:
        r[g] += 1
    q = list(r.values())
    q1 = max(q)
    print(n-q1)
M1,D1 = map(int,input().split())
M2,D2 = map(int,input().split())

if D2 == 1:
  print 1
else:
  print 0


### FIXED CODE ###

M1, D1 = map(int, input().split())
M2, D2 = map(int, input().split())

if D2 == 1:
    print(1)
else:
    print(0)
W , H, x, y、r = map(int, input().split())

if r <= x and x <= (W -r) and r <= y and y<= (H -r):

    print("Yes")

else:
    print("No")



### FIXED CODE ###

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

if r <= x and x <= (W - r):
    if r <= y and y <= (H - r):
        print("Yes")
    else:
        print("No")

else:
    print("No")
N=input()
print("Yes" if N[0]=N[2] else "No")

### FIXED CODE ###

N=input()
print("Yes" if N[0]==N[2] else "No")
A=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
n=int(input())
s=str(input())
x=n%26
for i in range(len(A)):
  for j in range(25):
    if s[i]==A[j]:
      if j+x<=25:
        s[i]=A[j+x]
        break
      else:
        s[i]=A[j+x-26]
        break

print(s)

### FIXED CODE ###

A=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
n=int(input())
s=str(input())
t=""
for i in range(len(s)):
  for j in range(26):
    if s[i]==A[j]:
      if j+n<=25:
        t+=A[j+n]
        break
      else:
        t+=A[j+n-26]
        break

print(t)
# -*- Coding: utf-8 -*-

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

if k == 0:
    print('{0} {1}'.format(a,b))
    exit(1)

if k >= a:
    k = k-a
    a = 0
else:
    a = a - k
    k = 0

if k == 0:
    print('{0} {1}'.format(a,b))
    exit(1)
else:
    if k >= b:
        b = 0
        print('{0} {1}'.format(a,b))
        exit(1)
    else:
        b = b - k
        print('{0} {1}'.format(a,b))

### FIXED CODE ###

# -*- Coding: utf-8 -*-

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

if k >= (a+b):
    print('{0} {1}'.format(0,0))
elif k < a:
    print('{0} {1}'.format(a-k, b))
elif k >= a:
    print('{0} {1}'.format(0, b-(k-a)))
input()
S=input()
k=int(input())
for s in S:print(s if s == S[k-1] else '*',sep='')


### FIXED CODE ###

a,b,c=map(int,input().split())
print('Yes' if a<c<b or a>c>b else 'No')
x,n=map(int,input().split())
try:
    p=list(map(int,input().split()))
    p.sort()
    min=abs(p[0])
    for i in range(p[n-1]):
        if i not in p:
            if min>abs(i-x):
                min=abs(i-x)
                ans=i
except:
    ans=x
print(ans)

### FIXED CODE ###

x, n = map(int, input().split())
a = [int(x) for x in input().split()]
b = [i for i in range(0,102) if i not in a] 
b_tmp = list(map(lambda s:abs(s-x), b)) 
address = b_tmp.index(min(b_tmp))
print(b[address])
N, W = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]

dp = [[0] * (W + 1) for _ in range(N + 1)]
dp[0][0] = 0
for i in range(N):
    for j in range(W + 1):
        if j < X[i][0]:
            dp[i + 1][j] = dp[i][j]
        else:
            dp[i + 1][j] = max(dp[i][j], dp[i][j - X[i][0]] + X[i][1])

print(dp[-1][-1])


### FIXED CODE ###

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

w0 = X[0][0]
ctr = [[] for _ in range(4)]
for w, v in X:
    ctr[w - w0].append(v)

for n in range(4):
    values = sorted(ctr[n], reverse=True)
    s = [0] * (len(values) + 1)
    for i in range(len(values)):
        s[i + 1] = s[i] + values[i]
    ctr[n] = s

ans = 0
for i in range(len(ctr[0])):
    for j in range(len(ctr[1])):
        for k in range(len(ctr[2])):
            for l in range(len(ctr[3])):
                tmp = ctr[0][i] + ctr[1][j] + ctr[2][k] + ctr[3][l]
                w = w0 * i + (w0 + 1) * j + (w0 + 2) * k + (w0 + 3) * l
                if w <= W:
                    ans = max(ans, tmp)

print(ans)
import queue
h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]
q = queue.Queue()
INF = float('inf')
counts = [[INF]*w for _ in range(h)]
ans = 0
for i in range(h):
    for j in range(w):
        if a[j][i] == '#':
            q.put([i, j, 0])
            counts[j][i] = 0
            
while not q.empty():
    x, y, z = q.get()
    ans = z
    for i, j in ((1, 0), (-1, 0), (0, 1), (0, -1)):
        x0 = x+i
        y0 = y+j
        if 0 <= x0 < w and 0 <= y0 < h:
            if counts[y][x]+1 < counts[y0][x0]:# and a[y0][x0] == '.':
                a[y0][x0] = '#'
                counts[y0][x0] = counts[y][x]+1
                q.put([x0, y0, counts[y0][x0]], z)
print(ans)


### FIXED CODE ###

from collections import deque

def cal():
    h, w = map(int, input().split())
    q = deque()
    counts = [[True for _ in range(w+2)]]+[[True]+[False]*w+[True] for _ in range(h)]+[[True for _ in range(w+2)]]
    for i in range(h):
        a = input()
        for j in range(w):
            if a[j] == '#':
                q.append([i+1, j+1, 0])
                counts[i+1][j+1] = True

    while q:
        x, y, z = q.popleft()    
        if not counts[x+1][y]:
            counts[x+1][y] = True
            q.append([x+1, y, z+1])
        if not counts[x-1][y]:
            counts[x-1][y] = True
            q.append([x-1, y, z+1])
        if not counts[x][y+1]:
            counts[x][y+1] = True
            q.append([x, y+1, z+1])
        if not counts[x][y-1]:
            counts[x][y-1] = True
            q.append([x, y-1, z+1])
    print(z)
    

cal()
I = list(map(int,input().split()))
if I(0)%2 = 1 :
    A = 'No' 
else:
    H＝I(1)[:I 0)/2]
    if I(1) = H + H :
        A = 'Yes'
    else:
        A = 'No'

print(A)

### FIXED CODE ###

I = [input() for i in range(2)]
sn = int(I[0])
ss = str(I[1])
if sn%2 == 1 :
    A = 'No' 
else:
    sl = int(sn/2) 
    # print(sl)
    if sl >= 2 : 
        H1 = ss[:sl]
        H2 = ss[sl:]
    #     print(H1)
    #     print(H2)
    elif sl == 1 :
        H1 = str(ss[0])
        H2 = str(ss[1])
    if  H1 == H2 :
        A = 'Yes'
    else:
        A = 'No'
print(A)
weathers = [
        'Sunny',
        'Cloudy',
        'Rainy'
    ]

    s = str(input())

    index = 0
    next_index = 0

    for w in weathers:
        if w == s:
            next_index = (index + 1) % 3
            break
        else:
            index += 1

    print(weathers[next_index])

### FIXED CODE ###

if __name__ == '__main__':
    weathers = [
        'Sunny',
        'Cloudy',
        'Rainy'
    ]

    s = str(input())

    index = 0
    next_index = 0

    for w in weathers:
        if w == s:
            next_index = (index + 1) % 3
            break
        else:
            index += 1

    print(weathers[next_index])
from collections import deque

num_r,num_c = map(int,input().split())
field = [input() for i in range(num_r)]
q = deque([])
seen = [0]*(num_c*num_r)
step_r = [1,0,-1,0]
step_c = [0,1,0,-1]

for i in range(num_r):
  for j in range(num_c):
    if field[i][j] == "#":
      q.append([i,j])

while q:
  now_q = q.popleft()
  r = now_q[0]
  c = now_q[1]

  for i in range(4):
    next_r = r + step_r[i]
    next_c = c + step_c[i]
    
    if (0 <= next_r < num_r) and (0 <= next_c < num_c) and (field[next_r][next_c] != "#") and (seen[next_r*num_c+next_c] == 0):
      q.append([next_r,next_c])
      seen[next_r*num_c+next_c] = seen[r*num_c+c] + 1
  #    print(seen[next_r][next_c],next_r,next_c)
      g_r = next_r
      g_c = next_c

print(int(seen[g_r*num_c+g_c]))

### FIXED CODE ###

def main():
    h,w = map(int,input().split())
    a = []
    for i in range(h):
        a.append(input())

    used = [True]*(h*w)

    p = []
    for i in range(h):
        for j in range(w):
            if a[i][j] == '#':
                p.append(i*w+j)
                used[i*w+j] = False


    
    res = 0
    while p:
        tank = []
        for e in p:
            if e>w-1 and used[e-w]:
                tank.append(e-w)
                used[e-w] = False
            if e%w > 0 and used[e-1]:
                tank.append(e-1)
                used[e-1] = False
            if e<(h-1)*w and used[e+w]:
                tank.append(e+w)
                used[e+w] = False
            if e%w<w-1 and used[e+1]:
                tank.append(e+1)
                used[e+1] =  False
        p = tank
        res += 1
    print(res-1)

if __name__ == '__main__':
    main()
x=int (input())

i=0

while(x=<100((1+0.01)**i){
  i=i+1
}


print(i)
      


### FIXED CODE ###

X=int(input())
total,Y=100,0
while X>total:
  total=total*101//100
  Y=Y+1
print(Y)
S = input()

count = 1
answer = [0] * len(S)
# RLの切り替わるインデックスをマーク
n = 0
for i in range(len(S) - 1):
    if (S[i] == S[i + 1]):
        count += 1
    else:
        if (S[i + 1] == 'R'):
            # Lを割り振る
            answer[n] += count // 2
            answer[n + 1] += -(-count // 2)
            count = 1
        else:
            # Rを割り振る
            answer[i] += -(-count // 2)
            answer[i + 1] += count // 2
            count = 1
            n = i
    # 右端のLを割り振る
    if (i == len(S) - 2):
        answer[n] += count // 2
        answer[n + 1] += -(-count // 2)

for c in answer:
    print(f"{c} ", end='')
print()


### FIXED CODE ###

inputNum = list(map(int, input().split()))

A = inputNum[0]
B = inputNum[1]
C = inputNum[2]

if ((C - (A - B)) > 0):
    print(C - (A - B))
else:
    print(0)
from math import gcd

a, b = map(int, input().split())
print((a * b) // gcd(a, b))

### FIXED CODE ###

from fractions import gcd
a, b = map(int, input().split())
print(int((a * b) / gcd(a, b)))
N, X = [int(_) for _ in input().split()]
x = [int(_) for _ in input().split()]

def gcd_list(numbers):
    if len(numbers) == 1:
        return abs(numbers[0])
    if len(numbers) == 2:
        return gcd(numbers[0], numbers[1])
    else:
        return gcd_list([gcd(numbers[0], numbers[1])] + numbers[2:])

def gcd(p, q):
    if p < 0:
        return gcd(-p, q)
    if q < 0:
        return gcd(p, -q)
    if q > p:
        return gcd(q, p)
    if p % q == 0:
        return q
    else:
        return gcd(q, p % q)

xmod = [_ - X for _ in x]
print(gcd_list(xmod))

### FIXED CODE ###

N, X = [int(_) for _ in input().split()]
xs = [abs(int(_) - X) for _ in input().split()]

def gcd(p, q):
    while q != 0:
        p, q = q, p % q
    return p

y = xs[0]
for i in range(N):
    if xs[i] % y != 0:
        y = gcd(y, xs[i])

print(y)
N=input()
print('Yes' if N[0]==N[1]==N[2] or N[1]==N[2]==M[3] else 'No')

### FIXED CODE ###

N=input()
print('Yes' if N[0]==N[1]==N[2] or N[1]==N[2]==N[3] else 'No')
N, M = (int(x) for x in input().split())
k = {}
j = True
ans = []

for i in range(M):
    ans.append("0")
    a, b = input().split()
    a = int(a)
    if a not in k.keys():
        k[a] = b
    else:
        if k[a] != b:
            j = False
            break

for n in range(N):
    if n + 1 in k.keys():
        ans[n] = k[n + 1]

if j:
    f = "".join(ans)
    print(int(f))
else:
    print(-1)

### FIXED CODE ###

def main():
    N, M = (int(x) for x in input().split())
    SC = [list(map(int, input().split())) for _ in range(M)]
    for i in range(10 ** N):
        _str = str(i)
        k = True
        if len(_str) == N:
            for j in range(M):
                if _str[SC[j][0]-1] != str(SC[j][1]):
                    k = False
            if k:
                return print(i)
    return print('-1')

if __name__ == "__main__":
    main()
a, b = input().split()
if a >= b:
  print(a*int(b))
  break
else:
  print(b*int(a))

### FIXED CODE ###

a, b = input().split()
print(a*int(b) if a < b else b*int(a))
N, R = list(map(int, input().split(' ')))
if N >= 10:
    print(R)
else:
    print(R + (100 - (10 - K)))

### FIXED CODE ###

N, R = list(map(int, input().split(' ')))
if N >= 10:
    print(R)
else:
    print(R + (100 * (10 - N)))
a,b=raw_input().split()
print a*b, (a+b)<<1

### FIXED CODE ###

a,b=map(int, raw_input().split())
print a*b, (a+b)<<1
# input
N, M, K = map(int, input().split())

Frends = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if a < b:
        Frends[a].append(b)
    else:
        Frends[b].append(a)

Blocked = [[] for _ in range(N)]
for _ in range(K):
    c, d = map(int, input().split())
    c -= 1
    d -= 1
    if c < d:
        Blocked[c].append(d)
    else:
        Blocked[d].append(c)

# process
# 友人グループを作成
fg = []
for i in range (N):
    fs = Frends[i]
    for f in fs:
        t = -1
        for j in range(len(fg)):
            g = fg[j]
            if i in g and f in g:
                if t < 0:
                    t = j              
                else:
                    fg[t] = fg[t] | g
                    fg.remove(g)
            elif not (i in g or f in g):
                continue
            else:
                if t < 0:
                    if i in g:
                        g.add(f)
                    else:
                        g.add(i)

                    t = j
                else:
                    fg[t] = fg[t] | g
                    fg.remove(g)

        if t < 0:
            fg.append(set([i, f]))

#print(fg)

# 友人候補を抽出
cand = []
for i in range(N):
    for g in fg:
        if i in g:
            for f in g:
                if i < f and not f in Frends[i] and not f in Blocked[i]:
                    cand.append((i, f,))

#print(cand)

# 友人候補をカウント
ans = [0 for _ in range(N)]
for c in cand:
    a, b = c
    ans[a] += 1
    ans[b] += 1

# output
print(" ".join(map(str, ans)))


### FIXED CODE ###

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

Friends = [set() for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    Friends[a].add(b)
    Friends[b].add(a)

Blocked = [set() for _ in range(N)]
for _ in range(K):
    c, d = map(int, input().split())
    c -= 1
    d -= 1
    Blocked[c].add(d)
    Blocked[d].add(c)

# process
# 友人グループを作成
checked = set()
ans = [0]*N

for i in range (N):
    if i in checked:
        continue
    
    fg = set()

    stack = list(Friends[i])
    while stack:
        f = stack.pop()
        if f in checked:
            continue

        checked.add(f)
        fg.add(f)
        stack.extend(Friends[f])

    for f in fg:
        ans[f] += len(fg)-1-len(fg&(Friends[f]|Blocked[f]))

# output
print(" ".join(map(str, ans)))
S,T=input().split()
A,B map(int, input().split())
U = input()
if S==U:
  print(A-1,B)
elif T==U:
  print(A,B-1)

### FIXED CODE ###

S, T = input().split()
A, B= map(int, input().split())
U = input()
if S == U:
    print(A - 1, B)
else:
    print(A, B - 1)
def sigma4jou(k):
    total = 0
    for i in range(k):
        total += 4 ** (i)
    return(total)

def pketa(N):
    k = 1
    while N - sigma4jou(k) > 0:
        k += 1
    return(2 * k - 1)

def mketa(N):
    k = 1
    while N + 2 * sigma4jou(k) < 0:
        k += 1
    return(2 * k)

def getResult(N):
    result = ""
    if N == 0:
        result += "0"
    elif N > 0:
        k = pketa(N)
        for i in range(k, 0, -2):
            j = int((i+1)/2)
            if abs((sigma4jou(j) - N) // (2 ** (i-1))) % 2 == 0:
                result += "1"
            else:
                result += "0"
            if i > 1:
                if abs(((sigma4jou(j) - N)) // (2 ** (i-2))) % 2 == 1:
                    result += "1"
                else:
                    result += "0"
    elif N < 0:
        k = mketa(N)
        for i in range(k, 0, -2):
            j = int(i/2)
            if abs((N + 2 * sigma4jou(j)) // (2 ** (i-1))) % 2 == 0:
                result += "1"
            else:
                result += "0"
            if i > 1:
                if abs(((N + 2 * sigma4jou(j))) // (2 ** (i-2))) % 2 == 1:
                    result += "1"
                else:
                    result += "0"
    return(result)

N = input()
print(getResult(N))

### FIXED CODE ###

def sigma4jou(k):
    total = 0
    for i in range(k):
        total += 4 ** (i)
    return(total)

def pketa(N):
    k = 1
    while N - sigma4jou(k) > 0:
        k += 1
    return(2 * k - 1)

def mketa(N):
    k = 1
    while N + 2 * sigma4jou(k) < 0:
        k += 1
    return(2 * k)

def getResult(N):
    result = ""
    if N == 0:
        result += "0"
    elif N > 0:
        k = pketa(N)
        for i in range(k, 0, -2):
            j = int((i+1)/2)
            if abs((sigma4jou(j) - N) // (2 ** (i-1))) % 2 == 0:
                result += "1"
            else:
                result += "0"
            if i > 1:
                if abs(((sigma4jou(j) - N)) // (2 ** (i-2))) % 2 == 1:
                    result += "1"
                else:
                    result += "0"
    elif N < 0:
        k = mketa(N)
        for i in range(k, 0, -2):
            j = int(i/2)
            if abs((N + 2 * sigma4jou(j)) // (2 ** (i-1))) % 2 == 0:
                result += "1"
            else:
                result += "0"
            if i > 1:
                if abs(((N + 2 * sigma4jou(j))) // (2 ** (i-2))) % 2 == 1:
                    result += "1"
                else:
                    result += "0"
    return(result)

N = int(input())
print(getResult(N))
import sys
def input():
    return sys.stdin.readline()[:-1]
inf=float("inf")
class UnionFind:
    def __init__(self, n):
        # 親要素のノード番号を格納。par[x] == xの時そのノードは根
        self.par = [i for i in range(n+1)]
        # 木の高さを格納する（初期状態では0）
        self.rank = [0] * (n+1)

    # 検索
    # 根ならその番号を返す
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            # 走査していく過程で親を書き換える
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

    # 併合
    def union(self, x, y):
        # 根を探す
        x = self.find(x)
        y = self.find(y)
        # 木の高さを比較し、低いほうから高いほうに辺を張る
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            # 木の高さが同じなら片方を1増やす
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

n,m=map(int,input().split())
kl=[list(map(int,input().split())) for i in range(n)]
uf=UnionFind(m)
for i in range(n):
    for j in range(2,kl[i][0]+1):    
        uf.union(kl[i][1], kl[i][j])

flag=uf.par[1]
for i in range(2,n):
    if flag!=uf.par[i]:
        print("NO")
        quit()
print("YES")

### FIXED CODE ###

import sys
def input():
    return sys.stdin.readline()[:-1]
inf=float("inf")
class UnionFind:
    def __init__(self, n):
        # 親要素のノード番号を格納。par[x] == xの時そのノードは根
        self.par = [i for i in range(n+1)]
        # 木の高さを格納する（初期状態では0）
        self.rank = [0] * (n+1)

    # 検索
    # 根ならその番号を返す
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            # 走査していく過程で親を書き換える
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

    # 併合
    def union(self, x, y):
        # 根を探す
        x = self.find(x)
        y = self.find(y)
        # 木の高さを比較し、低いほうから高いほうに辺を張る
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            # 木の高さが同じなら片方を1増やす
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

n,m=map(int,input().split())
kl=[list(map(int,input().split())) for i in range(n)]
uf=UnionFind(m)
for i in range(n):
    for j in range(2,kl[i][0]+1):    
        uf.union(kl[i][1], kl[i][j])

for i in range(1,n):
    if not uf.same_check(kl[0][1],kl[i][1]):
        print("NO")
        quit()
print("YES")
count = 1
tmpp, tmpq = 0, 0
li = []

for i in range(1, n + 1):
    li.append(i)

pattern = list(itertools.permutations(li))

for i in pattern:
    if i == p:
        tmpp = count

    if i == q:
        tmpq = count

    count += 1

print(abs(tmpp - tmpq))


### FIXED CODE ###

import itertools

n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))

count = 1
tmpp, tmpq = 0, 0
li = []

for i in range(1, n + 1):
    li.append(i)

pattern = list(itertools.permutations(li))

for i in pattern:
    if i == p:
        tmpp = count

    if i == q:
        tmpq = count

    count += 1

print(abs(tmpp - tmpq))
A,B = map(int,input().split())

print('{}'.format(max([A+B,A-B,A*B,A/B])))

### FIXED CODE ###

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

print('{}'.format(max([A+B,A-B,A*B])))
import math

def lcm(x, y):
    if math.gcd(x, y) == 0:
        return 0
    return x * y // math.gcd(x, y)

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



### FIXED CODE ###

from fractions import gcd

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

print(A * B // gcd(A, B))
n = int(input())
k = input().split()
c = ""
for i in list(range(2)):
  c += k[0][i]
  c += k[1][i]
  
print(c)

### FIXED CODE ###

n = int(input())
k = input().split()
c = ""
for i in list(range(n)):
  c += k[0][i]
  c += k[1][i]
  
print(c)