#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int main() {
  cin.tie(0), cout.tie(0);
  ios::sync_with_stdio(false);
  int t;
  cin >> t;
  while (t--) {
    int u = 0, l = 0, d = 0;
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
      if (s[i] >= 'a' && s[i] <= 'z') {
        l++;
      }
      if (s[i] >= 'A' && s[i] <= 'Z') {
        u++;
      }
      if (s[i] >= '0' && s[i] <= '9') {
        d++;
      }
    }
    for (int i = 0; i < s.size(); i++) {
      if (s[i] >= 'a' && s[i] <= 'z' && l > 1) {
        if (!u) {
          s[i] = 'A';
          u++;
        } else if (!d) {
          s[i] = '0';
          d++;
        }
      } else if (s[i] >= 'A' && s[i] <= 'Z' && u > 1) {
        if (!l) {
          s[i] = 'a';
          l++;
        } else if (!d) {
          s[i] = '0';
          d++;
        }
      } else if (s[i] >= '0' && s[i] <= '9' && d > 1) {
        if (!l) {
          s[i] = 'a';
          l++;
        } else if (!u) {
          s[i] = 'A';
          u++;
        }
      }
    }
    cout << s << endl;
  }
}
