#include <bits/stdc++.h>
using namespace std;
struct Code {
  int code, seq;
} arr[10];
map<int, int> used;
bool cmp_v(Code a, Code b) { return a.code < b.code; }
bool cmp_s(Code a, Code b) { return a.seq < b.seq; }
int main() {
  int t, n;
  cin >> t;
  while (t--) {
    used.clear();
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> arr[i].code;
      arr[i].seq = i;
      used[arr[i].code]++;
    }
    int cnt = 0;
    cnt = used.size();
    if (cnt == n) {
      cout << 0 << endl;
      for (int i = 0; i < n; i++) printf("%04d\n", arr[i].code);
    } else {
      cout << n - cnt << endl;
      sort(arr, arr + n, cmp_v);
      for (int i = 0; i < n; i++) {
        if (used[arr[i].code] == 1)
          continue;
        else {
          int tmp = arr[i].code / 10 * 10;
          for (int j = 0; j < 10; j++) {
            if (used[tmp + j])
              continue;
            else {
              used[arr[i].code]--;
              arr[i].code = tmp + j;
              used[tmp + j]++;
            }
          }
        }
      }
      sort(arr, arr + n, cmp_s);
      for (int i = 0; i < n; i++) printf("%04d\n", arr[i].code);
    }
  }
  return 0;
}
