#include <bits/stdc++.h>
using namespace std;
const int MX = 1e9;
const long long MX2 = 3e18;
const double pi = acos(-1);
const int MOD = 1e9 + 7;
const int sz = 2048;
int main() {
  cin.tie(nullptr);
  cout.tie(nullptr);
  ios::sync_with_stdio(false);
  int T;
  cin >> T;
  while (T--) {
    int n;
    cin >> n;
    string str[11];
    int arr[11];
    int i;
    int cnt[10011] = {};
    for (i = 1; i <= n; i++) {
      cin >> str[i];
      arr[i] = stoi(str[i]);
      cnt[arr[i]]++;
    }
    int ans = 0;
    for (i = 1; i <= n; i++) {
      if (cnt[arr[i]] == 1) continue;
      ans++;
      cnt[arr[i]]--;
      arr[i] -= arr[i] % 10;
      while (cnt[arr[i]]) arr[i]++;
      cnt[arr[i]]++;
    }
    cout << ans << '\n';
    for (i = 1; i <= n; i++) {
      if (arr[i] < 1000) cout << 0;
      if (arr[i] < 100) cout << 0;
      if (arr[i] < 10) cout << 0;
      cout << arr[i] << ' ';
    }
    cout << '\n';
  }
  return 0;
}
