def solve():
    N, M = map(int, input().split())
    A = [list(map(int, input().split())) for _ in range(M)]

    l = [0 for _ in range(N)]
    
    for a, b in A:
        l[a-1] = b

    
    ans = int(''.join(list(map(str, l))))
        
    if l[0] == 0:
        ans = -1
    if len(str(ans)) != N:
        ans = -1
    
    return ans

print(solve())