#include <bits/stdc++.h>
using namespace std;
const long long MOD = (long long)1e9 + 7;
string substrs(string s, int i, int j) {
  string a;
  for (int h = i; h < j + 1; h++) {
    a.push_back(s[h]);
  }
  return a;
}
int main() {
  int T;
  cin >> T;
  for (int zz = 0; zz < T; zz++) {
    string s, s1;
    cin >> s;
    vector<int> cnt[3];
    for (int i = 0; i < s.length(); i++) {
      if (islower(s[i])) {
        s1.push_back('l');
        cnt[0].push_back(i);
      } else if (isupper(s[i])) {
        s1.push_back('u');
        cnt[1].push_back(i);
      } else if (isdigit(s[i])) {
        s1.push_back('d');
        cnt[2].push_back(i);
      }
    }
    int num = 0;
    for (int i = 0; i < 3; i++)
      if (!cnt[i].size()) num++;
    if (num == 0) {
      cout << s << '\n';
      continue;
    } else if (num == 1) {
      for (int i = 0; i < 3; i++) {
        if (!cnt[i].size()) {
          for (int j = 1; j < 3; j++) {
            if (cnt[(i + j) % 3].size() != 1) {
              if (i == 0)
                s[cnt[(i + j) % 3][0]] = 'a';
              else if (i == 1)
                s[cnt[(i + j) % 3][0]] = 'A';
              else if (i == 2)
                s[cnt[(i + j) % 3][0]] = '1';
              break;
            }
          }
          break;
        }
      }
    } else if (num == 2) {
      for (int i = 0; i < 3; i++) {
        if (cnt[i].size()) {
          if (i == 0) {
            s[0] = 'A';
            s[1] = '1';
          } else if (i == 1) {
            s[0] = 'a';
            s[1] = '1';
          } else if (i == 2) {
            s[0] = 'A';
            s[1] = 'a';
          }
          break;
        }
      }
    }
    cout << s << '\n';
  }
  return 0;
}
