#include <bits/stdc++.h>
using namespace std;
string inttopin(int x) {
  string s = to_string(x);
  string ans = "";
  for (int i = 0; i < 4 - s.length(); i++) {
    ans += "0";
  }
  ans += s;
  return ans;
}
int main() {
  int cnt;
  scanf("%d", &cnt);
  while (cnt--) {
    int num[10], out[10], card, temp, ans = 0;
    int caled[10000] = {0};
    scanf("%d", &card);
    for (int i = 0; i < card; i++) {
      scanf("%d", &temp);
      num[i] = temp;
      caled[temp]++;
    }
    for (int i = 0; i < card; i++) {
      if (caled[num[i]] > 1) {
        ans++;
        int newn = num[i];
        caled[newn]--;
        for (int j = 0; j < 10; j++) {
          newn = (newn / 10) * 10 + j;
          if (caled[newn] == 0) {
            out[i] = newn;
            caled[newn] = true;
            break;
          }
        }
      } else {
        out[i] = num[i];
        caled[num[i]] = true;
      }
    }
    cout << ans << "\n";
    for (int i = 0; i < card; i++) {
      cout << inttopin(out[i]) << "\n";
    }
  }
}
