#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    map<string, int> M;
    string v[n];
    for (int i = 0; i < n; i++) {
      string s;
      cin >> s;
      M[s]++;
      v[i] = s;
    }
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      if (M[v[i]] > 1) {
        M[v[i]]--;
        for (int j = 0; j < n; j++) {
          v[i][0] = '0' + j;
          if (M[v[i]] == 0) {
            cnt++;
            M[v[i]] = 1;
            break;
          }
        }
      }
    }
    cout << cnt << endl;
    for (int i = 0; i < n; i++) {
      cout << v[i] << endl;
    }
  }
  return 0;
}
