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

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

print(S)