n,m = [int(i) for i in input().split()]
a = []
b = []
to = [0,0,0]

for i in range(m):
  s,c = [int(j) for j in input().split()]
  a.append(s)
  b.append(c)

for i in range(m):
  if 3 == a[i]:
    to[2] = b[i]
  elif 2 == a[i]:
    to[1] = b[i]
  elif 1 == a[i]:
    to[0] = b[i]

total = to[0] * 100 + to[1] * 10 + to[2]
print(total)