N,M = list(map(int, input().split()))
S = set()
for _ in range(M):
  S.add(tuple(map(int, input().split())))
  
A = [1] + [0] * (N-1)
CH = [False] * N

for l in S:
  idx, num = l[0] - 1, l[1]
  if CH[idx]:
    print(-1)
    exit(0)
  if N > 1 and idx == 0 and num == 0:
    print(-1)
    exit(0)
  CH[idx] = True
  A[idx] = num
  
if len(S) == 0 and N == 1:
  print(1)
else:
  print("".join(list(map(str,A))))
