#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int t, n;
char a[15][5];
int b[15];
char m[15][5];
int vis[15];
int y = 0;
bool check(char a[]) {
  for (int i = 1; i <= n; i++) {
    if (!strcmp(m[i], a)) {
      return true;
    }
  }
  return false;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> t;
  while (t--) {
    cin >> n;
    int num = 0;
    y = 0;
    for (int i = 0; i < 10; i++) vis[i] = 0;
    for (int i = 0; i <= n; i++) {
      strcpy(m[i], "00000");
    }
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
      b[i] = 0;
    }
    for (int i = 1; i <= n; i++) {
      if (check(a[i])) {
        b[i]++;
        num++;
      }
      strcpy(m[++y], a[i]);
      vis[a[i][3] - '0'] = 1;
    }
    for (int i = 1; i <= n; i++) {
      if (b[i] != 0) {
        for (int j = 0; j < 10; j++) {
          if (vis[j] == 0) {
            a[i][3] = j + '0';
            vis[j] = 1;
            break;
          }
        }
      }
    }
    cout << num << endl;
    for (int i = 1; i <= n; i++) {
      cout << a[i] << endl;
    }
  }
}
