#include <bits/stdc++.h>
using namespace std;
map<string, int> mp;
string s;
string arr[20], mark[20];
void solve() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
    mp[arr[i]]++;
  }
  for (int i = 1; i <= n; i++) {
    if (mp[arr[i]] != 1) {
      ans++;
      for (int k = 0; k < 4; k++) {
        string s = arr[i];
        char j = '0';
        while (mp[s] && j <= '9') {
          s[k] = j++;
        }
        if (!mp[s]) {
          mp[s]++;
          mark[i] = s;
          break;
        }
      }
      mp[arr[i]]--;
    } else {
      mark[i] = arr[i];
    }
  }
  cout << ans << endl;
  for (int i = 1; i <= n; i++) {
    cout << mark[i] << endl;
  }
  mp.clear();
}
int main() {
  ios::sync_with_stdio(0);
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
