import itertools
n, m = map(int, input().split())
memo = dict()
ans = 100000000
arr = [0] * 10
memo = [0] * n
check = False
for _ in range(m):
  s, c = map(int, input().split())
  if arr[s]==0:
    arr[s] += 1
    memo[s-1]=c
  if arr[s] > 1:
    ans=-1
    check = True
  
if memo[0]==0 and check:
  ans=-1
else:
  ans = ""
  for m in memo:
    ans += str(m)
print(ans)
