a = input().split()
n = int(a[0])
m = int(a[1])

d = {}
ret = True
for i in range(m):
  a = input().split()
  s = int(a[0])
  c = int(a[1])
  if (d.get(s,-1) != -1) & (d.get(s,-1) != c):
    ret = False
  if (s == 1) & (c == 0):
    ret = False
  d[s] = c

p = ""    
for i in range(1,n+1):
  if d.get(i,-1) == -1:
    if i == 1:
      p += "1"
    else:
      p += "0"
  else:
    p += str(d[i])
if ret:
  print(p)
else:
  print("-1")