def resolve():
    N, M = map(int, input().split())
    S = []
    C = []
    ans = ["-1"]
    for _ in range(M):
        s, c = map(int, input().split())
        S.append(s)
        C.append(c)
    for i in range(10**(N-1), 10**N):
        flag = 0
        for j in range(M):
            if str(i)[S[j]-1] != str(C[j]):
                flag = 1
        if flag == 0:
            ans.append(str(i))
    if len(ans) >= 2:
        ans = ans[1:]
    print(ans[0])
resolve()