#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    int l = s.length();
    vector<int> posdi, poscap, possmal;
    int di = 0, cap = 0, smal = 0;
    for (int i = 0; i < l; i++) {
      if (s[i] >= '0' && s[i] <= '9') {
        posdi.push_back(i);
        di++;
      } else if (s[i] >= 'A' && s[i] <= 'Z') {
        poscap.push_back(i);
        cap++;
      } else if (s[i] >= 'a' && s[i] <= 'z') {
        possmal.push_back(i);
        smal++;
      }
    }
    if (di > 0 && cap > 0 && smal > 0)
      cout << s;
    else {
      int l1 = posdi.size();
      int l2 = poscap.size();
      int l3 = possmal.size();
      if (di == 0) {
        if (l2 > 1) {
          s[poscap[0]] = '1';
          poscap.erase(poscap.begin());
          l2--;
        } else if (l3 > 1) {
          s[possmal[0]] = '1';
          possmal.erase(possmal.begin());
          l3--;
        }
      }
      if (cap == 0) {
        if (l1 > 1) {
          s[posdi[0]] = 'A';
          posdi.erase(posdi.begin());
          l1--;
        } else if (l3 > 1) {
          s[possmal[0]] = 'A';
          possmal.erase(possmal.begin());
          l3--;
        }
      }
      if (smal == 0) {
        if (l2 > 1) {
          s[poscap[0]] = 'a';
          poscap.erase(poscap.begin());
          l2--;
        } else if (l1 > 1) {
          s[posdi[0]] = 'a';
          posdi.erase(posdi.begin());
          l1--;
        }
      }
      cout << s;
    }
    cout << "\n";
  }
  return 0;
}
