#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string str[n];
    vector<string> v;
    vector<int> pos;
    vector<string> rep;
    map<string, int> m;
    for (long long i = 0; i < n; i++) {
      cin >> str[i];
      m[str[i]]++;
      v.push_back(str[i]);
      if (m[str[i]] > 1) {
        rep.push_back(str[i]);
        pos.push_back(i);
      }
    }
    for (int i = 0; i < rep.size(); i++) {
      for (int j = 0; j < 10; j++) {
        rep[i][0] = j + '0';
        if (m[rep[i]] != 0)
          ;
        else {
          m[rep[i]]++;
          v[pos[i]] = rep[i];
          break;
        }
      }
    }
    cout << rep.size() << "\n";
    for (auto it = v.begin(); it != v.end(); it++) {
      cout << *it << "\n";
    }
  }
  return 0;
}
