import sys
import os

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)]
isn = lambda n: [int(sys.stdin.buffer.readline().split()) 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 = isn(M)
    tmp = [0] * N
    for sc in SC:
        s, c = map(int, sc.split())
        tmp[s - 1] = c

    tmp = int(''.join(map(str, tmp)))

    mi = 10 ** (N - 1)
    mx = 10 ** N
    for n in range(mi, mx):
        if n == tmp:
            print(n)
            exit()
    else:
        print(-1)


if __name__ == '__main__':
    main()
