#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<string> pin(n);
    vector<int> visited(n);
    set<string> uniquePIN;
    int nrOfChanges = 0;
    for (int i = 0; i < n; i++) {
      string x;
      cin >> x;
      pin[i] = x;
      uniquePIN.insert(x);
      visited[i] = 0;
    }
    for (int i = 0; i < n; i++) {
      if (visited[i]) {
        continue;
      }
      for (int j = i + 1; j < n; j++) {
        if (pin[i] == pin[j]) {
          visited[j] = 1;
          nrOfChanges++;
          for (int k = 0; k < 4 && pin[i] == pin[j]; k++) {
            for (char c = '0'; c <= '9'; c++) {
              string t = pin[j];
              t[k] = c;
              if (!uniquePIN.count(t)) {
                uniquePIN.insert(t);
                pin[j] = t;
                break;
              }
            }
          }
        }
      }
    }
    cout << nrOfChanges << "\n";
    for (int i = 0; i < n; i++) cout << pin[i] << "\n";
  }
  return 0;
}
