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.util.*;
import java.io.*;

public class E1260 {
    public static void pri_result(int i) {
        System.out.println(i);
        System.exit(0);
    }

    public static void SolveA() {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        int[] r = new int[t];
        int[] g = new int[t];
        int[] b = new int[t];
        for (int i = 0; i < t; i++) {
            r[i] = sc.nextInt();
            g[i] = sc.nextInt();
            b[i] = sc.nextInt();
        }

        for (int i=0; i< t; i++) {
            int answer;
//            answer = Math.min( r[i] + g[i], b[i]);
//            answer = Math.max (answer, 
//                    Math.min(r[i] + b[i], g[i])
//            );
//            answer = Math.max (answer,
//                    Math.min(g[i] + b[i], r[i])
//                    );

            int a[] = new int[3];
            a[0] = r[i]; a[1] = g[i]; a[2] = b[i];
            Arrays.sort(a);
//            int answer1 = Math.min(a[0] + a[1], a[2]);           
//            answer = a[0];
//            if (a[0] % 2 == 1)
//                a[2] -= 1;
//            a[2] -= a[0]/2;
//            a[1] -= a[0]/2;
//            answer = a[0] + Math.min(a[1],a[2]);
            // make a[1] the same as a[2]
            if (a[0] + a[1] <= a[2]) {
                System.out.println(a[0] + a[1]);
            }
            else {
                a[0] -= a[2] - a[1];
                System.out.println(a[0]/2 + a[2]);
            }
            // System.out.println( Math.max(answer, answer1));
        }
        System.exit(0);
    }

    public static int calpc(char [] pc) {
        int k1 = 1;
        int pc1 = 0;
        for (int k= 3; k>=0; k --) {
            pc1 += (pc[k] - '0' ) * k1;
            k1 *=10;
        }
        return pc1;
    }
    public static char upp(char pc) {
        if (pc == '9')
            return '0';
        else
            return (++pc);
    }

    public static void SolveB() {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        
        for (int i = 0; i < t; i++) {
            int n = sc.nextInt();
            char [][] p = new char [n][4];
            int [] p1 = new int [n];
            HashSet<Integer> ap = new HashSet();
            HashSet<Integer> ap1= new HashSet();
            int changes = 0;
            
            for (int j=0; j< n; j++){
                p[j] = sc.next().toCharArray();
                p1[j] = calpc(p[j] );
                ap.add(p1[j]);                
                ap1.add(p1[j]);
            }
            

            for (int j=0; j<n; j++) {
                if (ap1.contains(p1[j])){
                    ap1.remove(p1[j]);
                    continue;
                }
                changes ++;
                // change each digit up or down
                for (int k = 0; k < 4; k++) {
                    // change digit k
                    char savec = p[j][k];
                    p[j][k] = upp(p[j][k]);
                    int pcnew = calpc(p[j]);
                    if (!ap.contains(pcnew)) {
                        ap.add(pcnew);
                        break;
                    }
                    p[j][k] = upp(p[j][k]);
                    pcnew = calpc(p[j]);
                    if (!ap.contains(pcnew)) {
                        ap.add(pcnew);
                        break;
                    }                    
                    p[j][k] = savec;
                    if (p[j][k] == '0') {
                        p[j][k] = '9';
                    }
                    else
                        p[j][k] --;
                    pcnew = calpc(p[j]);
                    if (!ap.contains(pcnew)) {
                        ap.add(pcnew);
                        break;
                    }
                    p[j][k] = savec;
                }
            }
            System.out.println(changes);
            for (int j=0; j<n; j++) {
                for (int k=0; k< 4; k++)
                    System.out.print(p[j][k]);
                System.out.println();
            }
        }
        System.exit(0);
    }

    public static void SolveC() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        Integer [] a = new Integer [n];

        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);

        int mc = 0;
        long total = 0L;
        long [] adds = new long [m];
        long [] ans  = new long [n];
        for (int i = 0; i < n; i++) {
            adds[mc] += a[i];
            total += adds[mc];
            ans[i] = total;
 
            mc++;
            if (mc >= m) {
                mc = 0;
            }
        }
        for (int i=0; i< n; i++)
            System.out.print(ans[i] + " ");
        System.out.println();
        System.exit(0);
    }

    public static void SolveC2() {
	PrintWriter out = new PrintWriter(System.out);        
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        Integer [] a = new Integer [n];

        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);

        int mc = 0;
        long total = 0L;
        long [] adds = new long [m];
        long [] ans  = new long [n];
        for (int i = 0; i < n; i++) {
            adds[mc] += a[i];
            total += adds[mc];
            ans[i] = total;
 
            mc++;
            if (mc >= m) {
                mc = 0;
            }
        }
        for (int i=0; i< n; i++)
            out.print(ans[i] + " ");
        out.println();
        out.close();
        System.exit(0);
    }

    public static void D_aux(int i, int j) {
        int i1 = i + 1;
        int j1 = j + 1;
        pw.println(i1 + " " + j1);
    }

    static PrintWriter pw; 
    public static void SolveD() {
        Scanner sc = new Scanner(System.in);
        pw = new PrintWriter(new BufferedOutputStream(System.out));
        int n = sc.nextInt();
        char[] l = new char[n];
        char[] r = new char[n];
        int[][] lc = new int[27][n + 1];
        int[][] rc = new int[27][n + 1];

        l = sc.next().toCharArray();
        r = sc.next().toCharArray();

        for (int i = 0; i < n; i++) {
            if (l[i] == '?') {
                lc[26][0]++;
                lc[26][lc[26][0]] = i;

            } else {
                int temp = l[i] - 'a';
                lc[temp][0]++;
                lc[temp][lc[temp][0]] = i;
            }

            if (r[i] == '?') {
                rc[26][0]++;
                rc[26][rc[26][0]] = i;

            } else {
                int temp = r[i] - 'a';
                rc[temp][0]++;
                rc[temp][rc[temp][0]] = i;
            }

        }
        int total_m = 0;
        for (int i = 0; i < 26; i++) {
            total_m += Math.min(lc[i][0], rc[i][0]);
        }

        total_m = Math.min(n, total_m + lc[26][0] + rc[26][0]);

        pw.println(total_m);

        int l26_i = 0;
        int r26_i = 0;

        for (int i = 0; i < 26; i++) {
            int j = 0;
            for (; j < lc[i][0] && j < rc[i][0]; j++) {
                D_aux(lc[i][j + 1], rc[i][j + 1]);
            }
            while (j < lc[i][0] && r26_i < rc[26][0]) {
                D_aux(lc[i][j + 1], rc[26][r26_i + 1]);
                j++;
                r26_i++;
            }
            while (j < rc[i][0] && l26_i < lc[26][0]) {
                D_aux(lc[26][l26_i + 1], rc[i][j + 1]);
                j++;
                l26_i++;
            }
        }

        while (l26_i < lc[26][0] && r26_i < rc[26][0]) {
            D_aux(lc[26][l26_i + 1], rc[26][r26_i + 1]);
            l26_i++;
            r26_i++;
        }
        pw.close();

    }

    static int find_i(long value, long[] d) {
        for (int i = 0; i < d.length; i++) {
            if (d[i] <= value) {
                return i + 1;
            }
        }
        return d.length;
    }

    public static void SolveE() {
        Scanner sc = new Scanner(System.in);
        long H = sc.nextLong();
        int n = sc.nextInt();
        int[] d = new int[n];
        long[] par_d = new long[n];
        long min_d = 0;

        for (int i = 0; i < n; i++) {
            d[i] = sc.nextInt();
            if (i == 0) {
                par_d[i] = d[i];
            } else {
                par_d[i] = d[i] + par_d[i - 1];
            }
            if (par_d[i] < min_d) {
                min_d = par_d[i];
            }
        }

        if (H + min_d > 0 && par_d[n - 1] >= 0) {
            pri_result(-1);
        }

        if (H + min_d <= 0) {  // Wrong test #12
            System.out.println(find_i(-1L * H, par_d));
            System.exit(0); // wrong answer on Test #4
        }

        long temp = (H + min_d) / (-1L * par_d[n - 1]);
        long H_temp = H + temp * par_d[n - 1];
        if (H_temp + min_d > 0) {
            temp++;
            H_temp += par_d[n - 1];
        }
        System.out.println(temp * n + find_i(-1L * H_temp, par_d));
    }

    public static void main(String args[]) {
        // SolveA();
        SolveB();
        // SolveC();
        // SolveC2();
        // SolveD();
        // SolveE();
    }    
}