N,M = map(int,input().split())
ans = ["0" for i in range(N)]
ans[0] = "1"
flag = True
count = 0
for i in range(M):
    s,c = map(int,input().split())
    s -= 1
    c = str(c)
    if s != 0:
        if ans[s] != "0":
            if ans[s] != c:
                flag = False
        else:
            ans[s] = c
    else:
        if c=='0':
            flag = False
            
        if count != 0:
            if ans[s] != c:
                flag = False
        else:
            count += 1
            ans[s] = c
ans1 = ''.join(ans)
print('-1' if flag==False else ans1)