#include <bits/stdc++.h>
using namespace std;
const int INF = 2034567891;
const long long int INF64 = 4234567890123456789ll;
long long nc3(long long v) { return (v * (v - 1ll) * (v - 2ll)) / 6ll; }
long long nc2(long long v) { return (v * (v - 1ll)) / 2ll; }
long long int gcd(long long int a, long long int b) {
  return (b == 0 ? a : gcd(b, a % b));
}
long long int lcm(long long int a, long long int b) {
  return (a * (b / gcd(a, b)));
}
const int N = 10 + 2e5;
bool isprime(long long int n) {
  if (n < 2) return 0;
  if (n == 2) return 1;
  if (n % 2 == 0) return 0;
  for (long long int i = 3; i * i <= n; i++)
    if (n % i == 0) return 0;
  return 1;
}
double dist(pair<long long int, long long int> p1,
            pair<long long int, long long int> p2) {
  return (p1.first - p2.first) * (p1.first - p2.first) +
         (p1.second - p2.second) * (p1.second - p2.second);
}
long long int power(long long int x, long long int y) {
  long long int ans = 1;
  while (y > 0) {
    if (y & 1) ans = (ans * x) % 1000000007;
    x = (x * x) % 1000000007;
    y /= 2;
  }
  return ans % 1000000007;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    long long int n = s.size();
    long long int cnt[3];
    memset(cnt, 0, sizeof(cnt));
    for (long long int i = 0; i < n; i++) {
      if (s[i] <= 'z' && s[i] >= 'a')
        cnt[0]++;
      else if (s[i] <= 'Z' && s[i] >= 'A')
        cnt[1]++;
      else
        cnt[2]++;
    }
    sort(cnt, cnt + 3);
    if (cnt[0] > 0)
      cout << s << endl;
    else if (cnt[1] > 0) {
      long long int a = 0, b = 0, c = 0, id1, id2, id3;
      string ans;
      for (long long int i = 0; i < n; i++) {
        if (s[i] <= 'z' && s[i] >= 'a')
          a++, id1 = i;
        else if (s[i] <= 'Z' && s[i] >= 'A')
          b++, id2 = i;
        else
          c++, id3 = i;
      }
      if (a > 0 && b > 0) {
        for (long long int i = 0; i < n; i++) {
          if (id1 != i && id2 != i) {
            s[i] = '1';
            break;
          }
        }
      } else if (a > 0 && c > 0) {
        for (long long int i = 0; i < n; i++)
          if (id1 != i && id3 != i) {
            s[i] = 'A';
            break;
          }
      } else {
        for (long long int i = 0; i < n; i++)
          if (id2 != i && id3 != i) {
            s[i] = 'a';
            break;
          }
      }
      cout << s << endl;
    } else {
      string ans;
      if (s[0] <= 'z' && s[0] >= 'a')
        ans = "A1";
      else if (s[0] <= 'Z' && s[0] >= 'A')
        ans = "a1";
      else
        ans = "Aa";
      ans += s.substr(2);
      cout << ans << endl;
    }
  }
}
