N, M = map(int, input().split())
ds = [-1]*N
for i in range(M):
  s, c = map(int, input().split())
  s = s-1
  if ds[s] < 0:
    ds[s] = c
  elif ds[s] != c:
    print(-1)
    exit()
if N > 1 and ds[0] == 0:
  print(-1)
  exit()
if ds[0] < 0:
  ds[0] = 1
for i in range(1, N):
  if ds[i] < 0:
    ds[i] = 0
r = "".join(map(str, ds))
print(r)
