#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    string s;
    int a = 0, A = 0, z = 0, aa = -1, aaa = -1, AA = -1, AAA = -1, zz = -1,
        zzz = -1;
    cin >> s;
    int l = s.size();
    for (long long i = (long long)0; i < (long long)l; i++) {
      if (isupper(s.at(i))) {
        if (A == 1) {
          AAA = AA;
          AA = i;
        }
        A = 1;
      }
      if (islower(s.at(i))) {
        if (a == 1) {
          aaa = aa;
          aa = i;
        }
        a = 1;
      }
      if (s.at(i) >= '0' && s.at(i) <= '9') {
        if (z == 1) {
          zzz = zz;
          zz = i;
        }
        z = 1;
      }
    }
    if (A == 0 && a == 0) {
      s.at(0) = 'A';
      s.at(1) = 'a';
    } else if (z == 0 && a == 0) {
      s.at(0) = '9';
      s.at(1) = 'a';
    } else if (A == 0 && z == 0) {
      s.at(0) = 'A';
      s.at(1) = '0';
    } else if (A == 0) {
      if (zz != -1)
        s.at(zz) = 'A';
      else
        s.at(aa) = 'A';
    } else if (a == 0) {
      if (zz != -1)
        s.at(zz) = 'a';
      else
        s.at(AA) = 'a';
    } else if (z == 0) {
      if (aa != -1)
        s.at(aa) = '0';
      else
        s.at(AA) = '0';
    }
    for (long long i = (long long)0; i < (long long)l; i++) cout << s.at(i);
    cout << endl;
  }
}
