#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
map<int, int> cnt;
int main() {
  int t;
  cin >> t;
  string s;
  while (t--) {
    cnt.clear();
    cin >> s;
    for (char c : s) {
      if ('0' <= c && c <= '9')
        cnt[0]++;
      else if ('a' <= c && c <= 'z')
        cnt[1]++;
      else
        cnt[2]++;
    }
    if (cnt[0] && cnt[1] && cnt[2]) {
      cout << s << endl;
    } else if (cnt[0] && cnt[1]) {
      bool f = 0;
      if (cnt[0] > 1) {
        for (auto c : s) {
          if (!f && '0' <= c && c <= '9') {
            f = 1;
            cout << 'A';
          } else
            cout << c;
        }
      } else {
        for (auto c : s) {
          if (!f && 'a' <= c && c <= 'z') {
            f = 1;
            cout << 'A';
          } else
            cout << c;
        }
      }
      cout << endl;
    } else if (cnt[1] && cnt[2]) {
      bool f = 0;
      if (cnt[1] > 1) {
        for (auto c : s) {
          if (!f && 'a' <= c && c <= 'z') {
            f = 1;
            cout << 0;
          } else
            cout << c;
        }
      } else {
        for (auto c : s) {
          if (!f && 'A' <= c && c <= 'Z') {
            f = 1;
            cout << 0;
          } else
            cout << c;
        }
      }
      cout << endl;
    } else if (cnt[0] && cnt[2]) {
      bool f = 0;
      if (cnt[0] > 1) {
        for (auto c : s) {
          if (!f && '0' <= c && c <= '9') {
            f = 1;
            cout << 'a';
          } else
            cout << c;
        }
      } else {
        for (auto c : s) {
          if (!f && 'A' <= c && c <= 'Z') {
            f = 1;
            cout << 'a';
          } else
            cout << c;
        }
      }
      cout << endl;
    } else if (cnt[0]) {
      cout << "aA";
      for (int i = 2; i < s.length(); i++) cout << s[i];
      cout << endl;
    } else if (cnt[1]) {
      cout << "0A";
      for (int i = 2; i < s.length(); i++) cout << s[i];
      cout << endl;
    } else if (cnt[2]) {
      cout << "0a";
      for (int i = 2; i < s.length(); i++) cout << s[i];
      cout << endl;
    }
  }
  return 0;
}
