#include <bits/stdc++.h>
using namespace std;
long long int powermodm(long long int x, long long int n, long long int M) {
  long long int result = 1;
  while (n > 0) {
    if (n % 2 == 1) result = (result * x) % M;
    x = (x * x) % M;
    n = n / 2;
  }
  return result;
}
long long int power(long long int _a, long long int _b) {
  long long int _r = 1;
  while (_b) {
    if (_b % 2 == 1) _r = (_r * _a);
    _b /= 2;
    _a = (_a * _a);
  }
  return _r;
}
long long int gcd(long long int a, long long int b) {
  while (a && b) a > b ? a %= b : b %= a;
  return a + b;
}
long long int lcm(long long int a, long long int b) {
  return (max(a, b) / gcd(a, b)) * min(a, b);
}
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 i, j, l = s.length();
    long long int c1 = 0, c2 = 0, c3 = 0;
    for (i = 0; i < l; i++) {
      if (s[i] >= '0' && s[i] <= '9') c1++;
      if (s[i] >= 'a' && s[i] <= 'z') c2++;
      if (s[i] >= 'A' && s[i] <= 'Z') c3++;
    }
    long long int cnt = 0;
    if (c1 == 0) cnt++;
    if (c2 == 0) cnt++;
    if (c3 == 0) cnt++;
    if (c1 && c2 && c3)
      cout << s << endl;
    else {
      if (cnt == 1) {
        if (!c1) {
          for (i = 0; i < l; i++) {
            if (s[i] >= 'a' && s[i] <= 'z' && c2 > 1) {
              s[i] = '1';
              break;
            }
            if (s[i] >= 'A' && s[i] <= 'Z' && c3 > 1) {
              s[i] = '1';
              break;
            }
          }
        }
        if (!c2) {
          for (i = 0; i < l; i++) {
            if (s[i] >= '0' && s[i] <= '9' && c1 > 1) {
              s[i] = 'a';
              break;
            }
            if (s[i] >= 'A' && s[i] <= 'Z' && c3 > 1) {
              s[i] = 'a';
              break;
            }
          }
        }
        if (!c3) {
          for (i = 0; i < l; i++) {
            if (s[i] >= 'a' && s[i] <= 'z' && c2 > 1) {
              s[i] = 'A';
              break;
            }
            if (s[i] >= '0' && s[i] <= '9' && c1 > 1) {
              s[i] = 'A';
              break;
            }
          }
        }
        cout << s << endl;
      } else {
        if (c1) {
          s[1] = 'a';
          s[2] = 'A';
        } else if (c2) {
          s[1] = '1';
          s[2] = 'A';
        } else {
          s[1] = 'a';
          s[2] = '1';
        }
        cout << s << endl;
      }
    }
  }
  return 0;
}
