n, m = list(map(int, input().split()))
sc = [list(map(int,input().split())) for i in range(m)]

for i in range(0, 10**n):
  str_i = str(i)
  if len(str_i) != n: continue

  chk = True
  for s, c in sc:
    if str_i[s-1] == c:
      cnt &= str_i[s-1] == str(c)
  if chk:
    print(i)
    exit()

  print(-1)
     
    
  