#include <bits/stdc++.h>
using namespace std;
map<string, int> mmp;
string refer[100];
map<string, int> ssee;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    mmp.clear();
    ssee.clear();
    int cnt = 0;
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
      cin >> refer[i];
      ssee[refer[i]]++;
    }
    for (int index = 1; index <= n; ++index) {
      string ss = refer[index];
      if (--ssee[ss]) {
        ++cnt;
        for (int i = 0; i < 4; ++i) {
          for (int j = 0; j < 10; ++j) {
            char temp = ss[i];
            ss[i] = j + '0';
            if (ssee.count(ss) == 0) {
              mmp[ss] = index;
              ssee[ss]++;
              goto END;
            }
            ss[i] = temp;
          }
        }
      END:;
      } else {
        mmp[ss] = index;
        ssee[ss]++;
      }
    }
    cout << cnt << endl;
    for (int i = 1; i <= n; ++i) {
      for (auto it : mmp)
        if (it.second == i) cout << it.first << endl;
    }
  }
  return 0;
}
