#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie();
  int t, k;
  cin >> t;
  for (k = 0; k < t; ++k) {
    string s;
    cin >> s;
    vector<int> counter(3);
    vector<vector<int> > position(3);
    for (auto i : s)
      if (isdigit(i))
        counter[0]++;
      else if (islower(i))
        counter[1]++;
      else if (isupper(i))
        counter[2]++;
    if (counter[0] && counter[1] && counter[2])
      cout << s << endl;
    else {
      bool f = 0;
      while (!counter[0] || !counter[1] || !counter[2]) {
        for (auto &i : s) {
          if (isdigit(i) && counter[0] >= counter[1] + counter[2]) {
            if (counter[1] < counter[2]) {
              i = 'a';
              counter[1]++;
            } else {
              i = 'A';
              counter[2]++;
            }
          } else if (islower(i) && counter[1] >= counter[0] + counter[2]) {
            if (counter[0] < counter[2]) {
              i = '1';
              counter[0]++;
            } else {
              i = 'A';
              counter[2]++;
            }
          } else if (isupper(i) && counter[2] >= counter[0] + counter[1]) {
            if (counter[0] < counter[1]) {
              i = '1';
              counter[0]++;
            } else {
              i = 'a';
              counter[1]++;
            }
          }
          if (counter[0] && counter[1] && counter[2]) {
            f = 1;
            break;
          }
        }
        if (f) break;
      }
      cout << s << endl;
    }
  }
  return 0;
}
