#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<string> vec(n);
    map<string, int> mp;
    for (int i = 0; i < n; i++) {
      cin >> vec[i];
      mp[vec[i]]++;
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
      if (mp[vec[i]] > 1) {
        ans++;
        for (int j = 0; j < 10; j++) {
          string suff = vec[i].substr(1, 3);
          string cand = to_string(j) + suff;
          if (mp.find(cand) == mp.end()) {
            mp[vec[i]]--;
            mp[cand]++;
            vec[i] = cand;
            break;
          }
        }
      }
    }
    cout << ans << "\n";
    for (string s : vec) cout << s << "\n";
  }
  return 0;
}
