#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    map<string, int> m;
    int ans = 0;
    vector<string> a, b;
    for (int i = 0; i < n; i++) {
      string s;
      cin >> s;
      if (m[s] != 0) ans++;
      m[s]++;
      b.push_back(s);
    }
    for (int i = 0; i < n; i++) {
      string s;
      s = b[i];
      if (m[s] != 1) {
        m[s]--;
        while (true) {
          if (s[3] == '9')
            s[3] = '0';
          else
            s[3] = ((int)s[3] + 1);
          if (m[s] == 0) {
            m[s]++;
            a.push_back(s);
            break;
          }
        }
      } else {
        a.push_back(s);
      }
    }
    cout << ans << endl;
    for (int i = 0; i < a.size(); i++) {
      cout << a[i] << endl;
    }
  }
  return 0;
}
