#include <bits/stdc++.h>
using namespace std;
int main() {
  int T;
  cin >> T;
  while (T--) {
    int n, vis[30] = {0}, res = 0;
    string str[30];
    map<string, int> mp;
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> str[i];
      mp[str[i]]++;
      vis[str[i][0] - '0']++;
    }
    for (int i = 0; i < n; i++) {
      if (mp[str[i]] > 1) {
        res++;
        mp[str[i]]--;
        vis[str[i][0] - '0']--;
        for (int j = 0; j <= 9; j++)
          if (!vis[j]) {
            vis[j]++;
            str[i][0] = j + '0';
            break;
          }
      }
    }
    cout << res << endl;
    for (int i = 0; i < n; i++) cout << str[i] << endl;
  }
  return 0;
}
