#include <bits/stdc++.h>
using namespace std;
int t;
char s[105];
int main() {
  while (cin >> t) {
    int a, b, c;
    while (t--) {
      a = 0, b = 0, c = 0;
      memset(s, 0, sizeof(t));
      cin >> s;
      int len = strlen(s);
      for (int i = 0; i < len; i++) {
        if (islower(s[i])) a++;
        if (isupper(s[i])) b++;
        if (isdigit(s[i])) c++;
        if (a != 0 && b != 0 && c != 0) {
          cout << s << endl;
          break;
        }
      }
      if (a == 0 && b != 0 && c != 0) {
        if (b == 1) {
          for (int i = 0; i < len; i++) {
            if (isdigit(s[i])) {
              s[i] = 'a';
              break;
            }
          }
        } else if (c == 1) {
          for (int i = 0; i < len; i++) {
            if (isupper(s[i])) {
              s[i] = 'a';
              break;
            }
          }
        } else {
          s[0] = 'a';
        }
        cout << s << endl;
      } else if (a != 0 && b == 0 && c != 0) {
        if (a == 1) {
          for (int i = 0; i < len; i++) {
            if (isdigit(s[i])) {
              s[i] = 'A';
              break;
            }
          }
        } else if (c == 1) {
          for (int i = 0; i < len; i++) {
            if (islower(s[i])) {
              s[i] = 'A';
              break;
            }
          }
        } else {
          s[0] = 'A';
        }
        cout << s << endl;
      } else if (a != 0 && b != 0 && c == 0) {
        if (a == 1) {
          for (int i = 0; i < len; i++) {
            if (isupper(s[i])) {
              s[i] = '1';
              break;
            }
          }
        } else if (b == 1) {
          for (int i = 0; i < len; i++) {
            if (islower(s[i])) {
              s[i] = '1';
              break;
            }
          }
        } else {
          s[0] = '1';
        }
        cout << s << endl;
      } else if (a == 0 && b == 0 && c != 0) {
        s[0] = 'a';
        s[1] = 'A';
        cout << s << endl;
      } else if (a == 0 && b != 0 && c == 0) {
        s[0] = 'a';
        s[1] = '1';
        cout << s << endl;
      } else if (a != 0 && b == 0 && c == 0) {
        s[0] = 'A';
        s[1] = '1';
        cout << s << endl;
      }
    }
  }
  return 0;
}
