#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9;
int main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    string s[11];
    map<string, long long> mp;
    mp.clear();
    for (long long i = 0; i < n; i++) {
      cin >> s[i];
      mp[s[i]]++;
    }
    long long ans = 0;
    for (long long i = 0; i < n; i++) {
      if (mp[s[i]] > 1) {
        mp[s[i]]--;
        ans++;
        for (char j = '0'; j <= '9'; j++) {
          s[i][0] = j;
          if (mp[s[i]] == 0) {
            mp[s[i]]++;
            break;
          }
        }
      }
    }
    cout << ans << '\n';
    for (long long i = 0; i < n; i++) cout << s[i] << '\n';
  }
  return 0;
}
