#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    map<string, long long int> mp;
    vector<string> v;
    for (long long int i = 0; i < n; i++) {
      string g;
      cin >> g;
      mp[g]++;
      v.push_back(g);
    }
    long long int ans = 0;
    long long int i = 0;
    for (long long int i = 0; i < n; i++) {
      if (mp[v[i]] > 1) {
        string s = v[i];
        for (long long int i = 0; i <= 9; i++) {
          if (s[s.size() - 1] - '0' != i) {
            s[s.size() - 1] = i + '0';
            if (mp[s] >= 1) {
              continue;
            } else {
              ans++;
              break;
            }
          }
        }
        mp[v[i]]--;
        v[i] = s;
        mp[v[i]]++;
      }
    }
    cout << ans << "\n";
    for (auto it : v) {
      cout << it << "\n";
    }
  }
  return 0;
}
