#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    vector<int> lower_pos, upper_pos, digit_pos;
    for (int i = 0; i < s.size(); i++) {
      if (islower(s[i]))
        lower_pos.push_back(i);
      else if (isupper(s[i]))
        upper_pos.push_back(i);
      else
        digit_pos.push_back(i);
    }
    if (lower_pos.size() == 0) {
      if (upper_pos.size() > 1) {
        int pos = upper_pos[0];
        s[pos] = tolower(s[pos]);
        lower_pos.push_back(pos);
        upper_pos.erase(upper_pos.begin());
      } else if (digit_pos.size() > 1) {
        int pos = digit_pos[0];
        s[pos] = 'a';
        lower_pos.push_back(pos);
        digit_pos.erase(digit_pos.begin());
      }
    }
    if (upper_pos.size() == 0) {
      if (lower_pos.size() > 1) {
        int pos = lower_pos[0];
        s[pos] = toupper(s[pos]);
        upper_pos.push_back(pos);
        lower_pos.erase(lower_pos.begin());
      } else if (digit_pos.size() > 1) {
        int pos = digit_pos[0];
        s[pos] = 'A';
        upper_pos.push_back(pos);
        digit_pos.erase(digit_pos.begin());
      }
    }
    if (digit_pos.size() == 0) {
      if (lower_pos.size() > 1) {
        int pos = lower_pos[0];
        s[pos] = '0';
        digit_pos.push_back(pos);
        lower_pos.erase(lower_pos.begin());
      } else if (upper_pos.size() > 1) {
        int pos = upper_pos[0];
        s[pos] = '0';
        digit_pos.push_back(pos);
        upper_pos.erase(upper_pos.begin());
      }
    }
    cout << s << endl;
  }
  return 0;
}
