nm = input()
N, M = map(int, nm.split())
sc = []
for i in range(M):
  sc.append(input().split())
r = '0'*N
for (s,c) in sc:
  s = int(s)
  if s>N or r[s] != '0':
    print(-1)
    return
  r[s] = c
 
if N==1 and r=='0': 
  print(0)
  return 
 
for i in range(N):
  if i==0 and r[i] == '0':
    r[i] = '1'
print(r)