#include <bits/stdc++.h>
const long long MAX = 1e7;
using namespace std;
void solve() {
  long long n;
  cin >> n;
  map<string, long long> mp;
  vector<string> arr(n);
  for (long long i = 0; i < n; i++) {
    string temp;
    cin >> temp;
    mp[temp]++;
    arr[i] = temp;
  }
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    if (mp[arr[i]] > 1) {
      ans++;
      mp[arr[i]]--;
      for (long long j = 0; j < 10; j++) {
        arr[i][3] = j + '0';
        if (mp[arr[i]] == 0) {
          mp[arr[i]] = 1;
          break;
        }
      }
    }
  }
  cout << ans << "\n";
  for (auto &it : arr) cout << it << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t;
  cin >> t;
  while (t--) solve();
}
