#include <bits/stdc++.h>
using namespace std;
int small = INT_MIN;
int large = INT_MAX;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n, ans = 0;
    cin >> n;
    char ch;
    int k;
    string a[n];
    int b[10] = {0};
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      ch = a[i][3];
      k = (int)ch - 48;
      if (b[k] == 0) b[k] = 1;
    }
    for (int i = 0; i < n - 1; i++) {
      for (int k = i + 1; k < n; k++) {
        if (a[i] == a[k]) {
          ans++;
          int pos;
          for (int j = 0; j < 10; j++) {
            if (b[j] == 0) {
              pos = j;
              b[j] = 1;
              break;
            }
          }
          pos += 48;
          ch = (char)pos;
          a[k][3] = ch;
        }
      }
    }
    cout << ans << endl;
    for (int i = 0; i < n; i++) {
      cout << a[i] << " ";
    }
    cout << endl;
  }
  return 0;
}
