#include <bits/stdc++.h>
using namespace std;
int vis[10000], a[100];
int main() {
  int T, n;
  scanf("%d", &T);
  while (T--) {
    memset(vis, 0, sizeof vis);
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      vis[a[i]]++;
    }
    int cnt = 0;
    for (int i = 1; i <= n; i++) {
      if (vis[a[i]] > 1) {
        cnt++;
        vis[a[i]]--;
        for (int j = 0; j <= 9; j++) {
          int x = a[i] / 10 * 10 + j;
          if (vis[x] == 0) {
            vis[x] = 1;
            a[i] = x;
            break;
          }
        }
      }
    }
    cout << cnt << endl;
    for (int i = 1; i <= n; i++) {
      printf("%04d\n", a[i]);
    }
  }
  return 0;
}
