#include <bits/stdc++.h>
using namespace std;
long long cnt(long long a, long long b, long long c) {
  long long ans = 0;
  if (a == -1) ++ans;
  if (b == -1) ++ans;
  if (c == -1) ++ans;
  return ans;
}
char func(long long a, long long b, long long c) {
  if (a == -1) return 'A';
  if (c == -1) return 'a';
  if (b == -1) return '0';
}
bool help(long long a, long long b, long long c, long long index) {
  if (c == -1) return a != index && b != index;
  if (b == -1) return a != index && c != index;
  if (a == -1) return b != index && c != index;
}
bool help2(long long a, long long b, long long c, long long index) {
  if (a != -1) {
    return min(b, c) != index && max(b, c) != (index + 1);
  } else if (b != -1) {
    return min(a, c) != index && max(a, c) != (index + 1);
  }
  return min(a, b) != index && max(a, b) != (index + 1);
}
int main() {
  std::ios_base::sync_with_stdio(false), std::cin.tie(NULL),
      std::cout.tie(NULL);
  long long T;
  cin >> T;
  for (long long i = 0; i < T; i++) {
    string str;
    cin >> str;
    long long n = str.size();
    long long a, b, c;
    a = b = c = -1;
    for (long long j = 0; j < n; j++) {
      if (isupper(str[j]))
        a = j;
      else if (isdigit(str[j]))
        b = j;
      else
        c = j;
    }
    if (cnt(a, b, c) == 1) {
      for (long long j = 0; j + 1 < n; j++)
        if (help(a, b, c, j)) {
          str[j] = func(a, b, c);
          break;
        }
    } else if (cnt(a, b, c) == 2) {
      for (long long j = 0; j + 1 < n; j++)
        if (help2(a, b, c, j)) {
          if (a != -1) {
            str[j] = '0';
            str[j + 1] = 'a';
          } else if (b != -1) {
            str[j] = 'A';
            str[j + 1] = 'a';
          } else {
            str[j] = '0';
            str[j + 1] = 'A';
          }
          break;
        }
    }
    cout << str << endl;
  }
  return 0;
}
