#include <bits/stdc++.h>
using namespace std;
int t;
int n;
int sol, temp;
vector<string> a;
void duplicates(int i);
int main() {
  cin >> t;
  for (; t; --t) {
    sol = 0;
    cin >> n;
    a.resize(n);
    for (int i = 0; i < n; ++i) {
      temp = 0;
      cin >> a[i];
      duplicates(i);
      if (temp) ++sol;
    }
    cout << sol << '\n';
    for (int i = 0; i < n; ++i) cout << a[i] << '\n';
  }
  return 0;
}
void duplicates(int i) {
  bool ok = false;
  for (int j = 0; j < i; ++j)
    if (a[i] == a[j]) {
      ++temp;
      a[i][1] = (a[j][1] + 1) % 10 + '0';
      ok = true;
    }
  if (ok) duplicates(i);
}
