#include <bits/stdc++.h>
using namespace std;
const long long N = 3e5 + 7;
const string ALPHA = "abcdefghijklmnopqrstuvwxyz";
long long power(long long x, long long y) {
  long long res = 1;
  x = x;
  while (y > 0) {
    if (y & 1) res = (res * x);
    y = y >> 1;
    x = (x * x);
  }
  return res;
}
template <typename T>
T gcd(T a, T b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
template <typename T>
T powm(T a, T b, long long m) {
  T cnt = 1;
  while (b > 0) {
    if (b % 2 == 1) cnt = (cnt * a) % m;
    b /= 2;
    a = (a * a) % m;
  }
  return cnt % m;
}
long long ncr(long long n, long long r) {
  long long res = 1;
  if (r > n) return 0;
  if (r > n - r) r = n - r;
  for (long long i = 0; i < r; i++) {
    res *= (n - i);
    res /= (i + 1);
  }
  return res;
}
long long sqr(long long x) { return x * x; }
void run() {
  string s;
  cin >> s;
  int n = s.length();
  int lo, up, d;
  lo = up = d = -1;
  for (int i = 0; i < n; i++) {
    if (islower(s[i])) {
      lo = i;
    } else if (isupper(s[i])) {
      up = i;
    } else if (isdigit(s[i])) {
      d = i;
    }
  }
  for (int i = 0; i < n; i++) {
    if (lo == -1 && i != up && i != d) {
      s[i] = 'a';
      lo = i;
    } else if (up == -1 && i != lo && i != d) {
      s[i] = 'A';
      up = i;
    } else if (d == -1 && i != up && i != lo) {
      s[i] = '9';
      d = i;
    }
  }
  cout << s << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int tc;
  tc = 1;
  cin >> tc;
  while (tc--) run();
  return 0;
}
