n, m = map(int, input().split())
sc = []
for _ in range(m): sc.append([int(x) for x in input().split()])
ans = [None for _ in range(n)]
for s, c in sc:
    s -= 1
    if s == 0 and c == 0:
        if n != 1:
            ans = -1
            break
    if ans[s] is None: ans[s] = c
    elif ans[s] != c:
        ans = -1
        break
if ans == -1: print("{}".format(ans))
else:
    for i in range(n):
        if ans[i] is not None: continue
        else:
            if i == 0: ans[i] = 1
            else: ans[i] = 0
    a = ""
    for i in range(n): a += str(ans[i])
    print(a)