#include <bits/stdc++.h>
using namespace std;
int q, n, k;
string s;
set<string> qr;
set<char> sq;
vector<string> v;
map<string, int> m;
int main() {
  cin >> q;
  while (q--) {
    cin >> n;
    k = 0;
    char ch = '0';
    sq.clear();
    qr.clear();
    v.clear();
    for (int i = 0; i < 10; i++) sq.insert(ch + i);
    for (int i = 1; i <= n; i++) {
      cin >> s;
      v.push_back(s);
      qr.insert(s);
      sq.erase(s[0]);
    }
    cout << n - qr.size() << endl;
    qr.clear();
    for (int i = 0; i < n; i++) {
      k++;
      qr.insert(v[i]);
      if (k != qr.size()) {
        k--;
        set<char>::iterator it = sq.begin();
        v[i][0] = *it;
        sq.erase(it);
      }
      cout << v[i] << endl;
    }
  }
}
