#include <bits/stdc++.h>
using namespace std;
const int N = 101;
int n = 0;
string p;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> p;
    queue<int> u, d, l;
    int us = -1, ds = -1, ls = -1, uu = 0, dd = 0, ll = 0;
    for (int i = 0; i < p.length(); ++i) {
      char c = p[i];
      if (c >= 'A' && c <= 'Z') {
        us = i;
        ++uu;
      } else if (c >= 'a' && c <= 'z') {
        ls = i;
        ++ll;
      } else {
        ds = i;
        ++dd;
      }
    }
    if (us == -1) {
      if (ls == -1) {
        p[0] = 'A';
        p[1] = 'a';
      } else if (ds == -1) {
        p[0] = 'A';
        p[1] = '1';
      } else if (ll > 1) {
        p[ls] = 'A';
      } else {
        p[ds] = 'A';
      }
    } else if (ls == -1) {
      if (ds == -1) {
        p[0] = '1';
        p[1] = 'a';
      } else if (dd > 1) {
        p[ds] = 'a';
      } else {
        p[us] = 'a';
      }
    } else if (ds == -1) {
      if (ll > 1)
        p[ls] = '1';
      else
        p[us] = '1';
    }
    cout << p << endl;
  }
}
