
def resolve():
    N, M = map(int, input().split())
    S, C = [0] * M, [0] * M
    for i in range(M):
        S[i], C[i] = map(int, input().split())

    def main():
        if M == 0:
            if N == 1:
                return 10
            elif N == 2:
                return 10
            else:
                return 100
        else:
            for j in range(10 ** (N - 1), 10 ** (N)):
                for i in range(M):
                    if str(j)[S[i] - 1] != C[i]:
                        break
                    elif i == M - 1:
                        return j


    val=main()
    print(val if val != None else -1)

resolve()