def ans(M, nums):
    for _ in range(M):
        s, c = map(int, input().split())
        
        if nums[s-1] == -1:
            nums[s-1] = c
            continue
        else:
            if nums[s-1] != c: 
                return -1
    
    for i, num in enumerate(nums):
        if num != -1:
            continue
        else:
            if i == 0:
                nums[i] = 1
            else:
                nums[i] = 0
    
    ans = int(''.join(map(str, nums)))
    
    if len(str(ans)) == len(nums):
        return ans
    else:
        return -1

N, M = map(int, input().split())

nums = [-1 for i in range(N)]

print(ans(M, nums))