#include <bits/stdc++.h>
using namespace std;
string str[15];
int main() {
  int t;
  cin >> t;
  while (t--) {
    map<string, int> freq;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> str[i];
      freq[str[i]]++;
    }
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      if (freq[str[i]] > 1) {
        cnt++;
        freq[str[i]]--;
        for (char digit = '0'; digit <= '9'; digit++) {
          str[i][0] = digit;
          if (freq[str[i]] == 0) {
            freq[str[i]]++;
            break;
          }
        }
      }
    }
    cout << cnt << endl;
    for (int i = 0; i < n; i++) {
      cout << str[i] << endl;
    }
  }
}
