#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  srand(time(NULL));
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    unordered_map<string, int> codes;
    vector<string> v(n);
    for (int i = 0; i < n; i++) {
      string x;
      cin >> x;
      v[i] = x;
      codes[x]++;
    }
    int ans = 0;
    vector<string> anss;
    for (int i = 0; i < n; i++) {
      if (codes[v[i]] > 1) {
        ans++;
        string x = v[i];
        while (codes[x] >= 1) {
          x = v[i];
          int pos = rand() % 4;
          char digit = (char)('0' + (rand() % 10));
          x[pos] = digit;
        }
        codes[x] = 1;
        codes[v[i]]--;
        anss.push_back(x);
      } else
        anss.push_back(v[i]);
    }
    cout << ans << '\n';
    for (auto a : anss) cout << a << '\n';
  }
  return 0;
}
