Problem: A PIN code is a string that consists of exactly 4 digits. Examples of possible PIN codes: 7013, 0000 and 0990. Please note that the PIN code can begin with any digit, even with 0.

Polycarp has n (2 ≤ n ≤ 10) bank cards, the PIN code of the i-th card is p_i.

Polycarp has recently read a recommendation that it is better to set different PIN codes on different cards. Thus he wants to change the minimal number of digits in the PIN codes of his cards so that all n codes would become different.

Formally, in one step, Polycarp picks i-th card (1 ≤ i ≤ n), then in its PIN code p_i selects one position (from 1 to 4), and changes the digit in this position to any other. He needs to change the minimum number of digits so that all PIN codes become different.

Polycarp quickly solved this problem. Can you solve it?

Input

The first line contains integer t (1 ≤ t ≤ 100) — the number of test cases in the input. Then test cases follow.

The first line of each of t test sets contains a single integer n (2 ≤ n ≤ 10) — the number of Polycarp's bank cards. The next n lines contain the PIN codes p_1, p_2, ..., p_n — one per line. The length of each of them is 4. All PIN codes consist of digits only.

Output

Print the answers to t test sets. The answer to each set should consist of a n + 1 lines

In the first line print k — the least number of changes to make all PIN codes different. In the next n lines output the changed PIN codes in the order corresponding to their appearance in the input. If there are several optimal answers, print any of them.

Example

Input


3
2
1234
0600
2
1337
1337
4
3139
3139
3139
3139


Output


0
1234
0600
1
1337
1237
3
3139
3138
3939
6139

Solution (in JAVA):

Solution:

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.function.Function;

public class P1263B {
    
    static boolean multipleIndependent = true;
    
    static int min = 0;
    
    static void run() {
        int n = in.nextInt();
        List<String> pins = new ArrayList<>();
        LinkedList<Integer> nums = new LinkedList<>();
        for (int i = 0; i < 10; i++) {
            nums.add(i);
        }
        while (n-- > 0) {
            String next = in.next();
            pins.add(next);
            nums.removeFirstOccurrence(next.charAt(0) - '0');
        }
        min = 0;
        List<String> newPins = new ArrayList<>();
        pins.forEach(pin -> {
            if (!newPins.contains(pin)) {
                newPins.add(pin);
            } else {
                char c = (char) (nums.pop() + '0');
                newPins.add(c + pin.substring(1));
                min++;
            }
        });
        System.out.println(min);
        newPins.forEach(System.out::println);
    }

    /* -----: Template :----- */
    static InputReader in = new InputReader(System.in);
    
    public static void main(String[] args) {
        int q = multipleIndependent ? in.nextInt() : 1;
        while (q-- > 0) {
            run();
        }
    }
    
    static class InputReader {
        
        private final BufferedReader reader;
        private StringTokenizer tokenizer;
        
        public InputReader(InputStream stream) {
            int bufferSize = 32 * 1024;
            reader = new BufferedReader(new InputStreamReader(stream), bufferSize);
            tokenizer = null;
        }
        
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        
        public int nextInt() {
            return Integer.parseInt(next());
        }
        
        public long nextLong() {
            return Long.parseLong(next());
        }
        
        public int[] nextIntArray(int n) {
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }
        
        public <T> T[] nextIntArrayWithFunction(int n, Function<Integer, T> function, Class<T> c) {
            T[] arr = (T[]) Array.newInstance(c, n);
            for (int i = 0; i < n; i++) {
                arr[i] = function.apply(nextInt());
            }
            return arr;
        }
        
        public long[] nextLongArray(int n) {
            long[] arr = new long[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }
        
        public <T> T[] nextLongArrayWithFunction(int n, Function<Long, T> function, Class<T> c) {
            T[] arr = (T[]) Array.newInstance(c, n);
            for (int i = 0; i < n; i++) {
                arr[i] = function.apply(nextLong());
            }
            return arr;
        }
        
        public int[][] nextIntMap(int n, int m) {
            int[][] map = new int[n][m];
            for (int i = 0; i < n; i++) {
                map[i] = nextIntArray(m);
            }
            return map;
        }
        
        public long[][] nextLongMap(int n, int m) {
            long[][] map = new long[n][m];
            for (int i = 0; i < n; i++) {
                map[i] = nextLongArray(m);
            }
            return map;
        }
        
        public char[][] nextCharMap(int n) {
            char[][] map = new char[n][];
            for (int i = 0; i < n; i++) {
                map[i] = next().toCharArray();
            }
            return map;
        }
    }

//    static int numLength(long n) {
//        int l = 0;
//        while (n > 0) {
//            n /= 10;
//            l++;
//        }
//        return l;
//    }
//
//    static <R> long binarySearch(long lowerBound, long upperBound,
//            R value, Function<Long, R> generatorFunction, Comparator<R> comparator) {
//        if (lowerBound <= upperBound) {
//            long mid = (lowerBound + upperBound) / 2;
//            int compare = comparator.compare(generatorFunction.apply(mid), value);
//            if (compare == 0) {
//                return mid;
//            } else if (compare < 0) {
//                return binarySearch(mid + 1, upperBound, value, generatorFunction, comparator);
//            } else {
//                return binarySearch(lowerBound, mid - 1, value, generatorFunction, comparator);
//            }
//        } else {
//            return -1;
//        }
//    }
//
//    static <T> Integer[] sortSimultaneously(T[] key, Comparator<T> comparator,
//            Object[]... moreArrays) {
//        int n = key.length;
//        for (Object[] array : moreArrays) {
//            if (array.length != n) {
//                throw new RuntimeException("Arrays must have equals lengths");
//            }
//        }
//        Integer[] indices = new Integer[n];
//        for (int i = 0; i < n; i++) {
//            indices[i] = i;
//        }
//        Comparator<Integer> delegatingComparator = (a, b) -> {
//            return comparator.compare(key[a], key[b]);
//        };
//        Arrays.sort(indices, delegatingComparator);
//        reorder(indices, key);
//        for (Object[] array : moreArrays) {
//            reorder(indices, array);
//        }
//        return indices;
//    }
//
//    static void reorder(Integer[] indices, Object[] arr) {
//        if (indices.length != arr.length) {
//            throw new RuntimeException("Arrays must have equals lengths");
//        }
//        int n = arr.length;
//        Object[] copy = new Object[n];
//        for (int i = 0; i < n; i++) {
//            copy[i] = arr[indices[i]];
//        }
//        System.arraycopy(copy, 0, arr, 0, n);
//    }
//    static int prodMod(int a, int b, int mod) {
//        return (int) (((long) a) * b % mod);
//    }
//
//    static long prodMod(long a, long b, long mod) {
//        long res = 0;
//        a %= mod;
//        b %= mod;
//        while (b > 0) {
//            if ((b & 1) > 0) {
//                res = (res + a) % mod;
//            }
//            a = (a << 1) % mod;
//            b >>= 1;
//        }
//        return res;
//    }
//
//    static long sumMod(int[] b, long mod) {
//        long res = 0;
//        for (int i = 0; i < b.length; i++) {
//            res = (res + b[i] % mod) % mod;
//        }
//        return res;
//    }
//
//    static long sumMod(long[] a, long mod) {
//        long res = 0;
//        for (int i = 0; i < a.length; i++) {
//            res = (res + a[i] % mod) % mod;
//        }
//        return res;
//    }
//
//    static long sumProdMod(int[] a, long b, long mod) {
//        long res = sumMod(a, mod);
//        return prodMod(res, b, mod);
//    }
//
//    static long sumProdMod(long[] a, long b, long mod) {
//        long res = sumMod(a, mod);
//        return prodMod(res, b, mod);
//    }
//
//    static long sumProdMod(int[] a, int[] b, long mod) {
//        if (a.length != b.length) {
//            throw new RuntimeException("Arrays must have equals lengths");
//        }
//        long res = 0;
//        for (int i = 0; i < a.length; i++) {
//            res = (res + prodMod(a[i], b[i], mod)) % mod;
//        }
//        return res;
//    }
//
//    static long sumProdMod(long[] a, long[] b, long mod) {
//        if (a.length != b.length) {
//            throw new RuntimeException("Arrays must have equals lengths");
//        }
//        long res = 0;
//        for (int i = 0; i < a.length; i++) {
//            res = (res + prodMod(a[i], b[i], mod)) % mod;
//        }
//        return res;
//    }
    static int[] toPrimitive(Integer[] arr) {
        int[] res = new int[arr.length];
        for (int i = 0; i < arr.length; i++) {
            res[i] = arr[i];
        }
        return res;
    }
    
    static int[][] toPrimitive(Integer[][] arr) {
        int[][] res = new int[arr.length][];
        for (int i = 0; i < arr.length; i++) {
            res[i] = toPrimitive(arr[i]);
        }
        return res;
    }
    
    static long[] toPrimitive(Long[] arr) {
        long[] res = new long[arr.length];
        for (int i = 0; i < arr.length; i++) {
            res[i] = arr[i];
        }
        return res;
    }
    
    static long[][] toPrimitive(Long[][] arr) {
        long[][] res = new long[arr.length][];
        for (int i = 0; i < arr.length; i++) {
            res[i] = toPrimitive(arr[i]);
        }
        return res;
    }
    
    static Integer[] toWrapper(int[] arr) {
        Integer[] res = new Integer[arr.length];
        for (int i = 0; i < arr.length; i++) {
            res[i] = arr[i];
        }
        return res;
    }
    
    static Integer[][] toWrapper(int[][] arr) {
        Integer[][] res = new Integer[arr.length][];
        for (int i = 0; i < arr.length; i++) {
            res[i] = toWrapper(arr[i]);
        }
        return res;
    }
    
    static Long[] toWrapper(long[] arr) {
        Long[] res = new Long[arr.length];
        for (int i = 0; i < arr.length; i++) {
            res[i] = arr[i];
        }
        return res;
    }
    
    static Long[][] toWrapper(long[][] arr) {
        Long[][] res = new Long[arr.length][];
        for (int i = 0; i < arr.length; i++) {
            res[i] = toWrapper(arr[i]);
        }
        return res;
    }
}