#include <bits/stdc++.h>
using namespace std;
const int mod = 1e5 + 3;
const int INF = 0x3f3f3f3f;
const int N = 2e5 + 10;
int n, m, ans;
int main() {
  int t;
  cin >> t;
  while (t--) {
    cin >> n;
    string s[11];
    map<string, int> m;
    ans = 0;
    for (int i = 1; i <= n; i++) {
      cin >> s[i];
    }
    for (int i = 1; i <= n; i++) {
      if (!m[s[i]]) {
        m[s[i]]++;
      } else
        ans++;
    }
    cout << ans << endl;
    m.clear();
    for (int i = 1; i <= n; i++) {
      if (!m[s[i]]) {
        m[s[i]]++;
        cout << s[i] << endl;
      } else {
        for (int j = 0; j < 10; j++) {
          s[i][1] = j + 48;
          int flag = 0;
          for (int k = i + 1; k <= n; k++)
            if (s[i] == s[k]) flag = 1;
          if (flag) continue;
          if (!m[s[i]]) {
            cout << s[i] << endl;
            m[s[i]]++;
            break;
          }
        }
      }
    }
  }
  return 0;
}
