#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9;
const double EPS = 1e-9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const int p = 239;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int q;
  cin >> q;
  while (q--) {
    int n;
    cin >> n;
    vector<string> pin(n);
    multiset<string> exist;
    for (int i = 0; i < n; ++i) {
      cin >> pin[i];
      exist.insert(pin[i]);
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
      if (exist.count(pin[i]) > 1) {
        for (int s = 0; s < (int)(pin[i]).size(); ++s) {
          bool found = false;
          for (char c = '0'; c <= '9'; ++c) {
            string ns = pin[i];
            ns[s] = char(c);
            if (exist.find(ns) == exist.end()) {
              exist.erase(exist.find(pin[i]));
              pin[i] = ns, ++ans, found = true;
              exist.insert(pin[i]);
              break;
            }
          }
          if (found) {
            break;
          }
        }
      }
    }
    cout << ans << "\n";
    for (auto i : pin) {
      cout << i << "\n";
    }
  }
  return 0;
}
