line = list(input().split(" "))
n = int(line[0])
m = int(line[1])
result = ["x" for i in range(n+1)]
for i in range(m):
    line = list(input().split(" "))
    s = int(line[0])
    c = int(line[1]) 
    if result[s] != "x" and result[s] != c:
        print(-1)
        exit()
    if s == 1 and c == 0:
        print(-1)
        exit()
    result[s] = c
if result[1] == "x":
    result[1] == 1
for i in range(n):
    if result[i+1] == "x":
        result[i+1] = 0
    print(result[i+1],end = "")
print()