n,m = map(int,input().split())
l = [0 for i in range(n)]
rl = [0 for i in range(n)]
if n != 1:
    l[0] = 1
k = 0
for i in range(m):
    s,c = map(int,input().split())
    s -= 1
    if s == 0:
        if c == 0:
            k = 1
            break
        else:
            if rl[s] == 0:
                l[s] = c
                rl[s] = 1
            else:
                if l[s] != c:
                    k = 1
                    break
    else:
        if rl[s] == 0:
            l[s] = c
            rl[s] = 1
        else:
            if l[s] != c:
                k = 1
                break
if k == 1:
    print(-1)
else:
    for i in l:
        print(i,end="")