n,m = map(int,input().split())
ans = []
for i in range(n):
    ans.append(0)
for k in range(m):
    s,c = map(int,input().split())
    if c == 0:
        c = 10    
    if ans[s-1] == 0 or ans[s-1] == c:
        ans[s-1] = c
    else:
        print('-1')
        exit()
if ans[0] == 10:
    print('-1')
    exit()
ans = [str(s) for s in ans]
ans = [s.replace("10","0") for s in ans]
print("".join(ans))