N, M = map(int,input().split())
v = set()
for i in range(M):
    x, y = map(int, input().split())
    x -= 1
    v.add((x,str(y)))

if M==0:
    print(-1)
    exit()


ans = '0'*N
for i in range(10**N):
    n = str(i).zfill(N)
    fl = True
    if n[0]=='0':
        continue
    for a,b in v:
        if n[a] != b:
            fl = False
            break
    if fl:
        ans = n
        if ans == '0'*N:
            print(-1)
            exit()
        else:
            print(ans)
            exit()

print(-1)