#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[1 << 20];
int get(char c) {
  if (c >= 'a' && c <= 'z')
    return 0;
  else if (c >= 'A' && c <= 'Z')
    return 1;
  return 2;
}
char doit(int i) {
  if (!i) return 'a';
  if (i == 1) return 'A';
  return '1';
}
bool ok(string s) {
  vector<int> a(3, 0);
  for (int i = 0, ThxDem = ((int)(s).size()); i < ThxDem; ++i) {
    char c = s[i];
    a[get(c)]++;
  }
  int r = 0;
  for (int i = 0, ThxDem = 3; i < ThxDem; ++i) r += (a[i] == 0);
  return r == 0;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int tc = 0, ThxDem = n; tc < ThxDem; ++tc) {
    string s;
    cin >> s;
    vector<int> a(3, 0);
    for (int i = 0, ThxDem = ((int)(s).size()); i < ThxDem; ++i) {
      char c = s[i];
      a[get(c)]++;
    }
    int r = 0;
    for (int i = 0, ThxDem = 3; i < ThxDem; ++i) r += (a[i] == 0);
    if (r == 1) {
      int k = -1;
      for (int j = 0, ThxDem = 3; j < ThxDem; ++j)
        if (a[j] == 0) k = j;
      for (int i = 0, ThxDem = ((int)(s).size()); i < ThxDem; ++i) {
        if (a[get(s[i])] > 1) {
          s[i] = doit(k);
          break;
        }
      }
    } else if (r == 2) {
      string t = "";
      for (int j = 0, ThxDem = 3; j < ThxDem; ++j)
        if (a[j] == 0) t += doit(j);
      s[0] = t[0];
      s[1] = t[1];
    }
    cout << s << "\n";
  }
}
