def solve():

    nm = [int(s) for s in input().split()]
    N = nm[0]
    M = nm[1]
    F = dict()
    for _ in range(M):
        sc = [int(s) for s in input().split()]
        s, c = sc[0], sc[1]
        if s-1 in F:
            if F[s-1] != c:
                print(-1)
                return
        else:
            F[s-1] = c
    for i in range(10**(N-1), 10**N):
        num = str(i)
        found = True
        for key in F:
            if F[key] != int(num[key]):
                found = False
        if found:
            print(num)
            return
    print(-1)
solve()
        
    