# input
N, M = map(int, input().split())
s = [0]*M
c = [0]*M

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

    ans = [-1]*N
    b = True

    for i in range(M):
        if(ans[s[i]-1] != -1 and ans[s[i]-1] != c[i]):
            b = False
        else:
            ans[s[i]-1] = c[i]

    for i in range(len(ans)):
        if(i==0):
            ans[i] = 1
        elif(ans[i] == -1):
            ans[i] = 0
    
    if(N>1 and ans[0]==0):
        b = False
        
    if(b):
        ans_print = ""
        for i in range(len(ans)):
            ans_print += str(ans[i])
        print(ans_print)
    else:
        print("-1")