#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  long long int t;
  cin >> t;
  while (t--) {
    cin >> s;
    long long int num_pos = 0;
    long long int up_pos = 0;
    long long int up_cnt = 0;
    long long int num_cnt = 0;
    long long int low_pos = 0;
    for (long long int i = 0; i < s.size(); i++) {
      if (s[i] >= 'A' && s[i] <= 'Z') {
        up_cnt++;
        up_pos = i;
      }
      if (s[i] >= '0' && s[i] <= '9') {
        num_cnt++;
        num_pos = i;
      }
      if (s[i] >= 'a' && s[i] <= 'z') {
        low_pos = i;
      }
    }
    long long int low_cnt = s.size() - num_cnt - up_cnt;
    if (low_cnt && num_cnt && up_cnt) {
      cout << s << endl;
      continue;
    }
    if (low_cnt && num_cnt) {
      if (num_cnt > 1) {
        s[num_pos] = 'A';
        cout << s << endl;
        continue;
      }
      if (low_cnt > 1) {
        s[low_pos] = 'A';
        cout << s << endl;
        continue;
      }
    }
    if (up_cnt && num_cnt) {
      if (num_cnt > 1) {
        s[num_pos] = 'a';
        cout << s << endl;
        continue;
      }
      if (up_cnt > 1) {
        s[up_pos] = 'a';
        cout << s << endl;
        continue;
      }
    }
    if (low_cnt && up_cnt) {
      if (up_cnt > 1) {
        s[up_pos] = '1';
        cout << s << endl;
        continue;
      }
      if (low_cnt > 1) {
        s[low_pos] = '1';
        cout << s << endl;
        continue;
      }
    }
    if (low_cnt) {
      s[0] = 'A';
      s[1] = '1';
      cout << s << endl;
      continue;
    }
    if (up_cnt) {
      s[0] = 'a';
      s[1] = '1';
      cout << s << endl;
      continue;
    }
    if (num_cnt) {
      s[0] = 'A';
      s[1] = 'a';
      cout << s << endl;
      continue;
    }
  }
}
