#include <bits/stdc++.h>
using namespace std;
int a[20000], b[20000];
int used[20000];
int flag[20000];
void solve() {
  memset(a, 0, sizeof(a));
  memset(used, 0, sizeof(used));
  memset(flag, 0, sizeof(flag));
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    flag[a[i]] = true;
  }
  for (int i = 1; i <= n; i++) b[i] = a[i];
  sort(a + 1, a + 1 + n);
  int ans = 0;
  a[0] = -1;
  for (int i = 1; i <= n; i++) {
    if (a[i] == a[i - 1]) ans++;
  }
  printf("%d\n", ans);
  int cc = 0;
  for (int i = 1; i <= n; i++) {
    if (!used[b[i]]) {
      used[b[i]] = true;
      printf("%04d\n", b[i]);
      cc++;
      continue;
    }
    for (int j = 1; j <= 10; j++) {
      int t = (b[i] + 1000 * j) % 10000;
      if (!used[t] && !flag[t]) {
        used[t] = true;
        printf("%04d\n", t);
        cc++;
        break;
      }
    }
  }
  if (cc != n)
    while (true)
      ;
}
int main(int argc, char *argv[]) {
  int T;
  scanf("%d", &T);
  while (T--) solve();
}
