n,m = map(int, input().split())
dic = {}
ans = ['0'] * n
for _ in range(m):
  s,c = input().split()
  if (s in dic and dic[s] != c) or (s == '1' and c == '0'):
    print(-1)
    break
  ans[int(s)-1] = c
  dic[s] = c
else:
  if ans[0] == '0':
    ans[0] = '1'
  print(''.join(ans))