n, m = map(int, input().split())
l = [''] * n
ans = 0
for i in range(m):
  s, c = map(int, input().split())
  if ans == 0:
    if s == 1 and c == 0 and n >= 2:
      ans = -1
    else:
      if l[s - 1] == '':
        l[s - 1] = c
      elif l[s - 1] != '' and l[s - 1] == c:
        next
      elif l[s - 1] != '' and l[s - 1] != c:
        ans = -1

if ans == 0:
  ans = ''
  for i  in range(len(l)):
    if l[i] == '' and i != 0:
      l[i] = 0
    elif l[i] == '' and i == 0:
      l[i] = 1 
    ans += str(l[i])
print(ans)