import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, M = map(int, readline().split())
m = map(int,read().split())
SC = list(zip(m,m))

#print(N, M)
#print(SC)

ans = -1
for n in range(10**(N-1), 10**N):
  str_n = str(n)
  all_ok = True
  for s, c in SC:
    if int(str_n[s-1]) != c:
      all_ok = False
      break
  
  if all_ok:
    ans = n
    break
    
print(ans)