N, M = map(int, input().split())
if N==1 and M==0:
  print(0)
  import sys
  sys.exit()
ans = [-1]*N
for i in range(M):
  s,c = map(int,input().split())
  if ans[s-1]!=-1 and ans[s-1]!=c:
    print(-1)
    break
  ans[s-1] = c
else:
  for i in range(N):
    if ans[i]==-1:
      if i!=0:
        ans[i] = 0
      else:
        ans[i] = 1
    ans[i] = str(ans[i])
  a = ''.join(ans)
  if a[0]=='0':
    print(-1)
  else:
    print(a)
