#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  set<string> s;
  vector<pair<string, int>> v;
  vector<string> ans(n);
  for (int i = 0; i < n; i++) {
    string m;
    cin >> m;
    ans[i] = m;
    if (s.count(m))
      v.emplace_back(m, i);
    else
      s.insert(m);
  }
  cout << v.size() << "\n";
  for (int i = 0; i < v.size(); i++) {
    string it = v[i].first;
    bool changed = false;
    for (int j = 0; j < 4; j++) {
      if (changed) break;
      for (int k = 0; k < 10; k++) {
        it[j] = '0' + k;
        if (s.count(it)) {
          it = v[i].first;
        } else {
          s.insert(it);
          ans[v[i].second] = it;
          changed = true;
          break;
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i] << "\n";
  }
  return;
}
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
