n, m = map(int, input().split())
x = ['x','x','x']
for _ in range(m):
  s, c = input().split()
  i = int(s)-1
  if c != x[i] and x[i] in ['0','1','2','3','4','5','6','7','8','9']:
    print(-1)
    exit()
  else:
    x[i] = c
j = ''.join(x)
r = j.replace('x','1')
if n != len(str(int(r))):
  print(-1)
  exit()
print(r)
