#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       string s[n];       unordered_map<string, int> mp;       int count = 0;       for (int i = 0; i < n; i++) {         cin >> s[i];         mp[s[i]] += 1;       }       for (int i = 0; i < n; i++) {         if (mp[s[i]] > 1) {           count += 1;           mp[s[i]] -= 1;           for (int j = 0; j < 10; j++) {             string s1 = s[i];             s1[3] =  0  + j;             if (mp[s1] == 0) {               mp[s1] += 1;               s[i] = s1;               break;             }           }         }       }       cout << count << endl;       for (int i = 0; i < n; i++) {         cout << s[i] << endl;       }     }   }   