N,M = map(int,input().split())

lst = [-1]*N
flag = False

for _ in range(M):
  s,c = map(int,input().split())
  if lst[s-1] != -1 and lst[s-1] != c:
    flag = True
  elif s == 1 and c == 0 and N != 1:
    flag = True
  else:
    lst[s-1] = c

    
if flag:
  print("-1")
elif N == 1 and lst[0] == 0:
  print("0")
else:
  for i in range(N):
    if i == 0 and lst[i] == -1:
      lst[i] = 1
    elif lst[i] == -1:
      lst[i] = 0
  print("".join(map(str,lst)))