import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M = list(map(int, sys.stdin.readline().split()))
    lines = [list(map(int, sys.stdin.readline().split())) for _ in range(M)]

    print(lines)
    ret = -1
    for n in range(0, pow(10, N)):
        if len(str(n)) != N:
            continue
        flg = True
        for s, c in lines:
            if str(n)[s - 1] != str(c):
                flg = False

        if flg:
            ret = n
            break

    print(ret)


if __name__ == '__main__':
    main()
