N,M = map(int,input().split())
if M == 0:
  if N == 1:
    print(0)
    exit()
  elif N == 2:
    print(10)
    exit()
  else:
    print(100)
    exit()
dic = {} 
for _ in range(M):
  s,c = map(int,input().split())
  if s in dic and dic[s] != c:
    print(-1)
    exit()
  else:
    dic[s] = c
if N != 1 and dic[1] == 0:
  print(-1)
  exit()
ans = ''
for i in range(N):
  if i+1 in dic:
    ans += str(dic[i+1])
  elif i+1 == 1:
    ans += '1'
  else:
    ans += '0'
print(ans)