def resolve():
    N, M = map(int, input().split())

    req = [list(map(int, input().split())) for i in range(M)]

    min_range = 10 ** (N - 1)
    max_range = 10 ** (N)

    for i in range(min_range, max_range):
        st = str(i)
        ok = True
        for s, c in req:
            if int(st[s - 1]) != int(c):
                ok = False
        if ok:
            print(st)
            return

    print(-1)