#include <bits/stdc++.h>
using namespace std;
map<string, int> hk;
string g[11], k;
int vis[11];
int main() {
  int t, n;
  cin >> t;
  while (t--) {
    memset(vis, 0, sizeof(vis));
    hk.clear();
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> g[i];
    for (int i = 1; i <= n; i++) {
      if (hk[g[i]] == 0) {
        hk[g[i]] = 1;
        vis[i] = 1;
      }
    }
    cout << n - hk.size() << endl;
    for (int i = 1; i <= n; i++) {
      if (vis[i] == 0) {
        char vv = g[i][3];
        for (int j = 1; j <= 9; j++) {
          g[i][3] = (vv - '0' + j) % 10 + '0';
          if (hk[g[i]] == 0) {
            hk[g[i]] = 1;
            break;
          }
        }
      }
      cout << g[i] << endl;
    }
  }
  return 0;
}
