#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    map<string, int> m, b;
    string x;
    vector<string> j, v;
    int ans = 0;
    for (int i = 0; i < n; i++) {
      cin >> x;
      v.push_back(x);
      m[x] = 1;
    }
    for (int i = 0; i < v.size(); i++) {
      x = v[i];
      if (b[x] == 0 && m[x] == 1) {
        j.push_back(x);
      } else {
        ans++;
        string temp = x;
        int flag = 0;
        for (int pos = 0; pos < 4; pos++) {
          for (char ch = '0'; ch <= '9'; ch++) {
            if (temp[pos] != ch) {
              string h = temp;
              h[pos] = ch;
              if (m[h] == 0) {
                m[h] = 1;
                j.push_back(h);
                flag = 1;
                break;
              }
            }
          }
          if (flag) break;
        }
      }
      b[x] = 1;
    }
    cout << ans << "\n";
    for (int i = 0; i < j.size(); i++) cout << j[i] << "\n";
  }
  return 0;
}
