#include <bits/stdc++.h>
using namespace std;
int n;
string s;
int l = 0, u = 0, d = 0;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    int l = -1, u = -1, d = -1;
    cin >> s;
    for (int j = 0; j < s.length(); j++) {
      if (isdigit(s[j])) d = j;
      if (islower(s[j])) l = j;
      if (isupper(s[j])) u = j;
    }
    if (d == -1)
      for (int j = 0; j < s.length(); j++)
        if (j != l && j != u) {
          s[j] = '4';
          d = j;
          break;
        }
    if (l == -1)
      for (int j = 0; j < s.length(); j++)
        if (j != d && j != u) {
          s[j] = 'a';
          l = j;
          break;
        }
    if (u == -1)
      for (int j = 0; j < s.length(); j++)
        if (j != l && j != d) {
          s[j] = 'A';
          u = j;
          break;
        }
    cout << s << endl;
  }
  return 0;
}
