N, M = map(int, raw_input().split())
s = [0]*M
c = [0]*M
for i in range(M):
  s[i], c[i] = map(int, raw_input().split())
  s[i] -= 1

for i in range(0 if N==1 else 10**(N-1), 10**N):
  i = str(i)
  ok = True
  for j in range(M):
    if i[s[j]]!=str(c[j]):
      ok = False
  if ok:
    print i
    exit(0)
print -1
