#include <bits/stdc++.h>
const unsigned int M = 1000000007;
const long double PI = 3.141592653589793236L;
using namespace std;
int max(int a, int b, int c) {
  if (a >= b && a >= c)
    return a;
  else if (b >= a && b >= c)
    return b;
  else
    return c;
}
void solve() {
  map<string, int> map;
  int n, count = 0;
  cin >> n;
  string s[n];
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    map[s[i]]++;
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (map[s[i]] > 1) {
      map[s[i]]--;
      for (int j = 0; j <= 9; j++) {
        s[i][0] = ('0' + j);
        if (map[s[i]] == 0) {
          map[s[i]] = 1;
          count++;
          break;
        }
      }
    }
  }
  cout << count << endl;
  for (int i = 0; i < n; i++) cout << s[i] << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int T = 1;
  cin >> T;
  while (T--) {
    solve();
  }
  return 0;
}
