#include <bits/stdc++.h>
using namespace std;
long long int func(char c) {
  if (c >= 'a' && c <= 'z') {
    return 1;
  }
  if (c >= 'A' && c <= 'Z') {
    return 2;
  }
  return 0;
}
void solve() {
  string s;
  cin >> s;
  long long int lw = 0;
  long long int up = 0;
  long long int nm = 0;
  string str = s;
  long long int mp[3] = {0};
  for (long long int i = 0; i < s.length(); i++) {
    mp[func(s[i])]++;
  }
  long long int cn = 0;
  for (long long int i = 0; i < 3; i++) {
    if (!mp[i]) cn++;
  }
  if (!cn) {
    cout << s << endl;
    return;
  }
  if (cn == 1) {
    for (long long int i = 0; i < s.length(); i++) {
      if (mp[func(s[i])] > 1) {
        long long int index = 0;
        for (long long int id = 0; id < 3; id++) {
          if (!mp[id]) index = id;
        }
        if (index == 0) {
          s[i] = '0';
          break;
        } else if (index == 1) {
          s[i] = 'a';
          break;
        } else {
          s[i] = 'A';
          break;
        }
      }
    }
    cout << s << endl;
  } else {
    long long int index;
    for (long long int i = 0; i < 3; i++) {
      if (mp[i]) {
        index = i;
        break;
      }
    }
    if (index == 1) {
      s[0] = 'A';
      s[1] = '0';
    } else if (index == 0) {
      s[0] = 'A';
      s[1] = 'a';
    } else {
      s[0] = '0';
      s[1] = 'a';
    }
    cout << s << endl;
  }
}
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
