N, M = map(int, input().split())
sc = []
tf = True
for i in range(M):
  sc.append(list(map(int, input().strip().split()))
num = []
for i in range(N):
  num.append(0)
for i in sc:
  if i[0] == N and i[1] == 0:
    tf = False
  else:
    num[i[0]-1] = i[1]
if tf:
  num[0] = 1
string = ""
for i in num:
  string += str(i)
if tf:
  print(string)
else:
  print(-1)