N, M = list(map(int, input().split()))
sc = []
for i in range(M):
    sc.append(list(map(int, input().split())))
    
num = "a" * N

for i in range(M):
    s,c = sc[i][0], sc[i][1]
    if num[s-1] == "a":
        num = num[:s-1] + str(c) + num[s:]
    else:
        if num[s-1] == str(c):
            continue
        else:
            print(-1)
            break

        
else:
    if (len(num) != 1) and (num[0] == "0"):
        print(-1)
    else:
        num = num.replace("a", "0")
        if num[0] == "0":
            num = "1" + num[1:]
    
        print(num)
    
