Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

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

D = [ [int(i) for i in input().split()] for _ in range(C) ]
c = [ [int(i) for i in input().split()] for _ in range(N) ]

costD = [ [0, 0, 0] for _ in range(C)]

for c0 in range(C):
    for i in range(N):
        for j in range(N):
            costD[c0][(i+j)%3] += D[c[i][j]-1][c0]

kohoD = []

for c1 in range(C):
    for c2 in range(C):
        if c1 == c2:
            continue
        for c3 in range(C):
            if c1 == c3 or c2 == c3:
                continue
            kohoD += [(costD[c1][0] + costD[c2][1] + costD[c3][2])]

print(min(kohoD))


### FIXED CODE ###

import itertools
 
 
def main():
    N, C = map(int, input().split())
    D = [list(map(int, input().split())) for _ in range(C)]
    CC = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(N)]
 
    cost = [[0 for _ in range(C)] for _ in range(3)]
    for c in range(C):
        for i in range(N):
            for j in range(N):
                cost[(i + j) % 3][c] += D[CC[i][j]][c]
 
    res = float("inf")
    color = [i for i in range(C)]
    for i, c in enumerate(list(itertools.permutations(color, 3))):
        tmp = 0
        for it in range(3):
            tmp += cost[it][c[it]]
        res = min(res, tmp)
 
    print(res)
 
main()
### BUGGY CODE ###

from sys import stdin

if __name__ == '__main__':
    N = int(stdin.readline().rstrip())
    n = [x for x in range(1,N)]
    print(sum(n))

### FIXED CODE ###

from sys import stdin

if __name__ == '__main__':
    N = int(stdin.readline().rstrip())
    print( ((N-1) * N) // 2)
### BUGGY CODE ###

import copy
from collections import deque
H, W = map(int, input().split())
M = [['#' == x for x in input()] for _ in range(H)]

black = deque([(i, j) for i in range(H) for j in range(W) if M[i][j]])

ans = 0
while True:
  ans += 1
  next_black = deque()
  while black:
    bi, bj = black.popleft()
    if bi - 1 >= 0 and not M[bi - 1][bj]:
      M[bi - 1][bj] = True
      next_black.append((bi - 1, bj))
    if bj - 1 >= 0 and not M[bi][bj - 1]:
      M[bi][bj - 1] = True
      next_black.append((bi, bj - 1))
    if bi + 1 < H and not M[bi + 1][bj]:
      M[bi + 1][bj] = True
      next_black.append((bi + 1, bj))
    if bj + 1 < W and not M[bi][bj + 1]:
      M[bi][bj + 1] = True
      next_black.append((bi, bj + 1))
  if next_black:
     black = copy.copy(next_black)
  else:
     break
print(ans - 1)


  

### FIXED CODE ###

from collections import deque
import copy
 
def main():
    h, w = map(int, input().split())
    a = [[j == "#" for j in input()] for _ in range(h)]
 
 
    que = deque([(i, j) for i in range(h) for j in range(w) if a[i][j]])
 
    count = 0
    while True:
        count += 1
        nque = deque()
        while que:
            y, x = que.popleft()
            if x > 0 and not a[y][x-1]:
                a[y][x-1] = True
                nque.append((y,x-1))
            if x < w-1 and not a[y][x+1]:
                a[y][x+1] = True
                nque.append((y,x+1))
            if y > 0 and not a[y-1][x]:
                a[y-1][x] = True
                nque.append((y-1,x))
            if y < h-1 and not a[y+1][x]:
                a[y+1][x] = True
                nque.append((y+1,x))
 
        if nque:
            que = copy.copy(nque)
        else:
            break
 
    print(count - 1)

if __name__ == "__main__":
    main()
### BUGGY CODE ###

k = int(input())

result_dict = {}
def gcd(x, y):
    if x > y:
        x, y = y, x
    if x == 0:
        return y
        
    global result_dict
    if x not in result_dict:
        result_dict[x] = {}
    if y in result_dict[x]:
        return result_dict[x][y]

    temp = gcd(y % x, x)
    result_dict[x][y] = temp
    return temp

ans = 0
for a in range(1, k + 1):
    for b in range(1, k + 1):
        for c in range(1, k + 1):
            temp = gcd(gcd(a, b), c)
            ans += temp
print(ans)

### FIXED CODE ###

from math import gcd

k = int(input())

r = range(1, k + 1)
ans = sum([gcd(gcd(a, b), c) for a in r for b in r for c in r])
print(ans)
### BUGGY CODE ###

N = int(input())

A = [''] * N
for i in range(N):
  A[i] = str(input())
  
B = list(set(A))

C = [0] * len(B)

for i in range(len(B)):
  C[i] = A.count(B[i])
  
m = max(C)
ans_i = [n for n, v in enumerate(C) if v == m]

ans = []
for i in ans_i:
  ans.append(B[i])
  
ans.sort()
for s in ans:
  print(s)

### FIXED CODE ###

N = int(input())
A = {}
for i in range(N):
  s = str(input())
  if s in A:
    A[s] += 1
  else:
    A[s] = 1

max_val = max(A.values())
keys = [key for key in A if A[key] == max_val]
keys.sort()
for s in keys:
  print(s)
### BUGGY CODE ###

N,W=map(int,input().split())
w=[]
v=[]

for i in range(N):
    x,y=map(int,input().split())
    w.append(x)
    v.append(y)

S=sum(v)

DP=[[1000000000000]*(S+1) for i in range(N+1)]
for i in range(N+1):
    DP[i][0]=0



for i in range(N):
    for v1 in range(S+1):
        DP[i+1][v1]=min(DP[i][v1-v[i]]+w[i],DP[i][v1])

for i in range(S,0,-1):
    if DP[N][i]<=W:
        print(i)
        exit()

### FIXED CODE ###

N,W=map(int,input().split())
w=[]
v=[]

for i in range(N):
    x,y=map(int,input().split())
    w.append(x)
    v.append(y)

S=sum(v)

DP=[[1000000000000]*(S+1) for i in range(N+1)]
for i in range(N+1):
    DP[i][0]=0



for i in range(N):
    for v1 in range(S+1):
        DP[i+1][v1]=min(DP[i][v1-v[i]]+w[i],DP[i][v1])

for i in range(S,0,-1):
    if DP[N][i]<=W:
        print(i)
        exit()
### BUGGY CODE ###

import math
from functools import reduce
 
def gcd(*numbers):
  return reduce(math.gcd, numbers)
 
K = input('')
K=int(K)
la = lb = lc = list(range(1, K+1))
sum = 0
 
for a in range (len(la)):
  for b in range(len(lb)):
    for c in range(len(lc)):
      sum += gcd(la[a],lb[b],lc[c])
print(sum)

### FIXED CODE ###

from math import gcd

K = int(input())
#K = 200
sum = 0

for a in range (1, K+1):
  for b in range(1, K+1):
    for c in range(1, K+1):
      sum += gcd(gcd(a, b), c)

print(sum)
### BUGGY CODE ###

import math

n = int(input())
a = [0]*10**7
x = math.sqrt(10)
b = math.floor(x)
l = 0
for i in range(1,n+1):
  x = math.sqrt(i)
  b = math.floor(x)
  for j in range(1,b+1):
    if(i%j==0 and i//j == j):
      a[i-1] +=1
    elif(i%j==0):
      a[i-1] +=2
for k in range(n):
  l = l + a[k]*(k+1)
print(l)
 


### FIXED CODE ###

import math

n = int(input())
answer = 0
c = 0
b = 0
for i in range(1,n+1):
  b = n//i
  c = i*b*(b+1)/2
  answer = answer + c
print(int(answer))
### BUGGY CODE ###

n,m=map(int, input().split())
l={}
for i in range(n):
    a,b=map(int, input().split())
    if not a in l:
        l[a]=[b]
    else:
        l[a].append(b)

res=0
target=[0]*m
for i in range(1,m+1):
    if i in l:
        target.extend(l[i])
    target.sort()
    val=target.pop()
    res+=val
    #print(target, max(target))

print(res)

### FIXED CODE ###

import bisect
import array

n,m=map(int, input().split())
l={}
for i in range(n):
    a,b=map(int, input().split())
    if not a in l:
        l[a]=[b]
    else:
        l[a].append(b)

res=0
target=array.array('I', [])
for i in range(1,m+1):
    if i in l:
        for j in l[i]:
            bisect.insort_left(target, j)

    if not target:
        val=0
    else:
        val=target.pop()
    res+=val
    #print(target, max(target))

print(res)
### BUGGY CODE ###

#!/usr/bin/env python3
def main():
    import sys

    sys.setrecursionlimit(10 ** 6)

    def dfs(now: int, depth: int):
        """深度を記録しながらDFS"""
        if temp_dis[now] <= depth:
            return
        temp_dis[now] = min(temp_dis[now], depth)
        for next in G[now]:
            dfs(next, depth + 1)
        
    N, X, Y = map(int, input().split())

    G = [[1]] + [[x - 1, x + 1] for x in range(1, N - 1)] + [[N - 2]]
    G[X - 1].append(Y - 1)
    G[Y - 1].append(X - 1)
    # print(G)

    distance = [set() for _ in [0] * N]
    for i in range(N):
        temp_dis = [N] * N
        dfs(i, 0)
        # print(i, temp_dis)
        for j in range(N):
            distance[temp_dis[j]].add((i, j) if i <= j else (j, i))
    
    for ans in distance[1:]:
        print(len(ans))


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
def main():
    from collections import deque
        
    N, X, Y = map(int, input().split())

    G = [[1]] + [[x - 1, x + 1] for x in range(1, N - 1)] + [[N - 2]]
    G[X - 1].append(Y - 1)
    G[Y - 1].append(X - 1)

    dist = [[-1] * N for _ in [0] * N]
    for s in range(N):
        q = deque([s])
        dist[s][s] = 0
        while q:
            v = q.popleft()
            for nv in G[v]:
                if dist[s][nv] == -1:
                    dist[s][nv] = dist[s][v] + 1
                    q.append(nv)
    res = [0] * N
    for i in range(N):
        for j in range(i + 1, N):
            res[dist[i][j]] += 1
    for d in range(1, N):
        print(res[d])


if __name__ == '__main__':
    main()
### BUGGY CODE ###

n, k, q = map(int, input().split())
points = [k] * n

for i in range(q):
    a = int(input()) - 1
    for j in range(n):
        if j != a:
            points[j] -= 1

for i in range(n):
    print('Yes' if points[i] > 0 else 'No')


### FIXED CODE ###

n, k, q = map(int, input().split())
points = [0] * n

for _ in range(q):
    a = int(input()) - 1
    points[a] += 1

for i in range(n):
    print('Yes' if k - q + points[i] > 0 else 'No')
### BUGGY CODE ###

N = int(input())
A = [0] + [int(_) for _ in input().split()]
B = [0]
is_monotone = True
for i in range(N):
    if is_monotone:
        is_monotone &= A[i + 1] > A[i]
    B += [min(A[i + 1], 18)]
if is_monotone:
    print(1)
    exit()


def is_possible(K):
    mp = {}
    for i in range(N):
        if B[i] >= B[i + 1]:
            for key in sorted(mp.keys(), reverse=True):
                if key >= B[i + 1]:
                    del mp[key]
                else:
                    break
            flag = True
            for j in range(B[i + 1] - 1, -1, -1):
                if mp.get(j, 0) < K - 1:
                    mp[j] = mp.get(j, 0) + 1
                    flag = False
                    break
                elif j in mp:
                    del mp[j]
            if flag:
                return False
    return True


def bis(x, y):
    if y == x + 1:
        return y
    elif is_possible((x + y) // 2):
        return bis(x, (x + y) // 2)
    else:
        return bis((x + y) // 2, y)


print(bis(0, N))


### FIXED CODE ###

import random
input()
A = [int(_) for _ in input().split()]
A = [A[0]] + [j for i, j in zip(A, A[1:]) if i >= j]
N = len(A)


def cut(array, index):
    if index < 1:
        return []
    if index <= array[0][0]:
        return [(index, array[0][1])]
    for _ in range(len(array)-1, 0, -1):
        if array[_ - 1][0] < index:
            return array[:_] + [(index, array[_][1])]


def is_possible(K):
    dp = [(A[0], 0)]
    for a in A[1:]:
        if a <= dp[-1][0]:
            dp = cut(dp, a)
        else:
            dp += [(a, 0)]
        is_added = False
        for j in range(len(dp) - 1, -1, -1):
            if dp[j][1] < K - 1:
                dp = cut(dp, dp[j][0] - 1) + [(dp[j][0], dp[j][1] + 1)]
                if dp[-1][0] < a:
                    dp += [(a, 0)]
                is_added = True
                break
        if not is_added:
            return False
    return True


def bis(x, y):
    if y == x + 1:
        return y
    elif is_possible((x + y) // 2):
        return bis(x, (x + y) // 2)
    else:
        return bis((x + y) // 2, y)


print(bis(0, N))
### BUGGY CODE ###

N,K=map(int,input().split())
A=[int(i) for i in input().split()]
M=41
B=[[0 for x in range(M-len(bin(A[i])[2:]))]+list([int(x) for x in bin(A[i])[2:]]) for i in range(N)]
C=[[0,0] for i in range(M)]
for i in range(N):
    for j in range(M):
        C[j][B[i][j]]+=1
D=[-1 for i in range(M)]
for j in range(M):
    if C[j][0]<=C[j][1]:
        D[j]=0
    else:
        D[j]=1
E=[2**(M-i-1) for i in range(M)]
tmp=0
for i in range(M):
    if tmp+E[i]*D[i]<=K:
        tmp+=E[i]*D[i]
ans=0
for i in range(N):
    ans+=tmp^A[i]
print(ans)

### FIXED CODE ###

N,K=map(int,input().split())
A=[int(i) for i in input().split()]
M=41
B=[[0 for x in range(M-len(bin(A[i])[2:]))]+list([int(x) for x in bin(A[i])[2:]]) for i in range(N)]
C=[[0,0] for i in range(M)]
for i in range(N):
    for j in range(M):
        C[j][B[i][j]]+=1
D=[-1 for i in range(M)]
for j in range(M):
    if C[j][0]<=C[j][1]:
        D[j]=0
    else:
        D[j]=1
E=[2**(M-i-1) for i in range(M)]
tmp=0
for i in range(M):
    if tmp+E[i]*D[i]<=K:
        tmp+=E[i]*D[i]
ans=0
for i in range(N):
    ans+=tmp^A[i]
print(ans)
### BUGGY CODE ###

x = input().split()
y = [int(input()) for i in range(int(x[2]))]
member = [int(x[1])] * int(x[0])

for l in y:
  for i,point in enumerate(member):
    if (l-1) != i:
      member[i] = (point -1)
      
for z in member:
  if z > 0:
    print("Yes")
  else:
    print("No")


### FIXED CODE ###

x = input().split()
member = [int(x[1])] * int(x[0])

for l in range(int(x[2])):
  y = input()
  member[int(y) - 1] += 1
      
for z in member:
  if (z - int(x[2])) > 0:
    print("Yes")
  else:
    print("No")
### BUGGY CODE ###

n, p = map(int, input().split())
s = [int(i) % p for i in input()]
mod = [[0] * p for _ in range(n)]
for i in range(n):
  mod[i][s[i]] = 1
count = mod[0][0]
for i in range(1, n):
  for j in range(p):
    mod[i][(j * 10 + s[i]) % p] += mod[i-1][j]
  count += mod[i][0]
print(count)

### FIXED CODE ###

n, p = map(int, input().split())
s = input()
count = 0
if p == 2 or p == 5:
  for i in range(n):
    if int(s[i]) % p == 0:
      count += i + 1
  print(count)
else:
  mod = [0] * p
  mod[0] = 1
  tmp = 0
  ten = 1
  for i in s[::-1]:
    ten = ten * 10 % p
    tmp = (tmp + int(i) * ten) % p
    mod[tmp] += 1
  for m in mod:
    count += m * (m - 1) // 2
  print(count)
### BUGGY CODE ###

import sys;input=sys.stdin.readline
from collections import defaultdict
N, = map(int, input().split())
S = []
for _ in range(N):
    s = input().strip()
    S.append(s)
S.sort(key=lambda x:len(x))
D = defaultdict(set)
R = 0
for s in S:
    l = len(s)
    d = defaultdict(int)
    for c in D[""]:
        d[c] += 1
    for i in range(l-1, -1, -1):
        R += d[s[i]]
        d[s[i]] = 0
        for c in D[s[i:]]:
            d[c] += 1
    D[s[1:]].add(s[0])
print(R)


### FIXED CODE ###

import sys;input=sys.stdin.readline
N, = map(int, input().split())
MOD=67280421310721
S = []
for _ in range(N):
    s = input().strip()
    S.append(s)
S.sort(key=lambda x:len(x))
D = dict()
dd = set()
R = 0
for s in S:
    l = len(s)
    d = [0]*26
    for c in dd:
        d[c] += 1
    tmp=0
    for i in range(l-1, -1, -1):
        ee = ord(s[i]) - 97
        tmp = 100*tmp+(ee+1)
        tmp %= MOD
        R += d[ee]
        d[ee] = 0
        if tmp in D:
            for c in D[tmp]:
                d[c] += 1
        if i == 1:
            nn = tmp
    if l != 1:
        if nn not in D:
            D[nn] = set()
        D[nn].add(ee)
    else:
        dd.add(ee)
print(R)
### BUGGY CODE ###

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

# 以下カンニング
for _ in range( min( k, 41 ) ):
    b = [ 0 for _ in range( n ) ]

    for i in range( n ):
        l = max( 0, i - a[ i ] )
        r = min( n - 1, i + a[ i ] )
        b[ l ] += 1
        if r + 1 < n:
            b[ r + 1 ] -= 1

    for i in range( 1, n ):
        b[ i ] += b[ i - 1 ]

    a = b

print( " ".join( list( map( str, a ) ) ) )

### FIXED CODE ###

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

# 以下カンニング
for _ in range( min( k, 41 ) ): # 41 ~ log( 2 * 10 ** 5 )
    b = [ 0 ] * n

    for i in range( n ):
        l = max( 0, i - a[ i ] )
        r = min( n - 1, i + a[ i ] )
        b[ l ] += 1
        if r + 1 < n:
            b[ r + 1 ] -= 1

    for i in range( 1, n ):
        b[ i ] += b[ i - 1 ]

    a = b

print( " ".join( list( map( str, a ) ) ) )
### BUGGY CODE ###

def main():
    N = int(input())
    
    A = [None] * N
    for i in range(N):
        A[i] = list(map(int, input().split()))
        
    
    day = 0
    roop_flag = True

    while roop_flag:
        # 基本はNGの状態にしておく
        roop_flag = False
        
        done = [False] * N
        b = [None] * N
        
        # 次に消化すべき組み合わせをとる
        for i in range(N):
            if len(A[i]) > 0:
                b[i] = A[i][0]
            
        if b == [None]*N:
            print(day)
            quit()
        
        for i in range(N):
            if not done[i]:
                if b[i] is None:
                    continue
                
                if b[b[i] - 1] == i + 1:
                    roop_flag = True

                    done[i] = True
                    done[b[i] -1] = True
                    
                    A[i] = A[i][1:]
                    A[b[i] -1] = A[b[i] -1][1:]
        day += 1
        
    print(-1)
    

    
if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
 
N = int(input())

A = [None] * N
# インデックス：-1で先頭にアクセスするため前後反転
# 最初の選手を指す場合０になるように-1した値を保持
# 全組み合わせを試合し終わった時は−１になるようにする
for i in range(N):
    A[i] = [-1] + [int(x) - 1 for x in input().split()[::-1]]


def f(candi):
    
    played = []
    
    # 次に試合する可能性のある選手を順次チェック
    for n in candi:
        target = A[n][-1]
        if A[target][-1] == n:
            played.append(n)
        
    new_candi = set()    
    for n in played:
        # 試合ずみの組み合わせを削除
        A[n].pop()
        # 試合する人の候補に追加
        new_candi.add(n)
        # 次の対戦相手を試合の候補に追加
        if A[n][-1] != -1:
            new_candi.add(A[n][-1])
            
    return len(played), new_candi


answer = 0
# 最悪の試合数（二倍された値）
rest = N*(N-1)
# 試合する人の候補
play_candi = set(range(N))

while True:
    answer += 1
    x, play_candi = f(play_candi)
    # 行われた試合数を確認
    if x == 0:
        answer = -1
        break
        
    rest -= x
    if rest ==0:
        break
        
print(answer)
### BUGGY CODE ###

import sys
n = int(input())
s = input()
se = set()
for i in range(0,n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            se.add(s[i]+s[j]+s[k])
print(len(se))

### FIXED CODE ###

n = int(input())
s = input()
target = [str(i) for i in range(10)]
count = 0
for x in target:
    a = s.find(x)
    if a == -1:
        continue
    for y in target:
        b = s.find(y,a+1)
        if b == -1:
            continue
        for z in target:
            c = s.find(z,b+1)
            if c != -1:
                count +=1
print(count)
### BUGGY CODE ###

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

order = []


for i in range(1,n+1):
    order.append(a.index(i)+1)
    

print(' '.join([str(i) for i in order]))

### FIXED CODE ###

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

ans = [0 for i in range(n)]

for i in range(n):
    ans[a[i]-1] = i+1

print(' '.join(map(str,ans)))
### BUGGY CODE ###

import math
import collections
N=int(input())
# N,M=map(int,input().split())
# S=[[]for i in range(N)]
# # for i in range(Q):
A=list(map(int,input().split()))
# #     S[i]=a
ans=0
# # print()
for i in range(N):
    for j in range(i,N):
        if abs(i-j)==A[i]+A[j]:
            ans+=1
print(ans)

### FIXED CODE ###

import math
import collections
N=int(input())
# N,M=map(int,input().split())
# S=[[]for i in range(N)]
# # for i in range(Q):
A=list(map(int,input().split()))
# #     S[i]=a
D=dict()
ans=0
for i in range(N):
    a=A[i]+i
    if a in D.keys():
        D[a]+=1
    else:
        D[a] = 1
    b=i-A[i]
    if b in D.keys():
        ans+=D[b]


print(ans)
### BUGGY CODE ###

from itertools import combinations
n = int(input())

def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1

p = []
impossible = []
flag = False
for i in range(2, 55556):
    if is_prime(i):
        p.append(i)
    
        if len(p) >= n:
            L = list(combinations(p, n))
            #for im in impossible:
                #if im in L:
            #    L.remove(im)
            for l in L:
                for l5 in list(combinations(l, 5)):
                    if is_prime(sum(l5)):
                        flag = False
                        #if not l in impossible:
                        #impossible.append(l)
                        break
                    flag = True
                if flag:
                    break
            if flag:
                break

if flag:
    print(' '.join(map(str, l)))

### FIXED CODE ###

import math

n = int(input())

def is_prime(x):
    if x < 2: return False
    if x == 2 or x == 3 or x == 5: return True
    if x % 2 == 0 or x % 3 == 0 or x % 5 == 0: return False

    prime = 7
    step = 4
    while prime <= math.sqrt(x):
        if x % prime == 0: return False

        prime += step
        step = 6 - step

    return True

A = []
for a in range(11, 55555, 10):
    if is_prime(a):
        A.append(a)
        if len(A) == n:
            break
print(' '.join(map(str, A)))
### BUGGY CODE ###

### C

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

X = list(map(int , sorted(list(map(int , input().split())))))

#print("X = " + str(X))

D = []

R = 0

if M-1 > 0 :
	for i in range(M-1):
		D.append(int(X[i+1]) - int(X[i]))


#print("D = " + str(D))

for i in range(N-1):
	if D !=[]:
		MAXD = max(D)
		D.remove(MAXD)
#		print(str(D) + "minus " + str(i+1) + "roots.")

if D != []:
	for d in D:
		R += d


print(R)



### FIXED CODE ###

### C

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

X = list(map(int , sorted(list(map(int , input().split())))))

#print("X = " + str(X))

D = []

R = 0

if M-1 > 0 :
	for i in range(M-1):
		D.append(int(X[i+1]) - int(X[i]))


#print("D = " + str(D))

if D !=[]:
	D = sorted(D)
	D = D[::-1]
	D = D[N-1:]
#print("D = " + str(D))

if D != []:
	for d in D:
		R += d


print(R)
### BUGGY CODE ###

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

A = collections.Counter(A)
cnt = 0
for _ in range(N):
    if len(A.keys()) <= K:
        break
    k, v = min(A.items(), key=lambda x: x[1])
    cnt += v
    del A[k]
    
print(cnt)

### FIXED CODE ###

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

A = collections.Counter(A)
A = sorted(A.items(), key=lambda x:x[1])
cnt = A[:len(A)-K]

ans = []
for c in cnt:
    ans.append(c[1])
    
print(sum(ans))
### BUGGY CODE ###

N = int(input())
S = []
A = 0


for i in range(N):
  s = input()
  if s in S:
    pass
  else:
    S.append(s)
    A += 1

print(A)

### FIXED CODE ###

N = int(input())
S = set()



for i in range(N):
  S.add(input())


print(len(S))
### BUGGY CODE ###

import sys
from bisect import *

def main():
	input = sys.stdin.readline

	N = int(input())
	S = input().strip()
	M = 998244353

	ri = []
	gi = []
	bi = []

	for i, c in enumerate(S):
		if c=='R':
			ri.append(i)
		elif c=='G':
			gi.append(i)
		else:
			bi.append(i)

	si = []
	mi = []
	li = []
	for i, tt in enumerate(zip(ri,gi,bi)):
		s, m, l = sorted(tt)
		si.append(s)
		mi.append(m)
		li.append(l)

	ans = 1
	for i, mm in enumerate(mi):
		st = bisect(si,mm)
		lt = bisect(li,mm)
		ans *= (st-i)*(i+1-lt)*(i+1)%M

	print(ans)

if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
from bisect import *

def main():
	input = sys.stdin.readline

	N = int(input())
	S = input().strip()
	M = 998244353

	ri = []
	gi = []
	bi = []

	for i, c in enumerate(S):
		if c=='R':
			ri.append(i)
		elif c=='G':
			gi.append(i)
		else:
			bi.append(i)

	si = []
	mi = []
	li = []
	for i, tt in enumerate(zip(ri,gi,bi)):
		s, m, l = sorted(tt)
		si.append(s)
		mi.append(m)
		li.append(l)

	ans = 1
	for i, mm in enumerate(mi):
		st = bisect(si,mm)
		lt = bisect(li,mm)
		ans = ans*(st-i)*(i+1-lt)*(i+1)
		ans = ans%M

	print(ans)

if __name__ == "__main__":
    main()
### BUGGY CODE ###

N = int(input())
gachalist = []
counter = 0
for i in range(N):
    item = input()
    if item not in gachalist:
        gachalist.append(item)
        counter = counter+1
print(counter)

### FIXED CODE ###

N = int(input())
gachalist=[]
for i in range(N):
    gachalist.append(input())
print(len(set(gachalist)))