#include <bits/stdc++.h>
using namespace std;
bool p(int x, int y) { return x < y; }
int a[16];
int hv[10000];
int main() {
  int t;
  cin >> t;
  while (t) {
    t--;
    int n, ans = 0;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
      scanf("%d", a + i);
      hv[a[i]]++;
    }
    for (int i = 1; i <= n; i++) {
      if (hv[a[i]] > 1) {
        hv[a[i]]--;
        for (int j = 0; j < 10; j++) {
          if (!hv[(a[i] / 10) * 10 + j]) {
            hv[(a[i] / 10) * 10 + j]++;
            a[i] = (a[i] / 10) * 10 + j;
            break;
          }
        }
        ans++;
      }
    }
    cout << ans << endl;
    for (int i = 1; i <= n; i++) {
      printf("%04d\n", a[i]);
      hv[a[i]]--;
    }
  }
  return 0;
}
