#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
long long t, n, res;
string a[11], tmp;
map<string, long long> mp;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> t;
  while (t--) {
    cin >> n;
    res = 0;
    for (long int i = 0; i < n; i++) cin >> a[i], mp[a[i]]++;
    for (long int i = 0; i < n; i++) {
      if (mp[a[i]] > 1) {
        res++;
        mp[a[i]]--;
        tmp = a[i];
        for (long long j = 0; mp[a[i]] != 0 && j < 10; j++) {
          a[i][0] = char('0' + j);
        }
        if (mp[a[i]] == 0) {
          mp[a[i]]++;
          continue;
        }
        a[i] = tmp;
        for (long long j = 0; mp[a[i]] > 1 && j < 10; j++) {
          a[i][1] = char('0' + j);
        }
      }
      mp[a[i]]++;
    }
    cout << res << "\n";
    for (long int i = 0; i < n; i++) cout << a[i] << "\n";
    mp.clear();
  }
}
