#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    map<char, int> m1;
    m1['u'] = 0;
    m1['l'] = 0;
    m1['n'] = 0;
    for (int i = 0; i < s.length(); i++) {
      if (s[i] <= 'Z' && s[i] >= 'A') {
        m1['u']++;
      }
      if (s[i] <= 'z' && s[i] >= 'a') {
        m1['l']++;
      }
      if (s[i] <= '9' && s[i] >= '0') {
        m1['n']++;
      }
    }
    if (m1['u'] > 1) {
      int index = 0;
      if (m1['l'] == 0) {
        while (1) {
          if (s[index] <= 'Z' && s[index] >= 'A') {
            s[index] = 'a';
            index++;
            break;
          } else {
            index++;
          }
        }
      }
      if (m1['n'] == 0) {
        while (1) {
          if (s[index] <= 'Z' && s[index] >= 'A') {
            s[index] = '1';
            index++;
            break;
          } else {
            index++;
          }
        }
      }
    } else {
      if (m1['l'] > 1) {
        int index = 0;
        if (m1['u'] == 0) {
          while (1) {
            if (s[index] <= 'z' && s[index] >= 'a') {
              s[index] = 'A';
              index++;
              break;
            } else {
              index++;
            }
          }
        }
        if (m1['n'] == 0) {
          while (1) {
            if (s[index] <= 'z' && s[index] >= 'a') {
              s[index] = '1';
              index++;
              break;
            } else {
              index++;
            }
          }
        }
      } else {
        int index = 0;
        if (m1['u'] == 0) {
          while (1) {
            if (s[index] <= '9' && s[index] >= '0') {
              s[index] = 'A';
              index++;
              break;
            } else {
              index++;
            }
          }
        }
        if (m1['l'] == 0) {
          while (1) {
            if (s[index] <= '9' && s[index] >= '0') {
              s[index] = 'z';
              index++;
              break;
            } else {
              index++;
            }
          }
        }
      }
    }
    cout << s << endl;
  }
}
