#include <bits/stdc++.h>
using namespace std;
void faltu() {}
void solve() {
  long long n;
  cin >> n;
  vector<string> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  long long ans(0);
  for (int i = 0; i < n; i++) {
    if (count(a.begin(), a.end(), a[i]) > 1) {
      int l = a[i][3];
      int p = '0';
      while (true) {
        a[i][3] = p;
        if (count(a.begin(), a.end(), a[i]) > 1)
          ++p;
        else {
          ++ans;
          break;
        }
      }
    }
  }
  cout << ans << "\n";
  for (auto r : a) cout << r << "\n";
}
int main() {
  faltu();
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
}
