#include <bits/stdc++.h>
int main() {
  int q;
  std::cin >> q;
  while (q--) {
    int n, ans(0);
    std::cin >> n;
    std::set<std::string> check, p;
    std::string s;
    std::vector<std::string> res, a(n);
    for (int i = 0; i < n; i++) {
      std::cin >> a[i];
      check.insert(a[i]);
    }
    for (int i = 0; i < n; i++) {
      if (p.find(a[i]) != p.end()) {
        std::string t = a[i];
        for (int x = 0; x < 10; x++) {
          if (check.find(t) == check.end()) {
            check.insert(t);
            p.insert(t);
            break;
          }
          t[0] = char('0' + x);
        }
        ++ans;
        res.push_back(t);
      } else {
        res.push_back(a[i]);
        p.insert(a[i]);
      }
    }
    std::cout << ans << std::endl;
    for (int i = 0; i < res.size(); i++) {
      std::cout << res[i] << std::endl;
    }
  }
  return 0;
}
