#include <bits/stdc++.h>
using namespace std;
void fastIO() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
template <typename T, typename U>
inline void mnze(T &x, U y) {
  if (y < x) x = y;
}
template <typename T, typename U>
inline void mxze(T &x, U y) {
  if (x < y) x = y;
}
void _scan(int &x) { scanf("%d", &x); }
void _scan(long long &x) { scanf("%lld", &x); }
void _scan(double &x) { scanf("%lf", &x); }
void _scan(char &x) { scanf(" %c", &x); }
void _scan(char *x) { scanf("%s", x); }
void scan() {}
template <typename T, typename... U>
void scan(T &head, U &...tail) {
  _scan(head);
  scan(tail...);
}
template <typename T>
void _dbg(const char *sdbg, T h) {
  cerr << sdbg << "=" << h << "\n";
}
template <typename T, typename... U>
void _dbg(const char *sdbg, T h, U... t) {
  while (*sdbg != ',') cerr << *sdbg++;
  cerr << "=" << h << ",";
  _dbg(sdbg + 1, t...);
}
long long MOD = 1e9 + 7;
inline long long Msum(long long x) { return x; }
template <typename... Rest>
inline long long Msum(long long x, Rest... rest) {
  return (x + Msum(rest...)) % MOD;
}
inline long long Mprod(long long x) { return x; }
template <typename... Rest>
inline long long Mprod(long long x, Rest... rest) {
  return x * Mprod(rest...) % MOD;
}
inline long long Mnorm(long long x) { return (x % MOD + MOD) % MOD; }
string s[11];
map<string, int> cnt;
int main() {
  int TC;
  cin >> TC;
  while (TC--) {
    int n;
    cin >> n;
    cnt.clear();
    for (int i = 0; i < (int)n; i++) cin >> s[i];
    for (int i = 0; i < (int)n; i++) cnt[s[i]]++;
    int ans = 0;
    for (int i = 0; i < (int)n; i++) {
      string s1 = s[i];
      if (cnt[s1] > 1) {
        ans++;
        string s2 = s1;
        bool good = false;
        for (int j = 0; j < (int)4 && !good; j++) {
          for (int d = 0; d < (int)10 && !good; d++) {
            s2[j] = '0' + d;
            if (cnt[s2] == 0) {
              good = true;
              s[i] = s2;
              cnt[s2]++;
              cnt[s1]--;
            }
          }
          s2[j] = s1[j];
        }
        assert(good);
      }
    }
    cout << ans << endl;
    for (int i = 0; i < (int)n; i++) cout << s[i] << endl;
  }
}
