#include <bits/stdc++.h>
using namespace std;
void faster() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
string s, t;
long long q, n, d, pos, i, sum, a, b, c;
bool ok;
void dii() {
  cin >> s;
  a = -1;
  b = -1;
  c = -1;
  for (int i = 0; i < s.size(); i++) {
    if (islower(s[i]) && a == -1) {
      a = i;
    } else if (isupper(s[i]) && b == -1) {
      b = i;
    } else if (isdigit(s[i]) && c == -1) {
      c = i;
    }
  }
  if (a == -1) {
    for (int i = 0; i < s.size(); i++) {
      if (i != b && i != c) {
        a = i;
        s[i] = 'a';
        break;
      }
    }
  }
  if (b == -1) {
    for (int i = 0; i < s.size(); i++) {
      if (i != a && i != c) {
        b = i;
        s[i] = 'A';
        break;
      }
    }
  }
  if (c == -1) {
    for (int i = 0; i < s.size(); i++) {
      if (i != b && i != a) {
        c = i;
        s[i] = '1';
        break;
      }
    }
  }
  cout << s;
  cout << endl;
}
int main() {
  faster();
  q = 1;
  cin >> q;
  while (q--) {
    dii();
  }
  return 0;
}
