#include <bits/stdc++.h>
using namespace std;
char s[15][5];
int ff[5][15];
int main() {
  int t, n;
  cin >> t;
  while (t--) {
    cin >> n;
    for (int i = 0; i < 4; i++)
      for (int j = 0; j <= 9; j++) ff[i][j] = 0;
    for (int i = 0; i < n; i++) {
      cin >> s[i];
      for (int j = 0; j < 4; j++) ff[j][s[i][j] - '0']++;
    }
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
        int f = 0;
        for (int k = 0; k < 4; k++)
          if (s[i][k] != s[j][k]) f = 1;
        if (!f) {
          cnt++;
          for (int r = 0; r <= 9; r++)
            if (ff[0][r] == 0) {
              ff[0][r] = 1;
              s[i][0] = r + '0';
              break;
            }
        }
      }
    }
    cout << cnt << endl;
    for (int i = 0; i < n; i++) cout << s[i] << endl;
  }
  return 0;
}
