import sys
n, m = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(m)]

sc_ans = [-1] * n
for i in sc:
    if (sc_ans[i[0]-1] == i[1]) | (sc_ans[i[0]-1] == -1):
        sc_ans[i[0] - 1] = i[1]
    else:
        print(-1)
        sys.exit()

if sc_ans[0] == 0:
    print(-1)
    sys.exit()

for i in range(n):
    if sc_ans[i] == -1:
        if i == 0:
            sc_ans[i] = 1
        else:
            sc_ans[i] = 0

print(*sc_ans,sep='')
