N, M = map(int, input().split())
D = dict()

for i in range(M):
    k, v = input().split()
    k = int(k)
    if k in D:
        if D[k] != v:
            print(-1)
            exit()
    else:
        D[k] = v

ans = list('0' * N)

if 1 in D:
    if D[1] == '0':
        print(-1)
        exit()

for k, v in D.items():
    ans[k - 1] = v

if N != 1 and ans[0] == '0':
    ans[0] = '1'

print("".join(ans))