#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, n, u, l, d;
  string s;
  cin >> t;
  while (t--) {
    cin >> s;
    n = s.size(), u = 0, l = 0, d = 0;
    for (int i = 0; i < n; i++) {
      if (s[i] >= 'A' && s[i] <= 'Z')
        u++;
      else if (s[i] >= 'a' && s[i] <= 'z')
        l++;
      else
        d++;
    }
    if (u && l && d)
      ;
    else if (u && l) {
      if (u > 1) {
        for (int i = 0; i < n; i++)
          if (s[i] >= 'A' && s[i] <= 'Z') s[i] = '5', i = n;
      } else {
        for (int i = 0; i < n; i++)
          if (s[i] >= 'a' && s[i] <= 'z') s[i] = '5', i = n;
      }
    } else if (u && d) {
      if (u > 1) {
        for (int i = 0; i < n; i++)
          if (s[i] >= 'A' && s[i] <= 'Z') s[i] = 'a', i = n;
      } else {
        for (int i = 0; i < n; i++)
          if (s[i] >= '0' && s[i] <= '9') s[i] = 'a', i = n;
      }
    } else if (l && d) {
      if (l > 1) {
        for (int i = 0; i < n; i++)
          if (s[i] >= 'a' && s[i] <= 'z') s[i] = 'A', i = n;
      } else {
        for (int i = 0; i < n; i++)
          if (s[i] >= '0' && s[i] <= '9') s[i] = 'A', i = n;
      }
    } else if (l)
      s[0] = 'A', s[1] = '5';
    else if (u)
      s[0] = 'a', s[1] = '5';
    else if (d)
      s[0] = 'A', s[1] = 'a';
    cout << s << endl;
  }
  return 0;
}
