#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int T;
  cin >> T;
  while (T--) {
    string S;
    cin >> S;
    vector<int> T(S.length());
    int C[3] = {0, 0, 0};
    string R = "5bD";
    for (int i = 0; i < S.length(); ++i) {
      char c = S[i];
      if ('0' <= c && c <= '9') ++C[0], T[i] = 0;
      if ('a' <= c && c <= 'z') ++C[1], T[i] = 1;
      if ('A' <= c && c <= 'Z') ++C[2], T[i] = 2;
    }
    int k = 3 - (C[0] > 0) - (C[1] > 0) - (C[2] > 0);
    if (k == 0) cout << S << '\n';
    if (k == 1) {
      for (int i = 0; i < S.length(); ++i)
        if (C[T[i]] > 1) {
          for (int j = 0; j < 3; ++j)
            if (C[j] == 0) {
              S[i] = R[j];
              break;
            }
          break;
        }
      cout << S << '\n';
    }
    if (k == 2) {
      int i = 0;
      for (int j = 0; j < 3; ++j)
        if (C[j] == 0) S[i++] = R[j];
      cout << S << '\n';
    }
  }
  return 0;
}
