Harryxun/stf_run huggingface dataset:
N = int(input())
S = [input() for _ in range(N)]

from collections import Counter
from scipy.special import comb

nS = []
for s in S:
    s  = ''.join(sorted(s))
    nS.append(s)

c = Counter(nS)

acc = 0
for cnt in list(c.values()):
    acc+=comb(cnt, 2, exact=True)
print(acc)

### FIXED CODE ###

N = int(input())
S = [input() for _ in range(N)]
 
from collections import Counter
 
nS = []
for s in S:
    s  = ''.join(sorted(s))
    nS.append(s)

c = Counter(nS)
 
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

acc = 0
for cnt in list(c.values()):
    if cnt!=1:
        acc+=cmb(cnt, 2)
    
print(acc)
# -*- coding: utf-8 -*-
# 整数の入力
n = int(raw_input())
li = list(map(int, input().split()))

for i in range(N):
    sl.append("".join(sorted(list[i])))

sl.sort()

c = collections.Counter(sl)

print(N - (len(c)-1))

### FIXED CODE ###

# -*- coding: utf-8 -*-
N = int(raw_input())
cnt = 0
dic = {}

for _ in xrange(N):
	rs = ''.join(sorted(raw_input()))
	
	if rs in dic:
		cnt += dic[rs]
		dic[rs] += 1
	else:
		dic[rs] = 1
print cnt
N,M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
A.reverse()
match = [2,5,5,4,5,6,3,7,6]
dp = [0]*(N+1)
for i in range(N+1):
  L = []
  for j in range(M):
    if i-match[A[j]-1] >= 0:
      L.append(dp[i-match[A[j]-1]]+1)
  L.sort()
  if len(L) >= 1:
    dp[i] = L[len(L)-1]
ans = ''
while N > 0:
  for i in range(M):
    if dp[N-match[A[i]-1]] == dp[N]-1:
      if dp[N]-1 != 0:
        ans += str(A[i])
        N -= match[A[i]-1]
        break
      else:
        for k in range(M):
          if match[A[k]-1] == N:
            ans += str(A[k])
            N = 0
            break
print(ans)

### FIXED CODE ###

n,m = map(int,input().split())
A = list(map(int,input().split()))
L = [2,5,5,4,5,6,3,7,6]
dp = [-float('inf')]*(n+1)
dp[0] = 0
for i in range(1,n+1):
    for j in range(m):
        if i-L[A[j]-1] < 0:
            None
        else:
            dp[i] = max(dp[i-L[A[j]-1]]+1, dp[i])
A.sort()
A.reverse()
cur = n
ans = ''
while cur != 0:
    for i in range(m):
        temp = A[i]
        if cur-L[temp-1] >= 0:
            if dp[cur-L[temp-1]] == dp[cur]-1:
                ans = ans+str(temp)
                cur -= L[temp-1]
                break
print(ans)
S=input()
N=len(S)

U=[]
for i in range(N):
    U.append(S[i:])
ans=0
for i in range(N):
    l=U[len(U)-1-i]
    cnt=5
    while(1):
        if (cnt)>len(l):
            break
        tmp=l[:cnt]
        if int(tmp)%2019==0:
            ans+=1
        cnt+=1

print(ans)

### FIXED CODE ###

S=input()
N=len(S)
#「連続する区間」についての問題では、”累積和的なもの”をとるのが定石である。
#Sの連続する区間が、右からa文字分から、右からb文字分を取り除いたものであるとき
#その区間の整数が2019の倍数になるということは、s[a]とs[b]を2019で割ったあまりが等しい
#十分条件であることは分かったが、必要条件であるのか
#結論として必要条件でもある
#なぜなら2019と10は互いに素であるからである。

T=[]
T.append(0)
tmp=""
d=[0 for _ in range(2019)]
d[0]=1
r=0
t=1
for i in range(N):
    s=S[N-1-i]
    r+=int(s)*t
    r%=2019
    t*=10
    t%=2019 
    d[r]+=1

ans=0

print(sum(i*(i-1)//2 for i in d))
def solve(data,p):
    L=[]
    if data[p[1]-1][p[0]-1]=="1":
        data[p[1]-1]=data[p[1]-1][:p[0]-1]+"0"+data[p[1]-1][p[0]:]
        L+=p
    else:
        return []
    bakuhu=[(p[0]-3,p[1]),(p[0]-2,p[1]),(p[0]-1,p[1]),(p[0]+1,p[1]),(p[0]+2,p[1]),(p[0]+3,p[1]),(p[0],p[1]-3),(p[0],p[1]-2),(p[0],p[1]-1),(p[0],p[1]+1),(p[0],p[1]+2),(p[0],p[1]+3)]
    for i in range(len(bakuhu)):
        if bakuhu[i][0]>0 and bakuhu[i][1] >0 and bakuhu[i][0] <9 and bakuhu[i][1] <9:
            L.extend(solve(data,bakuhu[i]))
    return L
    
while True:
    ndata=input()
    for i in range(ndata):
        raw_input()
        data=[]
        for j in range(8):
            data.append(raw_input())
        x=input()
        y=input()
        p=(x,y)
        L=solve(data,p)
        while len(L)!=0:
            x=L.pop(0)
            y=L.pop(0)
            data[y-1]=data[y-1][:x-1]+'0'+data[y-1][x:]
        print "Data"+str(i+1)+':'
        for i in range(len(data)):
            print data[i]
        

### FIXED CODE ###

def solve(data,p):
    L=[]
    if data[p[1]-1][p[0]-1]=="1":
        data[p[1]-1]=data[p[1]-1][:p[0]-1]+"0"+data[p[1]-1][p[0]:]
        L+=p
    else:
        return []
    bakuhu=[(p[0]-3,p[1]),(p[0]-2,p[1]),(p[0]-1,p[1]),(p[0]+1,p[1]),(p[0]+2,p[1]),(p[0]+3,p[1]),(p[0],p[1]-3),(p[0],p[1]-2),(p[0],p[1]-1),(p[0],p[1]+1),(p[0],p[1]+2),(p[0],p[1]+3)]
    for i in range(len(bakuhu)):
        if bakuhu[i][0]>0 and bakuhu[i][1] >0 and bakuhu[i][0] <9 and bakuhu[i][1] <9:
            L.extend(solve(data,bakuhu[i]))
    return L
    
while True:
    try:
        ndata=input()
        for i in range(ndata):
            raw_input()
            data=[]
            for j in range(8):
                data.append(raw_input())
            x=input()
            y=input()
            p=(x,y)
            L=solve(data,p)
            while len(L)!=0:
                x=L.pop(0)
                y=L.pop(0)
                data[y-1]=data[y-1][:x-1]+'0'+data[y-1][x:]
            print "Data "+str(i+1)+':'
            for i in range(len(data)):
                print data[i]
    except:
        break
import sys

i = 0

while x == 0:
  x = sys.stdin.readline()
  i += 1

  print "Case %d: %d", %(i,x)
  

### FIXED CODE ###

i = 0
d = 0

while d == 0:
    x = input()
    if x != 0:
        i += 1
        print("Case %d: %d" %(i, x))
    else:
        d = 1
n=int(input())
a=int(input())
b=int(input())
if n==1:print('Hello World')
else:print(a+b)

### FIXED CODE ###

n=int(input())
if n==1:print('Hello World')
else:
  a=int(input())
  b=int(input())
  print(a+b)
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
N = input()
A = map(int, raw_input().split())
B = []
for i in range(N):
	t = 0
	for j in range(N):
		if(i == j):
			continue
		else:
			if(t == 0):
				t = A[j]
			else:
				t = gcd(t,A[j])
		if(t == 1):
			break
	B.append(t)
print(max(B))

### FIXED CODE ###

A,B,T = map(int, raw_input().split())
print((T/A)*B)
n, a, b = map(int, input().split())

mod = 10**9 + 7

ans = pow(2, n, mod)

ans -= 1

aa = 1
for i in range(1, a+1):
    aa = (aa * (n - i + 1) * pow(i, -1, mod)) % mod

bb = 1
for i in range(1, b+1):
    bb = (bb * (n - i + 1) * pow(i, -1, mod)) % mod

ans = (ans - aa - bb) % mod

print(ans)

### FIXED CODE ###

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

mod = 10**9 + 7

ans = pow(2, n, mod)

ans -= 1

aa = 1
for i in range(1, a+1):
    aa = (aa * (n - i + 1) * pow(i, -1, mod)) % mod

bb = 1
for i in range(1, b+1):
    bb = (bb * (n - i + 1) * pow(i, -1, mod)) % mod

ans = (ans - aa - bb) % mod

print(ans)
N, K = map(int, input().split())
p = list(map(int, input().split()))
ans = [sum(p[:K])]
for i in range(N-K):
  ans.append(ans[-1]-p[i]+p[i+k])
print(max(ans)/2+K/2)
    

### FIXED CODE ###

N, K = map(int, input().split())
p = list(map(int, input().split()))
ans = [sum(p[:K])]
for i in range(N-K):
  ans.append(ans[-1]-p[i]+p[i+K])
print(max(ans)/2+K/2)
a=import()
b=import()
c=import()
print(a[0]+b[1]+c[2])

### FIXED CODE ###

a=input()
b=input()
c=input()
print(a[0]+b[1]+c[2])
r, g, b = int(input().split())
total = r*100 + g*10 + b
if total % 4 == 0:
	print(YES)
else:
	print(NO)

### FIXED CODE ###

r, g, b = map(int,input().split())
total = r*100 + g*10 + b
if total % 4 == 0:
	print('YES')
else:
	print('NO')
n = int(input())
for i in range(3):
  if n%10 == 7:
    print('Yes')
    break
  elif n/10 < 1:
    print('No')
  else:
    n = math.floor(n/10)

### FIXED CODE ###

import math
n = int(input())
for i in range(3):
  if n%10 == 7:
    print('Yes')
    break
  elif n/10 < 1:
    print('No')
  else:
    n = math.floor(n/10)
N = int(input("店舗数"))

list = []
for i in range(N):
    s, p = input().split()
    P = 100 - int(p)
    list.append((s,P,i+1))

list.sort()

for a in list:
    print(a[2])
    

### FIXED CODE ###

a, p = map(int, input().split())

re = int((a*3 + p) / 2)

print(re)
# -*- coding:utf-8 -*-
from collections import deque

def solve():
    n = int(input())
    A = input().split()

    """方針
    A = 0 6 7 6 7 0
    i | b
    ---------------
    1 | 0
    2 | 0 6 (本当は逆で6 0)
    3 | 7 0 6
    4 | 7 0 6 6 (本当は逆で 6 6 0 7)
    5 | 7 7 0 6 6
    6 | 7 7 0 6 6 0 (本当は逆で0 6 6 0 7 7) 

    ・iが偶数のとき、bの後ろにA[i]を追加する
    ・iが奇数のとき、bの前にA[i]を追加する

    上の操作をn回すべてしたあとに、

    ・nが偶数なら答えを反転する
    ・nが奇数なら答えはそのまま

    ただし、A[i]は2桁以上の数字の可能性も考慮すること

    あとPythonは、list.insert()はとても遅いので（TLEしたので）、代わりにcollections.dequeを使用する

    ・collections.deque
    https://docs.python.org/ja/3/library/collections.html#collections.deque

    dequeとは、「両端における append や pop を高速に行えるリスト風のコンテナ」
    """

    # 1 2 3 -> 3 1 2
    b = deque()
    for i in range(1, n+1):
        if i%2 == 0:
            b.append(A[i-1])
        else:
            b.insert(0, A[i-1])

    if n%2 == 0:
        ans = ""
        for i in range(n-1, -1, -1):
            ans += b[i] + " "
        print(ans[:-1])
    else:
        ans = " ".join(b)
        print(ans)


if __name__ == "__main__":
    solve()


### FIXED CODE ###

# -*- coding:utf-8 -*-
from collections import deque

def solve():
    n = int(input())
    A = input().split()

    """方針
    A = 0 6 7 6 7 0
    i | b
    ---------------
    1 | 0
    2 | 0 6 (本当は逆で6 0)
    3 | 7 0 6
    4 | 7 0 6 6 (本当は逆で 6 6 0 7)
    5 | 7 7 0 6 6
    6 | 7 7 0 6 6 0 (本当は逆で0 6 6 0 7 7) 

    ・iが偶数のとき、bの後ろにA[i]を追加する
    ・iが奇数のとき、bの前にA[i]を追加する

    上の操作をn回すべてしたあとに、

    ・nが偶数なら答えを反転する
    ・nが奇数なら答えはそのまま

    ただし、A[i]は2桁以上の数字の可能性も考慮すること

    あとPythonは、list.insert()はとても遅いので（TLEしたので）、代わりにcollections.dequeを使用する

    ・collections.deque
    https://docs.python.org/ja/3/library/collections.html#collections.deque

    dequeとは、「両端における append や pop を高速に行えるリスト風のコンテナ」
    """

    # 1 2 3 -> 3 1 2
    b = deque()
    for i in range(1, n+1):
        if i%2 == 0:
            b.append(A[i-1])
        else:
            b.appendleft(A[i-1])

    if n%2 == 0:
        ans = ""
        for i in range(n-1, -1, -1):
            ans += b[i] + " "
        print(ans[:-1])
    else:
        ans = " ".join(b)
        print(ans)


if __name__ == "__main__":
    solve()
l, r = map(int, input().split())
ans = 10**10
for i in range(l, r):
    for j in range(i+1, r):
        ans = min(ans, (i*j)%(2019))
        if i*j%2019==0:
            break
    if i*j%2019==0:
        break
print(ans)

### FIXED CODE ###

l, r = map(int, input().split())
ans = 10**10
for i in range(l, r+1):
    for j in range(i+1, r+1):
        ans = min(ans, (i*j)%(2019))
        if i*j%2019==0:
            break
    if i*j%2019==0:
        break
print(ans)
a=int(input())
b=map(int,input().split())
count=0
for i in range (a):
	if b[i]%2==0:
		if b[i]%3==0 or b[i]%5==0:
			count=1
		else:count=0
	else:count=1
if count=1:
	print("APPROVED")
else: print("DENIED")

### FIXED CODE ###

a=int(input())
b=list(map(int,input().split()))
count=0
for i in range (a):
 if b[i]%2==0 and b[i]%3!=0 and b[i]%5!=0:
  count=0
  break
 else:count=1
if count==1:
 print("APPROVED")
else: print("DENIED")
import sys
import numpy as np
import math
import collections
from collections import deque 
from functools import reduce

# input = sys.stdin.readline
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a_t, b_t = [0], [0]
for i in range(n):
    a_t.append(a_t[i] + a[i])
for i in range(m):
    b_t.append(b_t[i] + b[i])
ans = 0
j = m
for i in range(n+1):
    if (a[i] > k):
        break
    while(a_t[i] + b_t[j] > k):
        j -= 1
    ans = max(ans, i + j)
print(ans)



### FIXED CODE ###

import sys
import numpy as np
import math
import collections
from collections import deque 
from functools import reduce

# input = sys.stdin.readline
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a_t, b_t = [0], [0]
for i in range(n):
    a_t.append(a_t[i] + a[i])
for i in range(m):
    b_t.append(b_t[i] + b[i])
ans = 0
j = m
for i in range(n+1):
    if (a_t[i] > k):
        break
    while(a_t[i] + b_t[j] > k):
        j -= 1
    ans = max(ans, i + j)
print(ans)
i = list(map(int,input().split()))
j = list(map(int,input().split()))
for i in range(0, i[0] - i[1]):
    if j[i] < j[i + 3]:
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

i = list(map(int,input().split()))
j = list(map(int,input().split()))
for p in range(0, i[0] - i[1]):
    if j[p] < j[p + i[1]]:
        print("Yes")
    else:
        print("No")
n=int(input())
ans='APPROVED'
for i in range(n):
  x=int(input())
  if x%2==0:
    if x%3!=0 and x%5!=0:
      ans='DENIED'
      break
print(ans)

### FIXED CODE ###

n=int(input())
ans='APPROVED'
a=list(map(int,input().split()))
for x in a:
  if x%2==0:
    if x%3!=0 and x%5!=0:
      ans='DENIED'
      break
print(ans)
k,n = map(int,input(),split())
a = list(map(int,input().split()))
tm = a[0]
a.append(tm)
m = 11414114514
 
for i in range(n):
  m = min(m,a[i+1]-a[i])
  
print(k-m)

### FIXED CODE ###

k,n = map(int,input().split())
a = list(map(int,input().split()))
tm = a[0]
a.append(tm)
m = -9878789894545656
 
for i in range(n-1):
  m = max(m,a[i+1]-a[i])
  
m = max(m,a[0]+k-a[n-1])
  
print(k-m)
a = input() # 500
b = input() # 100
c = input() # 50
x = input() # objecive

counter = 0
for use_a in range(a+1):
  if 500*use_a > x:
    continue
  rest = x - 500*use_a
  for use_b in range(b+1):
    if 100*use_b > rest:
      continue
    rest = rest - 100*use_b
    for use_c in range(c+1):
      if 50*use_c != rest:
        continue
      counter += 1

print(counter)


### FIXED CODE ###

a = int(input())  # 500
b = int(input())  # 100
c = int(input())  # 50
x = int(input())  # objecive

counter = 0
for use_a in range(a + 1):
    if 500 * use_a > x:
        continue
    rest = x - 500 * use_a
    for use_b in range(b + 1):
        if 100 * use_b > rest:
            continue
        rest_c = rest - 100 * use_b
        for use_c in range(c + 1):
            if 50 * use_c != rest_c:
                continue
            counter += 1

print(counter)
l=sorted(list(map(int,raw_input().split())))
print(l[0],l[1],l[2])

### FIXED CODE ###

l=list(map(int,input().split()))
L=sorted(l)
print(L[0],L[1],L[2])
s= map.input()
if(s == "ABC"):
  print("ARC")
else:
  print("ABC")

### FIXED CODE ###

s= input()
if(s == "ABC"):
  print("ARC")
else:
  print("ABC")
def main():
    mod = 1000000007
    N, M, *A = map(int, open(0).read().split())
    F = [0] * (N + 1)
    A.sort()
    F[0] = 1
    if not A[0] == 1:
        F[1] = 1
    for i in range(2, N + 1):
        if i not in A:
            F[i] = (F[i-1] + F[i-2]) % mod
    print(F[-1])


if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    mod = 1000000007
    N, M, *A = map(int, open(0).read().split())
    A = set(A)
    F = [0] * (N + 1)
    F[0] = 1
    if 1 not in A:
        F[1] = 1
    for i in range(2, N + 1):
        if i not in A:
            F[i] = (F[i-1] + F[i-2]) % mod
    print(F[N])


if __name__ == "__main__":
    main()
s = input()
print(n//2-s.count("p"))

### FIXED CODE ###

s = input()
m = "gp"*(len(s)//2+1)
g = 0
for i in range(len(s)):
  if s[i] == m[i]:
    continue
  elif s[i] == "p":
    g -= 1
  else:
    g += 1
print(g)
import heapq
n, m = map(int, input().split())
day = [[] for _ in range(m+1)]
for _ in range(n):
    a, b = map(int, input().split())
    day[a].append(b)
benefit = []
heapq.heapify(benefit)
ans = 0
for i in range(1, m+1):
    for j in day[i]:
        heapq.heappush(benefit, -j)
    if benefit:
        ans -= heapq.heappop(benefit)  # 最大値を加算
print(ans)


### FIXED CODE ###

import heapq
n, m = map(int, input().split())
day = [[] for _ in range(10**5+1)]
for _ in range(n):
    a, b = map(int, input().split())
    day[a].append(b)
benefit = []
heapq.heapify(benefit)
ans = 0
for i in range(1, m+1):
    for j in day[i]:
        heapq.heappush(benefit, -j)
    if benefit:
        ans -= heapq.heappop(benefit)  # 最大値を加算
print(ans)
N=int(input())
A=input().split(" ")
A=[int(i) for i in A]
A.sort()

def act(A):
  if len(A)%2==0:
    A_=[]
    for i in range(int(len(A)/2)):
      A_.append((A[2*i]+A[2*i+1])/2)
    return A_
  
  elif len(A)%2==1:
    A_=[]
    for i in range(int((len(A)-1)/2)):
      A_.append((A[2*i]+A[2*i+1])/2)
    A_.append(A[len(A)-1])
    return A_
    
    
while len(A)>1:
  A=act(A)

print(A[0])

### FIXED CODE ###

a=int(input())
s=input()

if a>=3200:
  print(s)
else:
  print("red")
K, X = map(int, input().split())
 for i in range(X - K + 1, X + K):
 if i < X + K - 1:
 print(i, end=' ')
 else:
 print(i)


### FIXED CODE ###

K, X = map(int, input().split())
for i in range(X - K + 1, X + K):
  if i < X + K - 1:
    print(i, end=' ')
  else:
    print(i)
s = input()
t = input()
print("{}{}".format(t, s))

### FIXED CODE ###

s, t = input().split()
print("{}{}".format(t, s))
A, B, C = input() for i in range(3)
print(A[0] + B[1] + C[2])

### FIXED CODE ###

A=input()
B = input()
C = input()
print(A[0] + B[1] + C[2])
N,M=map(int,input().split())
sc=[]
ans=[]
for i in range(M):
    sc.append(list(map(int,input().split())))
    ans.append(0)
for i in sc:
    if ans[i[0]-1] > i[1] or ans[i[0]-1]==0:
        ans[i[0]-1]=i[1]
stack=""
for i in ans:
    stack=stack+str(i)
stack=int(stack)
stack=str(stack)
if len(stack) == N and stack != "0":
    print(stack)
else:
    print(-1)

### FIXED CODE ###

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())
for i in range(10**N):
    if len(str(i)) != N:
        pass
    else:
        num=list(str(i))
        ok = True
        for j in range(M):
            if num[s[j]-1] != str(c[j]):
                ok = False
        if ok:
            print(i)
            exit()
print(-1)
N = int(input())
a_list = []
for n in range(N):
    a_list.append(int(input()))

count = 0
pos = 1
for n in range(N):
    pos = a_list[pos-1]
    count += 1
    if a_list[pos-1]==2:
        print(count)
        break
if a_list[pos]!=2:
    print(-1)

### FIXED CODE ###

N = int(input())
a_list = []
for n in range(N):
    a_list.append(int(input()))

count = 0
pos = 1
for n in range(N):
    count += 1
    if a_list[pos-1]==2:
        print(count)
        break
    pos = a_list[pos-1]
    
if a_list[pos-1]!=2:
    print(-1)
a, b = map(float, input().split())
n = a*b
print(floor(n))

### FIXED CODE ###

from decimal import *
a,b = map(Decimal,input().split())
print(int(a*b))
from bisect import bisect_left, bisect_right
br, bl = bisect_right, bisect_left
n = input()
a = sorted([int(x) for x in raw_input().split()])
b = sorted([int(x) for x in raw_input().split()])
c = sorted([int(x) for x in raw_input().split()])
ans = 0
for bi in b:
	ans += (bl(a, bi) * (n - br(c, bi)))
print ans

### FIXED CODE ###

a = raw_input()
b = raw_input()
if a == b[::-1]:
	print 'YES'
else:
	print 'NO'
n,m = map(int,input().split())
l = [int(input()) for i in range(n)]

l.sort()

print(sum(l[:m]))

### FIXED CODE ###

def main():
	n,m = map(int,input().split())
	l = list(map(int,input().split()))
	 
	l.sort()
	 
	print(sum(l[:m]))

if __name__ == '__main__':
	main()
a,b=map(int,input().print())

if b%a==0:
  print(int(b+a))
else:
  print(int(b-a))

### FIXED CODE ###

a,b=map(int,input().split())
     
if b%a==0:
  print(int(b+a))
else:
  print(int(b-a))
import sys
N, M = map(int, input().split())

if N == 1:
    sc = []
    for m in range(M):
        s, c = map(int, input().split())
        sc.append(c)
    sc = set(sc)
    if len(sc) == 0:
        print(0)
        sys.exit(0)
    elif len(sc) == 1:
        print(sc[0])
        sys.exit(0)
    else:
        print(-1)
        sys.exit(0)
        
if N == 2:
    sc = []
    for m in range(M):
        s, c = map(int, input().split())
        sc.append([s, c])
    sc = list(map(list, set(map(tuple, sc))))
    
    l1 = []
    for m in range(M):
        if sc[m][0] == 1 and sc[m][1] > 0:
            l1.append(sc[m][1])
    if len(l1) == 0 or len(l1) > 1:
        print(-1)
        sys.exit(0)
    else:
        lank1 = min(l1)
    
    l2 = []
    for m in range(M):
        if sc[m][0] == 2:
            l2.append(sc[m][1])
    if len(l2) == 0:
        lank2 = 0
    elif len(l2) == 1:
        lank2 = min(l2)
    else:
        print(-1)
        sys.exit(0)
    
    ans = lank1 * 10 + lank2
    print(ans)
    sys.exit(0)
    
if N == 3:
    sc = []
    for m in range(M):
        s, c = map(int, input().split())
        sc.append([s, c])
    sc = list(map(list, set(map(tuple, sc))))    
    
    l1 = []
    for m in range(M):
        if sc[m][0] == 1 and sc[m][1] > 0:
            l1.append(sc[m][1])
    if len(l1) == 0 or len(l1) > 1:
        print(-1)
        sys.exit(0)
    else:
        lank1 = min(l1)
    
    l2 = []
    for m in range(M):
        if sc[m][0] == 2:
            l2.append(sc[m][1])
    if len(l2) == 0:
        lank2 = 0
    elif len(l2) == 1:
        lank2 = min(l2)
    else:
        print(-1)
        sys.exit(0)
    
    l3 = []
    for m in range(M):
        if sc[m][0] == 3:
            l3.append(sc[m][1])
    if len(l3) == 0:
        lank3 = 0
    elif len(l3) == 1:
        lank3 = min(l3)
    else:
        print(-1)
        sys.exit(0)
    
    ans = lank1 * 100 + lank2 * 10 + lank3
    print(ans)
    sys.exit(0)

### FIXED CODE ###

import sys
N, M = map(int,input().split())
s = []
c = []
for m in range(M):
    S, C = map(int,input().split())
    s.append(S)
    c.append(C)


for i in range(10 ** N):
    Str = str(i)

    if len(Str) == N and all([Str[s[m] - 1] == str(c[m]) for m in range(M)]):
        print(Str)
        sys.exit(0)

print(-1)
N=map(int, input())
list=list(map(str, input().split()))
answer=[]
for i in range(1, N):
	answer.append(list.count(i))
a_s='\n'.join(answer)
print(a_s)

### FIXED CODE ###

N=int(input())
A=list(map(int, input().split()))
ans=[0]*N
for a in A:
  ans[a-1]+=1
for n in ans:
  print(n)