------
## 最终结论
```python
def create_unique_elements_set(a):
    unique_elements = set(a)
    return unique_elements

def check_unique_elements_count(unique_elements, k):
    if len(unique_elements) > k:
        return "-1"
    return None

def create_base_pattern(unique_elements, k, n):
    pattern = list(unique_elements)
    
    # If pattern length is less than k, fill it with any element from 1 to n
    while len(pattern) < k:
        for i in range(1, n + 1):
            if i not in pattern:
                pattern.append(i)
                break
                
    return pattern

def fill_pattern_if_necessary(pattern, k, n):
    # If pattern length is less than k, fill it with any element from 1 to n
    while len(pattern) < k:
        for i in range(1, n + 1):
            if i not in pattern:
                pattern.append(i)
                break
    return pattern

def calculate_required_length(n, k):
    # The minimum length m for the beautiful array should be at least n and a multiple of k
    m = ((n + k - 1) // k) * k
    return m

def repeat_pattern_to_achieve_length(pattern, n, k):
    # Calculate the minimum length m for the beautiful array
    m = ((n + k - 1) // k) * k
    # Repeat the pattern to make the array length at least n
    beautiful_array = (pattern * ((m + k - 1) // k))[:m]
    return m, beautiful_array

def append_results(results, m, beautiful_array):
    results.append(f"{m}")
    results.append(" ".join(map(str, beautiful_array)))

def process_test_cases(t, test_cases):
    results = []
    
    for case in test_cases:
        n, k = case[0]
        a = case[1]
        
        unique_elements = create_unique_elements_set(a)
        
        result = check_unique_elements_count(unique_elements, k)
        if result == "-1":
            results.append("-1")
            continue
        
        base_pattern = create_base_pattern(unique_elements, k, n)
        
        filled_pattern = fill_pattern_if_necessary(base_pattern, k, n)
        
        required_length, beautiful_array = repeat_pattern_to_achieve_length(filled_pattern, n, k)
        
        append_results(results, required_length, beautiful_array)
    
    return results

# Example usage:
t = 4
test_cases = [
    [(4, 2), [1, 2, 2, 1]],
    [(4, 3), [1, 2, 2, 1]],
    [(3, 2), [1, 2, 3]],
    [(4, 4), [4, 3, 4, 2]]
]

results = process_test_cases(t,test_cases)
for result in results:
   print(result)
```