import sys
n, m = map(int, input().split())

d = dict()

for _ in range(m):
  s, c = input().split()
  if s in d.keys() and d[s] != c:
    print(-1)
    sys.exit()
  d[s] = c

if n != 1 and m == 0:
  print(10 ** (n - 1))
  sys.exit()

if n != 1 and d['1'] == '0':
  print(-1)
  sys.exit()

s = ["0"] * n

for i, e in d.items():
  s[int(i) - 1] = e

print(''.join(s))