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

digit_dict = {digit: '*' for digit in range(1, N + 1)}

for _ in range(M):
  s, c = map(int, input().split())
  
  if digit_dict[s] == '*':
    digit_dict[s] = c
  elif digit_dict[s] != c:
    print(-1)
    exit()

for key, value in digit_dict.items():
  if key == 1 and value == 0:
    print(-1)
    exit()
  
  if value != '*':
    continue
  
  if key == 1:
    digit_dict[key] = 1
  else:
    digit_dict[key] = 0

print(''.join(list(map(str, digit_dict.values()))))