n, m = map(int, input().split())
num = [" " for x in range(n)]
ans = " "

for i in range(m):
    s, c = map(int, input().split())
    c = str(c)
    
    if num[s - 1] == " " :
        num[s - 1] = c
    
    elif num[s - 1] == c :
        continue
    
    else:
        ans = -1
        break
        
if num[0] == "0":
    if n == 1:
        print(0)
    else:
        print(-1)

elif num[0] == " ":
    if n == 1:
        print(0)
    else:
        num[0] = "1"

else:
    for j in range(n):
        if num[j - 1] == " ":
            num[j - 1] = "0"
            print("".join(num))