#include <bits/stdc++.h>
using namespace std;
void scan() {}
template <typename T, typename... Args>
void scan(T &a, Args &...args) {
  cin >> a;
  scan(args...);
}
void sortt(long long &a, long long &b, long long &c) {
  if (b < a) swap(a, b);
  if (c < b) swap(b, c);
  if (b < a) swap(a, b);
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long tz;
  cin >> tz;
  while (tz--) {
    long long n;
    cin >> n;
    vector<string> ans;
    map<string, long long> make_pair;
    string s;
    long long c = 0, p = 0;
    while (n--) {
      cin >> s;
      make_pair[s]++;
      ans.push_back(s);
    }
    string temp;
    for (long long i = 0; i < ans.size(); i++) {
      if (make_pair[ans[i]] > 1) {
        make_pair[ans[i]]--;
        temp = ans[i];
        long long k = 0;
        while (make_pair[temp] != 0) {
          temp[0] = char(k + '0');
          k++;
        }
        c++;
        ans[i] = temp;
        make_pair[temp] = 1;
      }
    }
    cout << c << '\n';
    for (auto it : ans) cout << it << '\n';
  }
}
