def solve():
    from sys import stdin
    f_i = stdin
    
    N, M = map(int, f_i.readline().split())
    
    digits = [False] * N
    
    for i in range(M):
        s, c = f_i.readline().split()
        s = int(s)
        if digits[s-1] and digits[s-1] != c:
            return -1
        else:
            digits[s-1] = c
    
    if digits[0] == '0':
        if N > 1:
            return -1
        else:
            return 0
    
    if digits[0] == False:
        digits[0] = '1'
    
    for i, d in enumerate(digits[1:], start=1):
        if d == False:
            digits[i] = '0'
    
    ans = ''.join(digits)
    return ans

print(solve())