#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    map<int, int> m;
    string a[n];
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      m[stoi(a[i])]++;
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
      bool b = 0;
      int val = stoi(a[i]);
      if (m[val] > 1) {
        for (int k = 0; k < 4; k++) {
          bool b = 0;
          string s1 = a[i];
          for (int j = 0; j < 9; j++) {
            s1[k] = '0' + j;
            if (m[stoi(s1)] == 0) {
              b = 1;
              m[stoi(s1)] = 1;
              m[val]--;
              a[i] = s1;
              break;
            }
          }
          if (b) break;
        }
        ans++;
      }
    }
    cout << ans << endl;
    for (int i = 0; i < n; i++) cout << a[i] << endl;
  }
}
