N, M = map(int, input().split())
s = []
c = []
a = [10, 10, 10]
flag = 0
ans = 0

for i in range(M):
    s1,c1=[int(i) for i in input().split()]
    s.append(s1)
    c.append(c1)
     
for i in range(M):
  if a[s[i] - 1] != 10:
    a[s[i] - 1] = c[i]
  else:
    flag = 1
      
for i in range(3):
  if a[i] == 10:
    if i == 3 - N:
      a[i] = 1
    else:
      a[i] = 0

if flag == 1:
  print(-1)
else:
  if N == 1:
    print(a[2])
  elif a[3 - N] == 0:
    print(-1)
  else:
    for i in range(N):
      ans = ans + a[2 - i] * (10 ** i)
      print(ans)