import numpy as np

n,m = map(int, input().split())
x = np.zeros(n)
ans = 0

for i in range(m):
  s,c = map(int, input().split())
  if x[s-1] == 0:
    x[s-1] = c
  elif x[s-1] == c:
    ans = -1

if ans == -1:
  print(ans)
else:
  str = ""
  for i in range(n):
    str = str + x[i]
  print(str)