n, m = map(int, input().split())
d = [-1 for i in range(n)]
flag = True

for i in range(m):
  s, c = map(int, input().split())
  if d[s - 1] > -1 and d[s - 1] != c:
    flag = False
  elif s == 1 and n > 1 and c == 0:
    flag = False
  else:
    d[s - 1] = c

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