import sys

n, m = list(map(int, input().split()))
ar = [list(map(int, input().split())) for _ in range(m)]
ans = [0 for _ in range(n)]

for a in ar:
    ans[a[0] - 1] = a[1]

if ans[0] == 0:
    print(-1)
    sys.exit()

ans = int("".join(map(str, ans)))