N, M = map(int, input().split(' '))
X = [list(map(int, input().split(' '))) for _ in range(M)]

def judge(i):
  I = str(i)
  for s, c in X:
    if I[s-1] != str(c):
      return False
  return True

def main():
  B = 10 ** (N - 1)
  T = 10 ** N
  for i in range(B, T):
    if judge(i):
      print(i)
      return
  else:
    print(-1)

main()