#include <bits/stdc++.h>
struct compare {
  bool operator()(const int& l, const int& r) { return l > r; }
};
using namespace std;
priority_queue<int, vector<int>, compare> pq;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    int fa = 0, fA = 0, f1 = 0;
    int n = s.size();
    for (int i = 0; i < n; ++i) {
      if (s[i] >= 'a' && s[i] <= 'z')
        fa++;
      else if (s[i] >= 'A' && s[i] <= 'Z')
        fA++;
      else
        f1++;
    }
    if (fa && fA && f1) {
      cout << s << "\n";
    } else if (!fa && fA && f1) {
      for (int i = 0; i < n; ++i) {
        if (s[i] >= 'A' && s[i] <= 'Z' && fA >= 2) {
          s[i] = 'a';
          break;
        } else if (s[i] >= '0' && s[i] <= '9' && f1 >= 2) {
          s[i] = 'a';
          break;
        }
      }
      cout << s << "\n";
    } else if (fa && !fA && f1) {
      for (int i = 0; i < n; ++i) {
        if (s[i] >= 'a' && s[i] <= 'z' && fa >= 2) {
          s[i] = 'A';
          break;
        } else if (s[i] >= '0' && s[i] <= '9' && f1 >= 2) {
          s[i] = 'A';
          break;
        }
      }
      cout << s << "\n";
    } else if (fa && fA && !f1) {
      for (int i = 0; i < n; ++i) {
        if (s[i] >= 'A' && s[i] <= 'Z' && fA >= 2) {
          s[i] = '1';
          break;
        } else if (s[i] >= 'a' && s[i] <= 'z' && fa >= 2) {
          s[i] = '1';
          break;
        }
      }
      cout << s << "\n";
    } else if (fa && !fA && !f1) {
      s[0] = 'A';
      s[1] = '1';
      cout << s << "\n";
    } else if (!fa && fA && !f1) {
      s[0] = 'a';
      s[1] = '1';
      cout << s << "\n";
    } else if (!fa && !fA && f1) {
      s[0] = 'a';
      s[1] = 'A';
      cout << s << "\n";
    } else {
      cout << s << "\n";
    }
  }
}
