N, M = map(int, input().split())
sets = dict()
key_list = list()

for i in range(M):
  s, c = map(str, input().split())
  c = int(c)
  
  if int(s) == 1 and c == 0:
    print(-1)
    exit()
  if s not in key_list:
    sets[s] = c
    key_list.append(s)
  elif s in key_list and sets[s] != c:
    print(-1)
    exit()

res = ''
for i in range(1, N+1):
  if i == 1 and str(i) not in key_list:
    res += '1'
  elif str(i) in key_list:
    res += str(sets[str(i)])
  else:
    res += '0'
print(res)