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]:
                                return j
        print(main() if main()!=None else -1)


resolve()