n, m = map(int, input().split())
s = [0]*m
c = [0]*m

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

r = [0]*3  
for i in range(3):
  r[s[i] - 1] = c[i]
 
ans = r[0]*100 + r[1]*10 + r[2]*1
print(ans)