#include <bits/stdc++.h>
using namespace std;
inline void file() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  if (0) {
    freopen(".in", "r", stdin);
    freopen(".out", "w", stdout);
  }
}
const int PX[8] = {1, 0, -1, 0, 1, 1, -1, -1},
          PY[8] = {0, 1, 0, -1, -1, 1, 1, -1}, N = 2e6 + 10, INF = 1e9,
          MOD = 1e9 + 7;
const long long INFL = 1e18, MODL = 1e9 + 7;
const long double EPS = 1e-6;
template <typename type>
inline void up(type& a, type b) {
  if (a < b) a = b;
}
inline long long rnd(long long l = 1, long long r = INFL) {
  unsigned long long ans = rand();
  ans = (ans << 16LL) ^ rand();
  ans = (ans << 16LL) ^ rand();
  ans = (ans << 16LL) ^ rand();
  ans %= r - l + 1;
  return (long long)ans + l;
}
int n, has[3], x[128];
inline string solve(string s) {
  has[0] = has[1] = has[2] = false;
  for (int j = 0; j < s.size(); ++j) {
    char i = s[j];
    if ('a' <= i && i <= 'z') x[j] = 0;
    if ('A' <= i && i <= 'Z') x[j] = 1;
    if ('0' <= i && i <= '9') x[j] = 2;
  }
  for (int i = 0; i < s.size(); ++i) has[x[i]]++;
  int mx = 0;
  for (int i = 0; i < 3; ++i)
    if (has[i] > has[mx]) mx = i;
  for (int i = 0; i < s.size(); ++i)
    if (x[i] == mx)
      for (int j = 0; j < 3; ++j)
        if (!has[j]) {
          has[j]++;
          if (j == 0) s[i] = 'a';
          if (j == 1) s[i] = 'A';
          if (j == 2) s[i] = '0';
          break;
        }
  return s;
}
int main() {
  file();
  string s;
  int t;
  cin >> t;
  while (t--) {
    cin >> s;
    cout << solve(s) << '\n';
  }
}
