#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, n, i, tmp, j, dig;
  cin >> t;
  int ans[10];
  int arr[10];
  map<int, int> m;
  while (t--) {
    cin >> n;
    for (i = 0; i < n; i++) {
      cin >> tmp;
      arr[i] = tmp;
      m[tmp]++;
    }
    dig = 0;
    for (i = 0; i < n; i++) {
      tmp = arr[i];
      if (m[tmp] == 1) {
        ans[i] = tmp;
        continue;
      }
      tmp = 10 * floor(tmp / 10);
      for (j = 0; j < 10; j++) {
        if (m[tmp + j] == 0) {
          ans[i] = tmp + j;
          m[tmp + j]++;
          m[arr[i]]--;
          dig++;
          break;
        }
      }
    }
    cout << dig << "\n";
    for (i = 0; i < n; i++) {
      tmp = ans[i];
      if (tmp == 0) {
        cout << "0000"
             << "\n";
        continue;
      }
      dig = 0;
      while (tmp > 0) {
        dig++;
        tmp = floor(tmp / 10);
      }
      if (dig == 1)
        cout << "000" << ans[i] << "\n";
      else if (dig == 2)
        cout << "00" << ans[i] << "\n";
      else if (dig == 3)
        cout << "0" << ans[i] << "\n";
      else
        cout << ans[i] << "\n";
    }
    m.clear();
  }
}
