#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    long long int lower = 0, upper = 0, num = 0;
    for (int i = 0; i < s.length(); i++) {
      if (s[i] >= 97)
        lower++;
      else if (s[i] >= 65)
        upper++;
      else if (s[i] >= 48)
        num++;
    }
    if (num == 0 && upper == 0) {
      s[0] = 49;
      s[1] = 65;
    } else if (num == 0 && lower == 0) {
      s[0] = 49;
      s[1] = 97;
    } else if (upper == 0 && lower == 0) {
      s[0] = 65;
      s[1] = 97;
    } else {
      if (num == 0) {
        if (upper > 1) {
          for (int i = 0; i < s.length(); i++) {
            if (s[i] >= 65 && s[i] < 97) {
              s[i] = 49;
              break;
            }
          }
        } else {
          for (int i = 0; i < s.length(); i++) {
            if (s[i] >= 97) {
              s[i] = 49;
              break;
            }
          }
        }
      }
      if (lower == 0) {
        if (num > 1) {
          for (int i = 0; i < s.length(); i++) {
            if (s[i] >= 48 && s[i] < 65) {
              s[i] = 97;
              break;
            }
          }
        } else {
          for (int i = 0; i < s.length(); i++) {
            if (s[i] >= 65) {
              s[i] = 97;
              break;
            }
          }
        }
      }
      if (upper == 0) {
        if (num > 1) {
          for (int i = 0; i < s.length(); i++) {
            if (s[i] >= 48 && s[i] < 65) {
              s[i] = 65;
              break;
            }
          }
        } else {
          for (int i = 0; i < s.length(); i++) {
            if (s[i] >= 97) {
              s[i] = 65;
              break;
            }
          }
        }
      }
    }
    for (int i = 0; i < s.length(); i++) {
      cout << char(s[i]);
    }
    cout << "\n" << flush;
  }
}
