#include <bits/stdc++.h>
using namespace std;
int a[15], tot[10005];
int main() {
  int T;
  for (scanf("%d", &T); T; T--) {
    int n;
    memset(tot, 0, sizeof(tot));
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      tot[a[i]]++;
    }
    int ans = 0;
    for (int i = 1; i <= n; i++)
      while (tot[a[i]] > 1) {
        tot[a[i]]--;
        ans++;
        int k = ((a[i] % 10) + 9) % 10;
        a[i] = (a[i] / 10) * 10 + k;
        tot[a[i]]++;
        if (tot[a[i]] > 1) ans--;
      }
    printf("%d\n", ans);
    for (int i = 1; i <= n; i++) printf("%04d\n", a[i]);
  }
  return 0;
}
