import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


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

    N, M = il()
    SC = [il() for _ in range(M)]
    mi = pow(10, N-1)
    mx = pow(10, N)

    ret = float('inf')
    for n in range(mi, mx):
        print(n)
        isSC = True
        for sc in SC:
            s, c = sc
            if str(n)[s-1] != str(c):
                isSC = False

        if isSC:
            ret = min(ret, n)

    print(ret if ret < mx else -1)


if __name__ == '__main__':
    main()
