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