import sys

# S = input()
# N, M = map(int, input().split())
# As = [int(input()) for _ in range(N)]
# nums = list(map(int, input().split()))
# nums_2d = [list(map(int, input().split())) for _ in range(N)]


def main():
    print(solve())


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

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

    minimum = 10 ** (N-1)
    if minimum == 1:
        minimum = 0
    maximum = 10 ** N - 1

    ans = -1
    for i in range(minimum, maximum+1):
        candidate = str(i)
        ok = True
        for s, c in scs:
            if candidate[s-1] != c:
                ok = False
                break
        if ok:
            ans = int(candidate)
            break

    return ans


if __name__ == '__main__':
    main()
