#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int _inf = 0xc0c0c0c0;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const long long _INF = 0xc0c0c0c0c0c0c0c0;
const long long mod = (int)1e9 + 7;
const int N = 1e5 + 100;
char s[N];
int main() {
  int T;
  int low, upp, dig;
  scanf("%d", &T);
  while (T--) {
    scanf("%s", s);
    int len = strlen(s);
    low = upp = dig = 0;
    for (int i = 0; i < len; ++i) {
      if (islower(s[i]))
        low++;
      else if (isupper(s[i]))
        upp++;
      else
        dig++;
    }
    if (low == 0 && upp == 0) {
      s[0] = 'A';
      s[1] = 'a';
    } else if (low == 0 && dig == 0)
      s[0] = 'a', s[1] = '1';
    else if (dig == 0 && upp == 0)
      s[0] = '1', s[1] = 'A';
    else if (low == 0) {
      if (upp > 1) {
        for (int i = 0; i < len; ++i)
          if (isupper(s[i])) {
            s[i] = 'a';
            break;
          };
      } else {
        for (int i = 0; i < len; ++i)
          if (isdigit(s[i])) {
            s[i] = 'a';
            break;
          };
      }
    } else if (dig == 0) {
      if (upp > 1) {
        for (int i = 0; i < len; ++i)
          if (isupper(s[i])) {
            s[i] = '1';
            break;
          };
      } else {
        for (int i = 0; i < len; ++i)
          if (islower(s[i])) {
            s[i] = '1';
            break;
          };
      }
    } else if (upp == 0) {
      if (low > 1) {
        for (int i = 0; i < len; ++i)
          if (islower(s[i])) {
            s[i] = 'A';
            break;
          };
      } else {
        for (int i = 0; i < len; ++i)
          if (isdigit(s[i])) {
            s[i] = 'A';
            break;
          };
      }
    }
    printf("%s\n", s);
  }
  return 0;
}
