N, M = map(int,input().split())
S = "0" * N

for i in range(M):
    s,c = map(int,input().split())
    if s == 1 and c == 0 and N != 1:
        print("-1")
        quit()
    elif S[s-1] == "0" or S[s-1] == str(c):
        S = S[0:s-1] + str(c) + S[s:-1]
    else:
        print("-1")
        quit()

if S[0] == "0" and N != 1:
    S = "1" + S[1:-1]

print(S)