#include <bits/stdc++.h>
using namespace std;
string a[11];
int main() {
  int t, n;
  cin >> t;
  while (t--) {
    unordered_map<string, int> mp;
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      mp[a[i]]++;
    }
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      auto t = a[i];
      if (mp[t] == 1) continue;
      int f = 0;
      for (int j = 0; j < 4; j++) {
        for (int k = 0; k < 10; k++) {
          t[j] = (char)('0' + k);
          if (!mp[t]) {
            mp[a[i]]--;
            mp[t]++;
            a[i] = t;
            cnt++;
            f = 1;
            break;
          }
        }
        if (f) break;
      }
    }
    cout << cnt << endl;
    for (int i = 0; i < n; i++) cout << a[i] << endl;
  }
  return 0;
}
