#include <bits/stdc++.h>
using namespace std;
int digit(char c) {
  char digits[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
  for (int i = 0; i < 10; i++) {
    if (c == digits[i]) return 0;
  }
  return 1;
}
int main() {
  int t = 0;
  scanf("%d", &t);
  while (t--) {
    string s;
    cin >> s;
    int len = s.length();
    int d = 1, c = 1, l = 1;
    int cd = 0, cc = 0, cl = 0;
    int flag = 0;
    for (int i = 0; i < len; i++) {
      if (int(s[i]) >= 48 && int(s[i]) <= 57) {
        d = 0;
        ++cd;
      } else if (tolower(s[i]) == s[i]) {
        l = 0;
        ++cl;
      } else if (toupper(s[i]) == s[i]) {
        c = 0;
        ++cc;
      }
      if ((d + c + l) == 0) {
        flag = 1;
        break;
      }
    }
    if (flag == 1) {
      cout << s << endl;
      continue;
    }
    if ((d + c + l) == 1) {
      if (d) {
        if (cl <= cc) {
          for (int i = 0; i < len; i++) {
            if (toupper(s[i]) == s[i]) {
              s[i] = '7';
              break;
            }
          }
        } else {
          for (int i = 0; i < len; i++) {
            if (tolower(s[i]) == s[i]) {
              s[i] = '7';
              break;
            }
          }
        }
        d = 0;
      }
      if (c) {
        if (cl <= cd) {
          for (int i = 0; i < len; i++) {
            if (int(s[i]) >= 48 && int(s[i]) <= 57) {
              s[i] = 'A';
              break;
            }
          }
        } else {
          for (int i = 0; i < len; i++) {
            if (tolower(s[i]) == s[i] && digit(s[i])) {
              s[i] = toupper(s[i]);
              break;
            }
          }
        }
        c = 0;
      }
      if (l) {
        if (cc <= cd) {
          for (int i = 0; i < len; i++) {
            if (int(s[i]) >= 48 && int(s[i]) <= 57) {
              s[i] = 'a';
              break;
            }
          }
        } else {
          for (int i = 0; i < len; i++) {
            if (toupper(s[i]) == s[i] && digit(s[i])) {
              s[i] = tolower(s[i]);
              break;
            }
          }
        }
      }
      l = 0;
    }
    if ((d + c + l) == 2) {
      if (!d) {
        s[0] = 'A';
        s[1] = 'a';
      }
      if (!c) {
        s[0] = 'a';
        s[1] = '7';
      }
      if (!l) {
        s[0] = 'A';
        s[1] = '7';
      }
    }
    cout << s << endl;
  }
  return 0;
}
