#include <bits/stdc++.h>
using namespace std;
int t, n;
string A[10];
map<string, int> Count;
int main() {
  cin >> t;
  for (; t > 0; t--) {
    cin >> n;
    Count.clear();
    int times = 0;
    for (int i = 0; i < n; i++) {
      cin >> A[i];
      Count[A[i]]++;
    }
    for (int i = 0; i < n; i++)
      if (Count[A[i]] > 1) {
        Count[A[i]]--;
        for (int j = 0; j <= 9; j++) {
          A[i][0] = j + '0';
          if (Count[A[i]] == 0) {
            Count[A[i]]++;
            break;
          }
        }
        times++;
      }
    cout << times << endl;
    for (int i = 0; i < n; i++) cout << A[i] << endl;
  }
  return 0;
}
