#include <bits/stdc++.h>
using namespace std;
char str[1100] = {0};
int len = 0;
void Solve() {
  vector<int> v[4];
  bool flag[4] = {0};
  scanf("%s", str + 1);
  len = strlen(str + 1);
  for (int i = 1; i <= len; i++) {
    if (str[i] >= 'A' && str[i] <= 'Z') flag[1] = 1, v[1].push_back(i);
    if (str[i] >= 'a' && str[i] <= 'z') flag[2] = 1, v[2].push_back(i);
    if (str[i] >= '0' && str[i] <= '9') flag[3] = 1, v[3].push_back(i);
  }
  int tot = flag[1] + flag[2] + flag[3];
  if (tot == 3)
    puts(str + 1);
  else if (tot == 2) {
    if (!flag[1]) {
      if (v[2].size() > 1)
        str[v[2][0]] = 'A';
      else
        str[v[3][0]] = 'A';
    }
    if (!flag[2]) {
      if (v[1].size() > 1)
        str[v[1][0]] = 'a';
      else
        str[v[3][0]] = 'a';
    }
    if (!flag[3]) {
      if (v[1].size() > 1)
        str[v[1][0]] = '0';
      else
        str[v[2][0]] = '0';
    }
    puts(str + 1);
  } else {
    int x1, x2;
    if (flag[1])
      str[1] = 'a', str[2] = '0';
    else if (flag[2])
      str[1] = 'A', str[2] = '0';
    else if (flag[3])
      str[1] = 'A', str[2] = 'a';
    puts(str + 1);
  }
}
int main() {
  int T;
  scanf("%d", &T);
  while (T--) Solve();
  return 0;
}
