#include <bits/stdc++.h>
using namespace std;
template <typename T>
void out(T x) {
  cout << x << endl;
  exit(0);
}
const int maxn = 1e6 + 7;
string miss1(char c, int i, int j, string& s, vector<set<int>>& v) {
  if (v[i].size() >= 2) {
    int idx = *v[i].begin();
    s[idx] = c;
    return s;
  }
  if (v[j].size() >= 2) {
    int idx = *v[j].begin();
    s[idx] = c;
    return s;
  }
  assert(false);
  return "";
}
string miss2(char c1, char c2, int i, string& s, vector<set<int>>& v) {
  int idx1 = *v[i].begin();
  v[i].erase(v[i].begin());
  int idx2 = *v[i].begin();
  s[idx1] = c1;
  s[idx2] = c2;
  return s;
}
string solve() {
  string s;
  cin >> s;
  int n = (int)s.size();
  vector<set<int>> v = {{}, {}, {}};
  for (int i = 0; i < n; i++) {
    if (!isalpha(s[i])) v[0].insert(i);
    if (islower(s[i])) v[1].insert(i);
    if (isupper(s[i])) v[2].insert(i);
  }
  int cnt = 0;
  for (int i = 0; i < 3; i++) {
    if (v[i].empty()) cnt += pow(2, i);
  }
  if (cnt == 0) {
    return s;
  }
  if (cnt == 1) {
    return miss1('1', 1, 2, s, v);
  }
  if (cnt == 2) {
    return miss1('a', 0, 2, s, v);
  }
  if (cnt == 4) {
    return miss1('A', 0, 1, s, v);
  }
  if (cnt == 3) {
    return miss2('1', 'a', 2, s, v);
  }
  if (cnt == 5) {
    return miss2('1', 'A', 1, s, v);
  }
  if (cnt == 6) {
    return miss2('A', 'a', 0, s, v);
  }
  assert(false);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int T;
  cin >> T;
  while (T--) {
    cout << solve() << "\n";
  }
  return 0;
}
