#include <bits/stdc++.h>
using namespace std;
char ch[105];
int ok[5];
int check(int i) {
  if (ch[i] >= 'A' && ch[i] <= 'Z') return 1;
  if (ch[i] >= 'a' && ch[i] <= 'z') return 2;
  if (ch[i] >= '0' && ch[i] <= '9') return 3;
  return 0;
}
int main(int argc, char const *argv[]) {
  int T;
  cin >> T;
  while (T--) {
    cin >> ch;
    int len = 0;
    for (int i = 0; i < sizeof(ch); i++)
      if (check(i)) len++;
    for (int i = 0; i < len; i++) ok[check(i)]++;
    if (ok[1] == len || ok[2] == len || ok[3] == len) {
      if (ok[1] == len) {
        ch[0] = 'a';
        ch[1] = '1';
      }
      if (ok[2] == len) {
        ch[0] = 'A';
        ch[1] = '1';
      }
      if (ok[3] == len) {
        ch[0] = 'A';
        ch[1] = 'a';
      }
    } else {
      if (ok[1] == 0)
        for (int i = 0; i < len; i++)
          if (ok[check(i)] > 1) {
            ch[i] = 'A';
            break;
          }
      if (ok[2] == 0)
        for (int i = 0; i < len; i++)
          if (ok[check(i)] > 1) {
            ch[i] = 'a';
            break;
          }
      if (ok[3] == 0)
        for (int i = 0; i < len; i++)
          if (ok[check(i)] > 1) {
            ch[i] = '1';
            break;
          }
    }
    cout << ch << endl;
    memset(ch, 0, sizeof(ch));
    memset(ok, 0, sizeof(ok));
  }
  return 0;
}
