#include <bits/stdc++.h>
using namespace std;
inline long long power(long long a, long long b) {
  long long x = 1;
  a = a % 1000000007ULL;
  while (b) {
    if (b & 1) x = (x * a) % 1000000007ULL;
    a = (a * a) % 1000000007ULL;
    b >>= 1;
  }
  return x;
}
inline long long inv(long long a) { return power(a, 1000000007ULL - 2); }
long long gcd(long long a, long long b) { return a ? gcd(b % a, a) : b; }
const int N = 1e5 + 5;
int t;
string pass;
vector<int> v[4];
int main() {
  ios_base::sync_with_stdio(false);
  cin >> t;
  while (t--) {
    cin >> pass;
    int n = pass.size();
    v[0].clear();
    v[1].clear();
    v[2].clear();
    for (int i = 0; i < n; i++) {
      if (pass[i] - '0' < 10)
        v[2].push_back(i);
      else if (pass[i] - 'A' < 26)
        v[1].push_back(i);
      else
        v[0].push_back(i);
    }
    int c1, c2, c3;
    c1 = v[0].size() - 1;
    c2 = v[1].size() - 1;
    c3 = v[2].size() - 1;
    if (v[0].size() == 0) {
      if (c2 > 0) {
        pass[v[1][c2]] = 'a';
        c2--;
      } else if (c3 > 0) {
        pass[v[2][c3]] = 'a';
        c3--;
      }
    }
    if (v[1].size() == 0) {
      if (c1 > 0) {
        pass[v[0][c1]] = 'A';
        c1--;
      } else if (c3 > 0) {
        pass[v[2][c3]] = 'A';
        c3--;
      }
    }
    if (v[2].size() == 0) {
      if (c1 > 0) {
        pass[v[0][c1]] = '1';
        c1--;
      } else if (c2 > 0) {
        pass[v[1][c2]] = '1';
        c2--;
      }
    }
    cout << pass << "\n";
  }
  return 0;
}
