N, M = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(M)]

ans = ['A'] * N
for i, (si, ci) in enumerate(sc):
    if ans[si - 1] != 'A' and ans[si - 1] != str(ci):
        ans = -1
        break
    #
    ans[si - 1] = str(ci)

if ans == -1:
    print(ans)
else:
    ans = ''.join(ans).replace('A', '1')
    if ans[0] == '0':
        if N == 1:
            print(ans)
        else:
            print(-1)
    else:
        print(ans)