#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  string s;
  for (int i = 0; i < n; i++) {
    int a = 0, b = 0, c = 0;
    cin >> s;
    for (__typeof(s.size()) j = (0) - ((0) > (s.size()));
         j != (s.size()) - ((0) > (s.size()));
         j += 1 - 2 * ((0) > (s.size()))) {
      if (islower(s[j]))
        a++;
      else if (isupper(s[j]))
        b++;
      else
        c++;
    }
    if (a and b and c)
      cout << s << endl;
    else {
      if (c == 0) {
        if (a > 1) {
          for (__typeof(s.size()) j = (0) - ((0) > (s.size()));
               j != (s.size()) - ((0) > (s.size()));
               j += 1 - 2 * ((0) > (s.size())))
            if (islower(s[j])) {
              s[j] = '1';
              break;
            }
        } else if (b > 1) {
          for (__typeof(s.size()) j = (0) - ((0) > (s.size()));
               j != (s.size()) - ((0) > (s.size()));
               j += 1 - 2 * ((0) > (s.size())))
            if (isupper(s[j])) {
              s[j] = '1';
              break;
            }
        }
        c++;
      }
      if (b == 0) {
        if (a > 1) {
          for (__typeof(s.size()) j = (0) - ((0) > (s.size()));
               j != (s.size()) - ((0) > (s.size()));
               j += 1 - 2 * ((0) > (s.size())))
            if (islower(s[j])) {
              s[j] = toupper(s[j]);
              break;
            }
        } else if (c > 1) {
          for (__typeof(s.size()) j = (0) - ((0) > (s.size()));
               j != (s.size()) - ((0) > (s.size()));
               j += 1 - 2 * ((0) > (s.size())))
            if (!islower(s[j])) {
              s[j] = 'A';
              break;
            }
        }
        b++;
      }
      if (a == 0) {
        if (b > 1) {
          for (__typeof(s.size()) j = (0) - ((0) > (s.size()));
               j != (s.size()) - ((0) > (s.size()));
               j += 1 - 2 * ((0) > (s.size())))
            if (isupper(s[j])) {
              s[j] = tolower(s[j]);
              break;
            }
        } else if (c > 1) {
          for (__typeof(s.size()) j = (0) - ((0) > (s.size()));
               j != (s.size()) - ((0) > (s.size()));
               j += 1 - 2 * ((0) > (s.size())))
            if (!isupper(s[j])) {
              s[j] = 'a';
              break;
            }
        }
        a++;
      }
      cout << s << endl;
    }
  }
  return 0;
}
