#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, cnt = 0;
    cin >> n;
    string s[n];
    long long int h1[10] = {}, h2[10] = {};
    for (int i = 0; i < n; i++) {
      cin >> s[i];
      h1[s[i][3] - '0']++;
    }
    for (int i = 0; i < n - 1; i++) {
      for (int j = i + 1; j < n; j++) {
        if (s[i].compare(s[j]) == 0) {
          int k;
          cnt++;
          for (k = 0; k < 10; k++) {
            if (h1[k] == 0) {
              break;
            }
          }
          h1[s[i][3] - '0']--;
          h1[k]++;
          s[i][3] = k + '0';
        }
      }
    }
    cout << cnt << endl;
    for (int i = 0; i < n; i++) {
      cout << s[i] << endl;
    }
  }
  return 0;
}
