#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<string> v(n);
    map<string, int> m;
    bool visited[10];
    for (int i = 0; i < 10; i++) visited[i] = false;
    for (int i = 0; i < n; i++) {
      cin >> v[i];
      m[v[i]]++;
      visited[v[i][0] - '0'] = true;
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
      if (m[v[i]] > 1) {
        ans++;
        ;
        m[v[i]]--;
        for (int j = 0; j < 10; j++) {
          if (visited[j] == false) {
            v[i][0] = j + '0';
            visited[j] = true;
            break;
          }
        }
      }
    }
    cout << ans << endl;
    for (int i = 0; i < n; i++) cout << v[i] << endl;
  }
}
