#include <bits/stdc++.h>
using namespace std;
inline int two(int n) { return 1 << n; }
inline void set_bit(int& n, int b) { n |= two(b); }
inline void unset_bit(int& n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
template <class T>
T gcd(T a, T b) {
  return (b != 0 ? gcd<T>(b, a % b) : a);
}
template <class T>
T lcm(T a, T b) {
  return (a / gcd<T>(a, b) * b);
}
int dr[] = {-1, 0, 1, 0}, dc[] = {0, 1, 0, -1};
int main() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    vector<int> dig, low, up;
    int freq[400] = {0};
    string s;
    cin >> s;
    for (int j = 0; j < s.size(); ++j) {
      if (islower(s[j]))
        low.push_back(j);
      else if (isupper(s[j]))
        up.push_back(j);
      else
        dig.push_back(j);
    }
    if (low.size() && up.size() && dig.size())
      cout << s << '\n';
    else {
      if (dig.size() == 0) {
        if (low.size() > 1)
          s[low.back()] = '1', low.pop_back();
        else if (up.size() > 1)
          s[up.back()] = '1', up.pop_back();
      }
      if (low.size() == 0) {
        if (dig.size() > 1)
          s[dig.back()] = 'a', dig.pop_back();
        else if (up.size() > 1)
          s[up.back()] = 'a', up.pop_back();
      }
      if (up.size() == 0) {
        if (dig.size() > 1)
          s[dig.back()] = 'A';
        else if (low.size() > 1)
          s[low.back()] = 'A';
      }
      cout << s << '\n';
    }
  }
}
