#include <bits/stdc++.h>
using namespace std;
int main() {
  int T;
  cin >> T;
  for (int TEST = 0; TEST < T; TEST++) {
    int n;
    cin >> n;
    map<string, bool> mp;
    vector<string> vs;
    vector<bool> dd(11, 0);
    int dem = 0;
    for (int i = 0; i < n; i++) {
      string s;
      cin >> s;
      if (mp[s] == true) {
        string s_ = s;
        dem++;
        dd[i] = 1;
      }
      vs.push_back(s);
      mp[s] = true;
    }
    for (int i = 0; i < n; i++)
      if (dd[i]) {
        string s_ = vs[i];
        for (char j = '0'; j <= '9'; j++) {
          s_[0] = j;
          if (mp[s_] == false) {
            vs[i] = s_;
            mp[s_] = true;
            break;
          }
        }
      }
    cout << dem << '\n';
    for (int i = 0; i < vs.size(); i++) cout << vs[i] << '\n';
  }
  return 0;
}
