#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    vector<string> v(n);
    set<string> s;
    for (auto &i : v) {
      cin >> i;
      s.insert(i);
    }
    map<string, long long int> make_pair;
    for (auto it : s) {
      make_pair[it] = 0;
    }
    cout << n - s.size() << "\n";
    for (long long int i = 0; i < n; i++) {
      make_pair[v[i]]++;
      if (make_pair[v[i]] > 1) {
        for (char j = '0'; j <= '9'; j++) {
          string temp = "";
          temp.push_back(v[i][0]);
          temp.push_back(v[i][1]);
          temp.push_back(v[i][2]);
          temp.push_back(j);
          if (s.find(temp) == s.end()) {
            s.insert(temp);
            v[i] = temp;
            break;
          }
        }
      }
    }
    for (auto xyz : v) cout << xyz << "\n";
  }
}
