N, M = map(int, input().split())
guess = [-1] * N

for i in range(M):
  s, c = map(int, input().split())
  s = s - 1
  if s == 0 and c == 0:
    print(-1)
    exit()
  if guess[s] == -1:
    guess[s] = c
  elif guess[s] == c:
    continue
  else:
    print(-1)
    exit()
    
for i in range(len(guess)):
  if guess == [-1] * len(guess):
    guess[0] = 1
    guess[1:] = [0] * (len(guess)-1)
  elif guess[i] == -1:
    guess[i] = 0
res = map(str, guess)
print(''.join(res))