n, m = map(int, input().split())
ans = [1] + [0] * (n - 1)
flag1 = 0
flag2 = 0
for i in range(m):
    s, c = map(int, input().split())
    if s == 1:
        if c == 0 and n != 1:
            print("-1")
            exit()
        if (ans[s - 1] != 1 and ans[s - 1] != c) or (ans[s - 1] == 1 and flag1 == 1):
            print("-1")
            exit()
        if ans[s - 1] == 1 and c == 1:
            flag1 = 1
        ans[s - 1] = c
    else:
        if (ans[s - 1] != 0 and ans[s - 1] != c) or (ans[s - 1] == 0 and flag2 == 1):
            print("-1")
            exit()
        if ans[s - 1] == 0 and c == 0:
            flag2 = 1
    ans[s - 1] = c
print(*ans, sep = "")