#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n;
    string b;
    cin >> n;
    vector<string> v(n);
    map<string, pair<int, int>> mp;
    for (int i = 0; i < n; i++) {
      cin >> b;
      mp[b].first++;
      mp[b].second = i;
      v[i] = b;
    }
    cout << n - mp.size() << endl;
    for (auto it : mp) {
      string s = (it.first);
      while (mp[s].first > 1) {
        bool ok = false;
        int j = 0;
        while (!ok) {
          b = s;
          b[0] = j + 48;
          if (mp[b].first == 0) {
            mp[s].first--;
            mp[b].first++;
            ok = true;
            for (int i = 0; i < n; i++)
              if (v[i] == s) {
                v[i] = b;
                break;
              }
          }
          if (j == 9) break;
          j++;
        }
      }
    }
    for (auto it : v) cout << it << endl;
  }
  return 0;
}
