n,m = map(int, input().split())
nums = [-1]*n
for _ in range(m):
  s,c = map(int, input().split())
  s = int(s)-1
  if nums[s] != -1 and nums[s] != c:
    print(-1)
    exit()
  nums[s] = c
  
for i in range(n):
  if nums[i] == -1:
    if i == 0:
      if n == 1:
        nums[0] = 0
      else:
        nums[0] = 1
    else:
      nums[i] = 0
ans = ""
for i in nums:
  ans += str(i)
print(ans)