#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  string a[n];
  for (long long i = 0; i < n; i++) cin >> a[i];
  for (long long i = 0; i < n; i++) {
    string x = a[i];
    long long len = x.length();
    long long cu = 0, cl = 0, cd = 0;
    for (long long t = 0; t < len; t++) {
      if (x[t] - 'a' >= 0 && x[t] - 'a' <= 25) cl++;
      if (x[t] - 'A' >= 0 && x[t] - 'A' <= 25) cu++;
      if (x[t] - '0' >= 0 && x[t] - '0' <= 9) cd++;
    }
    if (cl == 0 && cu == 0) {
      x[0] = 'a';
      x[1] = 'A';
    } else if (cd == 0 && cu == 0) {
      x[0] = '1';
      x[1] = 'A';
    } else if (cl == 0 && cd == 0) {
      x[0] = 'a';
      x[1] = '1';
    } else if (cd == 0) {
      long long j = 0;
      long long ccu = 0, ccl = 0, ccd = 0;
      while (j < len) {
        if (x[j] - 'a' >= 0 && x[j] - 'a' <= 25)
          ccl++;
        else if (x[j] - 'A' >= 0 && x[j] - 'A' <= 25)
          ccu++;
        else if (x[j] - '0' >= 0 && x[j] - '0' <= 9)
          ccd++;
        if (ccl > 1 || ccd > 1 || ccu > 1)
          break;
        else
          j++;
      }
      x[j] = '1';
    } else if (cl == 0) {
      long long j = 0;
      long long ccu = 0, ccl = 0, ccd = 0;
      while (j < len) {
        if (x[j] - 'a' >= 0 && x[j] - 'a' <= 25)
          ccl++;
        else if (x[j] - 'A' >= 0 && x[j] - 'A' <= 25)
          ccu++;
        else if (x[j] - '0' >= 0 && x[j] - '0' <= 9)
          ccd++;
        if (ccl > 1 || ccd > 1 || ccu > 1)
          break;
        else
          j++;
      }
      x[j] = 'a';
    } else if (cu == 0) {
      long long j = 0;
      long long ccu = 0, ccl = 0, ccd = 0;
      while (j < len) {
        if (x[j] - 'a' >= 0 && x[j] - 'a' <= 25)
          ccl++;
        else if (x[j] - 'A' >= 0 && x[j] - 'A' <= 25)
          ccu++;
        else if (x[j] - '0' >= 0 && x[j] - '0' <= 9)
          ccd++;
        if (ccl > 1 || ccd > 1 || ccu > 1)
          break;
        else
          j++;
      }
      x[j] = 'A';
    }
    cout << x << endl;
  }
  return 0;
}
