#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
void yes() {
  cout << "YES\n";
  return;
}
void no() {
  cout << "NO\n";
  return;
}
void solve(int case_no) {
  string str;
  cin >> str;
  int strl = str.length();
  int cnt[3] = {0, 0, 0};
  for (int i = 0; i < strl; i++) {
    isdigit(str[i]) ? cnt[0]++ : isupper(str[i]) ? cnt[1]++ : cnt[2]++;
  }
  if (cnt[0] == 0) {
    pair<int, int> t = {0, 0};
    for (int i = 0; i < strl; i++) {
      isupper(str[i]) ? t.first++ : t.second++;
      if (t.first == 2) {
        str[i] = '0';
        cnt[0]++;
        cnt[1]--;
        break;
      } else if (t.second == 2) {
        str[i] = '0';
        cnt[0]++;
        cnt[2]--;
        break;
      }
    }
  }
  if (cnt[1] == 0) {
    pair<int, int> t = {0, 0};
    for (int i = 0; i < strl; i++) {
      isdigit(str[i]) ? t.first++ : t.second++;
      if (t.first == 2) {
        str[i] = 'A';
        cnt[1]++;
        cnt[0]--;
        break;
      } else if (t.second == 2) {
        str[i] = 'A';
        cnt[1]++;
        cnt[2]--;
        break;
      }
    }
  }
  if (cnt[2] == 0) {
    pair<int, int> t = {0, 0};
    for (int i = 0; i < strl; i++) {
      isdigit(str[i]) ? t.first++ : t.second++;
      if (t.first == 2) {
        str[i] = 'a';
        cnt[2]++;
        cnt[0]--;
        break;
      } else if (t.second == 2) {
        str[i] = 'a';
        cnt[2]++;
        cnt[1]--;
        break;
      }
    }
  }
  cout << str << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  srand(time(NULL));
  int t = 1;
  cin >> t;
  for (int i = 1; i <= t; i++) solve(i);
}
