def main():
    N, M = map(int, input().split())
    S, C = [0]*M, [0]*M
    for i in range(M):
        S[i], C[i] = map(int, input().split())
    ans = -1
    for i in range(10**(N-1), 10**N):
        found = True
        for j in range(M):
            s, c = N - S[j], C[j]
            if s > 1 and s == N - 1 and c == 0:
                found = False
                break
            v = (i // (10**s)) % 10
            if v != c:
                found = False
                break
        if found:
            ans = i
            break
    print(ans)

if __name__ == '__main__':
    main()
