n, m = map(int, input().split())
ans = ["-1" for i in range(n)]
for i in range(m):
    s, c = input().split()
    s = int(s)
    if (s == 1 and c == '0'):
        print(-1)
        exit()
    if ans[s-1] == "-1" :
        ans[s-1] = c
    else:
        if ans[s-1] != c :
            print(-1)
            exit()
print(("".join(ans)).replace("-1", "1"))
