#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    long long int c1 = 0, c2 = 0, c3 = 0;
    for (int i = 0; i < s.size(); ++i) {
      if (s[i] >= 'a' && s[i] <= 'z')
        c1++;
      else if (s[i] >= 'A' && s[i] <= 'Z')
        c2++;
      else
        c3++;
    }
    if (c1 != 0 && c2 != 0 && c3 != 0)
      cout << s << "\n";
    else {
      long long int cc = 0;
      if (c1 == 0) cc++;
      if (c2 == 0) cc++;
      if (c3 == 0) cc++;
      if (cc == 2) {
        if (c1 == 0)
          s[0] = 'a';
        else if (c2 == 0)
          s[0] = 'A', c2++;
        if (c2 == 0)
          s[1] = 'A';
        else if (c3 == 0)
          s[1] = '1';
        cout << s << "\n";
      } else {
        for (int i = 0; i < s.size(); i++) {
          if (s[i] >= 'a' && s[i] <= 'z' && c1 > 1) {
            if (c2 == 0)
              s[i] = 'A';
            else if (c3 == 0)
              s[i] = '1';
            break;
          }
          if (s[i] >= 'A' && s[i] <= 'Z' && c2 > 1) {
            if (c1 == 0)
              s[i] = 'a';
            else if (c3 == 0)
              s[i] = '1';
            break;
          }
          if (s[i] >= '0' && s[i] <= '9' && c3 > 1) {
            if (c1 == 0)
              s[i] = 'a';
            else if (c2 == 0)
              s[i] = 'A';
            break;
          }
        }
        cout << s << "\n";
      }
    }
  }
  return 0;
}
