import sys
from collections import defaultdict

N, M = map(int, input().split())
d = defaultdict(int)

for i in range(M):
    s, c = map(int, input().split())
    if (d[s]!=0) & (d[s]!=c):
        print(-1)
        sys.exit()
    elif (s==1) & (c==0):
        print(-1)
        sys.exit()
    elif d[s]==0:
        d[s] = c
    else:
        continue

ans = ["1"] + ["0"] * (N - 1)

for s, c in d.items():
    ans[int(s) - 1] = str(c)

print("".join(ans))