N, M = map(int, input().split())
C = [tuple(map(int, input().split())) for _ in range(M)]
ans = 10 ** (N - 1)
while ans < 10 ** N:
    for s, c in C:
        if str(ans)[s - 1] == str(c):
            pass
        else:
            break
    else:
        print(ans)
        break
    ans += 1
else:
    print(-1)
