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

for i in range(10**(n-1), 10**n):
  tmp = str(i)
  flag = True
  for s, c in digit:
    if tmp[s-1] != str(c):
      flag = False
  if flag:
    print(i)
    exit()
print(-1)
  
