n,m = map(int,input().split())
d = {}
for _ in range(m):
  s,c = map(int,input().split())
  if s ==1 and c ==0:
    print(-1)
    exit()
  if s in d:
    if d[s] == c:
      continue
    else:
      print(-1)
      exit()
  else:
    d[s] = c

print(d)
ans = ''
flag = False
for i in range(1,n+1):
  if i in d:
    if d[i] != 0:
      flag = True
    ans += str(d[i])
  else:
    if flag:
      ans += '0'
    else:
      ans += '1'
      flag = True
print(ans)



