a = input().split()
A = [int(s) for s in a]
c = [10] * A[0]
b = [input().split() for i in range(A[1])]
B = [[int(s) for s in row]for row in b]
flag = 1
for i in range(A[1]):
  if c[B[i][0]-1] == 10:
    c[B[i][0]-1] = B[i][1]
  elif c[B[i][0]-1] != B[i][1]:
    flag = 0
if c[0] == 0:
  flag = 0
elif c[0] == 10:
  c[0] = 1
if flag == 1:
  for i in range(A[0]-1):
    if c[i+1] == 10:
      c[i+1] = 0
if flag:
    print(c)
else:
    print('-1')