#include <bits/stdc++.h>
using namespace std;
bool check(set<int> s, int x) {
  for (auto i : s) {
    if (i == x) return true;
  }
  return false;
}
int main(void) {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    int n, steps = 0;
    cin >> n;
    vector<int> v;
    set<int> num;
    for (int i = 0; i < n; i++) {
      int a;
      cin >> a;
      v.push_back(a);
      num.insert(a % 10);
    }
    for (int i = 0; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
        if (v[j] == v[i]) {
          steps++;
          v[i] -= v[i] % 10;
          for (int k = 0; k < 10; k++) {
            if (!check(num, k)) {
              num.insert(k);
              v[i] += k;
              break;
            }
          }
          break;
        }
      }
    }
    cout << steps << endl;
    for (int i = 0; i < n; i++) {
      if (v[i] == 0)
        cout << "000";
      else if (v[i] / 10 == 0)
        cout << "000";
      else if (v[i] / 100 == 0)
        cout << "00";
      else if (v[i] / 1000 == 0)
        cout << "0";
      cout << v[i] << endl;
    }
  }
}
