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

l = []

for i in range(m):
  l.append(list(map(int, input().split())))

ans = -1
for i in range(10 ** (n - 1), 10 ** n):
  s = str(i)
  result = True
  for x in l:
    if not s[x[0] - 1] == str(x[1]):
      result = False
      break
  if result:
    ans = i
    break

print(ans)

