#include <bits/stdc++.h>
using namespace std;
const int maxn = 105;
const int MOD = 1000000007;
int T, n;
char s[maxn];
int main() {
  scanf("%d", &n);
  while (n--) {
    scanf("%s", s);
    int len = strlen(s);
    int counta, countA, count1;
    counta = countA = count1 = 0;
    for (int i = 0; i < len; i++) {
      if (s[i] >= 'a' && s[i] <= 'z')
        counta++;
      else if (s[i] >= 'A' && s[i] <= 'Z')
        countA++;
      else
        count1++;
    }
    if (counta == 0) {
      if (countA > 1) {
        for (int i = 0; i < len; i++) {
          if (s[i] >= 'A' && s[i] <= 'Z') {
            s[i] = 'a';
            break;
          }
        }
      } else if (count1 > 1) {
        for (int i = 0; i < len; i++) {
          if (s[i] >= '0' && s[i] <= '9') {
            s[i] = 'a';
            break;
          }
        }
      }
    }
    if (countA == 0) {
      if (counta > 1) {
        for (int i = 0; i < len; i++) {
          if (s[i] >= 'a' && s[i] <= 'z') {
            s[i] = 'A';
            break;
          }
        }
      } else if (count1 > 1) {
        for (int i = 0; i < len; i++) {
          if (s[i] >= '0' && s[i] <= '9') {
            s[i] = 'A';
            break;
          }
        }
      }
    }
    if (count1 == 0) {
      if (countA > 1) {
        for (int i = 0; i < len; i++) {
          if (s[i] >= 'A' && s[i] <= 'Z') {
            s[i] = '1';
            break;
          }
        }
      } else if (counta > 1) {
        for (int i = 0; i < len; i++) {
          if (s[i] >= 'a' && s[i] <= 'z') {
            s[i] = '1';
            break;
          }
        }
      }
    }
    for (int i = 0; i < len; i++) printf("%c", s[i]);
    printf("\n");
  }
  return 0;
}
