import sys
n, m = map(int, input().split())
d = {}
for _ in range(m):
  s, c = map(int, input().split())
  if (s == 1 and c == 0) or (s in d and d[s] != c):
    print("-1")
    sys.exit()
  d[s] = c

for i in range(1, n+1):
  if i in d:
    print(d[i], end = "")
  else:
    print("1" if i == 1 else "0", end = "")
print()