n, m = map(int, input().split())
tmp = [10]*n

for _ in range(m):
    s,c = map(int, input().split())
    tmp[s-1] = min(tmp[s-1],c)
for i in range(n):
    if tmp[i] == 10:
        if i == 0 and n != 1:
            tmp[i] = 1
        else:
            tmp[i] = 0

ans = ''.join(map(str,tmp))

if n != 1 and ans[0] == 0:
    print('-1')
else:
    print(ans)