n,m = map(int,input().split())
ans = ["-1"]*n

for _ in range(m):
    s,c = input().split()
    s = int(s)-1
    if ans[s] != "-1" and ans[s] != c: 
        print(-1)
        exit()
    ans[s] = c

if n != 1 and ans[0] == "0":
    print(-1)
    exit()

for i in range(n):
    if ans[i] == "-1":
        ans[i] = "0" if i != 0 else "1"

print("".join(ans))