#include <bits/stdc++.h>
using namespace std;
int visit[10];
int main() {
  int t;
  cin >> t;
  while (t--) {
    memset(visit, 0, sizeof(visit));
    int n;
    cin >> n;
    vector<string> s;
    while (n--) {
      string s1;
      cin >> s1;
      s.push_back(s1);
    }
    int x = 0;
    for (int i = 0; i < s.size(); i++) {
      int j;
      for (j = i + 1; j < s.size(); j++) {
        if (s[i] == s[j]) break;
      }
      if (j == s.size()) {
        string o = s[i];
        visit[o[3] - 48] = true;
      }
    }
    for (int i = 0; i < s.size() - 1; i++) {
      string p = s[i];
      for (int j = i + 1; j < s.size(); j++) {
        if (s[i] == s[j]) {
          x++;
          char c;
          for (int k = 0; k <= 9; k++) {
            if (visit[k] == 0) {
              c = k + 48;
              break;
            }
          }
          p[3] = c;
          s[i] = p;
          break;
        }
      }
      visit[p[3] - 48] = true;
    }
    cout << x << endl;
    for (int i = 0; i < s.size(); i++) {
      cout << s[i] << endl;
    }
    memset(visit, 0, sizeof(visit));
  }
}
