#include <bits/stdc++.h>
using namespace std;
void gethas(string s, int &has0, int &hasa, int &hasA) {
  int n = int(s.size());
  has0 = 0;
  hasa = 0;
  hasA = 0;
  for (int i = 0; i < n; i++) {
    char c = s[i];
    has0 = has0 or ('0' <= c and c <= '9');
    hasa = hasa or ('a' <= c and c <= 'z');
    hasA = hasA or ('A' <= c and c <= 'Z');
  }
}
bool valid(string s) {
  int has0, hasa, hasA;
  gethas(s, has0, hasa, hasA);
  return has0 and hasa and hasA;
}
bool check(string s) {
  if (valid(s)) {
    cout << s << endl;
    return true;
  }
  return false;
}
int cases;
int main() {
  cin >> cases;
  for (int cas = 0; cas < cases; cas++) {
    string s;
    cin >> s;
    if (check(s)) continue;
    int n = int(s.size());
    int has0, hasa, hasA;
    gethas(s, has0, hasa, hasA);
    if (has0 + hasa + hasA == 2) {
      for (int i = 0; i < n; i++) {
        if (check(s.substr(0, i) + "0" + s.substr(i + 1, n - i))) break;
        if (check(s.substr(0, i) + "a" + s.substr(i + 1, n - i))) break;
        if (check(s.substr(0, i) + "A" + s.substr(i + 1, n - i))) break;
      }
      continue;
    }
    for (int i = 0; i < n - 1; i++) {
      if (check(s.substr(0, i) + "0a" + s.substr(i + 2, n - i - 1))) break;
      if (check(s.substr(0, i) + "0A" + s.substr(i + 2, n - i - 1))) break;
      if (check(s.substr(0, i) + "aA" + s.substr(i + 2, n - i - 1))) break;
    }
  }
}
