#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
char s[200];
int main() {
  int T;
  scanf("%d", &T);
  for (int t = 1; t <= T; t++) {
    bool num = 0, xx = 0, dx = 0;
    vector<int> res;
    scanf("%s", s + 1);
    int len = strlen(s + 1);
    for (int i = 1; i <= len; i++) {
      if (isdigit(s[i])) {
        if (!num)
          num = 1;
        else
          res.push_back(i);
      }
      if (isalpha(s[i])) {
        if (s[i] == tolower(s[i])) {
          if (!xx)
            xx = 1;
          else
            res.push_back(i);
        } else {
          if (!dx)
            dx = 1;
          else
            res.push_back(i);
        }
      }
    }
    int cnt = 1;
    if (num == 0) s[res.back()] = '1', res.pop_back();
    if (xx == 0) s[res.back()] = 'a', res.pop_back();
    if (dx == 0) s[res.back()] = 'A', res.pop_back();
    printf("%s\n", s + 1);
  }
}
