[N, M] = [int(i) for i in input().split()]
num_dict = {}
for i in range(M):
  [s, c] = [int(i) for i in input().split()]
  if s in num_dict:
    if num_dict[s] != c:
      print('-1')
      exit()
  else:
  	num_dict[s] = c
ans = '0' * N
for key in num_dict.keys():
  ans = ans[:key-1] + str(num_dict[key]) + ans[key:]
if ans == '0':
  pass
elif set(ans) == {'0'}:
  print('-1')
  exit()
elif ans[0] == '0':
  ans = '1' + ans[1:]
print(ans)