N,M = map(int,input().split())
SC = []
for i in range(M):
  SC.append(list(map(int,input().split())))

if M == 0:
  if N == 1:
    print(0)
  else:
    print(-1)
  exit()
  
ans = []
for i in range(N):
  ans.append('a')
for s,c in SC:
  s -= 1
  if (ans[s] != 'a' and ans[s] != c) or (s == 0 and c == 0):
    print(-1)
    exit()
  else:
    ans[s] = c
for i in range(N):
  if ans[i] == 'a':
    if i == 0:
      ans[i] = 1
    else:
      ans[i] = 0
print(*ans, sep ='')