#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  ;
  int t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    long long n = s.length(), c1 = 0, ca = 0, cb = 0;
    for (int i = 0; i < n; i++) {
      if (isdigit(s[i])) {
        c1++;
      } else if ((s[i] - 'a') >= 0 && (s[i] - 'a') < 26) {
        ca++;
      } else if ((s[i] - 'A') >= 0 && (s[i] - 'A') < 26) {
        cb++;
      }
    }
    if (c1 == 0 && ca == 0) {
      s = "a1" + s.substr(2);
      cout << s << endl;
      continue;
    }
    if (c1 == 0 && cb == 0) {
      s = "A1" + s.substr(2);
      cout << s << endl;
      continue;
    }
    if (cb == 0 && ca == 0) {
      s = "aA" + s.substr(2);
      cout << s << endl;
      continue;
    }
    if (c1 == 0) {
      if (cb != 1) {
        for (int i = 0; i < n; i++) {
          if ((s[i] - 'A') >= 0 && (s[i] - 'A') < 26) {
            s[i] = '1';
            break;
          }
        }
      } else {
        for (int i = 0; i < n; i++) {
          if ((s[i] - 'a') >= 0 && (s[i] - 'a') < 26) {
            s[i] = '1';
            break;
          }
        }
      }
      cout << s << endl;
      continue;
    }
    if (cb == 0) {
      if (ca != 1) {
        for (int i = 0; i < n; i++) {
          if ((s[i] - 'a') >= 0 && (s[i] - 'a') < 26) {
            s[i] = 'A';
            break;
          }
        }
      } else {
        for (int i = 0; i < n; i++) {
          if (isdigit(s[i])) {
            s[i] = 'A';
            break;
          }
        }
      }
      cout << s << endl;
      continue;
    }
    if (ca == 0) {
      if (cb != 1) {
        for (int i = 0; i < n; i++) {
          if ((s[i] - 'A') >= 0 && (s[i] - 'A') < 26) {
            s[i] = 'a';
            break;
          }
        }
      } else {
        for (int i = 0; i < n; i++) {
          if (isdigit(s[i])) {
            s[i] = 'a';
            break;
          }
        }
      }
      cout << s << endl;
      continue;
    }
    cout << s << endl;
  }
}
