flag = 1
keta,n = map(int,input().split())
sc = []
for i in range(n):
    sc.append(list(map(int,input().split())))

ans = [None]*n

for j in sc:
    if j[0] == 1 and j[1] == 0:
        flag = 0
    if ans[j[0]-1] == None:
        ans[j[0]-1] = j[1]
    elif ans[j[0]-1] == j[1]:
        pass
    else:
        flag = 0


else:
    for k in range(len(ans)):
        if k == 0 and ans[0] == 0:
            ans[0] = 1
        elif ans[k] == None:
            ans[k] = 0
ans_s = ""
for l in ans:
    ans_s += str(l)
    
if flag == 0:
    print("-1")        
else:
    print(ans_s) 