#include <bits/stdc++.h>
const long long INF = (long long)1e9 + 9;
const long long maxn = (long long)1e9 + 6;
using namespace std;
signed main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n, cnt = 0;
    cin >> n;
    map<string, long long> mp;
    vector<string> s(n), answer(n);
    for (long long i = 0; i < n; i++) {
      cin >> s[i];
      mp[s[i]]++;
    }
    for (long long i = 0; i < n; i++) {
      if (mp[s[i]] == 1) {
        answer[i] = s[i];
        mp[s[i]] = true;
      } else {
        string temp = s[i];
        mp[temp]--;
        cnt++;
        for (long long where = 0; where < 4; where++) {
          for (char ch = '0'; ch <= '9'; ch++) {
            temp[where] = ch;
            if (not mp.count(temp)) {
              answer[i] = temp;
              mp[temp]++;
              where = 4;
              break;
            }
          }
        }
      }
    }
    cout << cnt << endl;
    for (long long i = 0; i < n; i++) {
      cout << answer[i] << endl;
    }
  }
  return 0;
}
