#include <bits/stdc++.h>
using namespace std;
int t, type[3];
string s;
int get_type(int j) {
  if (s[j] >= 'A' && s[j] <= 'Z') return 0;
  if (s[j] >= 'a' && s[j] <= 'z') return 1;
  return 2;
}
char get_char(int t) {
  if (t == 0) return 'A';
  if (t == 1) return 'a';
  return '1';
}
int main() {
  cin >> t;
  for (int i = 0; i < t; i++) {
    cin >> s;
    type[0] = type[1] = type[2] = 0;
    for (int j = 0; j < s.length(); j++) type[get_type(j)]++;
    int sum = (type[0] != 0) + (type[1] != 0) + (type[2] != 0);
    if (sum == 3)
      cout << s << endl;
    else if (sum == 2) {
      int tt;
      for (int j = 0; j < 3; j++) {
        if (type[j] == 0) tt = j;
      }
      for (int j = 0; j < s.length(); j++) {
        if (type[get_type(j)] > 1) {
          s[j] = get_char(tt);
          break;
        }
      }
      cout << s << endl;
    } else if (sum == 1) {
      int t1 = -1, t2 = -1;
      for (int j = 0; j < 3; j++)
        if (type[j] == 0 && t1 == -1)
          t1 = j;
        else if (type[j] == 0 && t1 != -1)
          t2 = j;
      s[0] = get_char(t1);
      s[1] = get_char(t2);
      cout << s << endl;
    }
  }
  return 0;
}
