#include <bits/stdc++.h>
using namespace std;
long long n, m, a[200005];
map<string, long long> mp;
string s[1005];
int main() {
  long long int i, j, k, z = 0, c = 0, t, x, y, l, r, mid;
  scanf("%lld", &t);
  while (t--) {
    scanf("%lld", &n);
    mp.clear();
    for (i = 0; i < n; i++) {
      cin >> s[i];
      mp[s[i]]++;
    }
    c = 0;
    for (i = 0; i < n; i++) {
      if (mp[s[i]] > 1) {
        c++;
        mp[s[i]]--;
        k = 0;
        for (char jj = '0'; jj <= '9'; jj++) {
          s[i][0] = jj;
          if (mp.find(s[i]) == mp.end()) {
            k = 1;
            mp[s[i]] = 1;
            break;
          }
        }
      }
    }
    cout << c << endl;
    for (i = 0; i < n; i++) {
      cout << s[i] << endl;
    }
  }
}
