import numpy as np

def main():

    N, M = list(map(int, input().split()))

    num = [0] * N
    num[0] = 1

    used = set()
    pair = []
    for i in range(M):
        s, c = list(map(int, input().split()))
        if s == 1 and c == 0:
            print(-1)
            return

        if s in used and [s,c] not in pair:
            print(-1)
            return

        num[s - 1] = c
        used.add(s)
        pair.append([s,c])

    for c in num:
        print(c, end="")
    print()
        


main()