#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    string s;
    int isUpper = 0, isLower = 0, digit = 0;
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
      if (s[i] >= 'a' && s[i] <= 'z') {
        isLower++;
      } else if (s[i] >= 'A' && s[i] <= 'Z') {
        isUpper++;
      } else if (s[i] >= '0' && s[i] <= '9') {
        digit++;
      }
    }
    if (isLower == 0 && isUpper == 0) {
      s[0] = 'a';
      s[1] = 'A';
      cout << s << endl;
    } else if (digit == 0 && isUpper == 0) {
      s[0] = '4';
      s[1] = 'A';
      cout << s << endl;
    } else if (isLower == 0 && digit == 0) {
      s[0] = 'a';
      s[1] = '4';
      cout << s << endl;
    } else if (digit == 0) {
      for (int i = 0; i < s.size(); i++) {
        if (isUpper > 1 && isLower > 1) {
          s[i] = '4';
          break;
        }
        if (isUpper == 1 && (s[i] >= 'a' && s[i] <= 'z')) {
          s[i] = '4';
          break;
        }
        if (isLower == 1 && (s[i] >= 'A' && s[i] <= 'Z')) {
          s[i] = '4';
          break;
        }
      }
      cout << s << endl;
    } else if (isLower == 0) {
      for (int i = 0; i < s.size(); i++) {
        if (isUpper > 1 && digit > 1) {
          s[i] = 'a';
          break;
        }
        if (isUpper == 1 && (s[i] >= '0' && s[i] <= '9')) {
          s[i] = 'a';
          break;
        }
        if (digit == 1 && (s[i] >= 'A' && s[i] <= 'Z')) {
          s[i] = 'a';
          break;
        }
      }
      cout << s << endl;
    } else if (isUpper == 0) {
      for (int i = 0; i < s.size(); i++) {
        if (digit > 1 && isLower > 1) {
          s[i] = 'A';
          break;
        }
        if (digit == 1 && (s[i] >= 'a' && s[i] <= 'z')) {
          s[i] = 'A';
          break;
        }
        if (isLower == 1 && (s[i] >= '0' && s[i] <= '9')) {
          s[i] = 'A';
          break;
        }
      }
      cout << s << endl;
    } else {
      cout << s << endl;
    }
  }
}
