#include <bits/stdc++.h>
using namespace std;
int T, low, up, digit, p[5][105];
int main() {
  cin >> T;
  while (T--) {
    string s;
    cin >> s;
    int low = 0, up = 0, digit = 0, t1 = 1, t2 = 1, t3 = 1;
    for (int i = 0; i < s.size(); i++) {
      if (s[i] >= 'a' && s[i] <= 'z')
        low++, p[1][low] = i;
      else if (s[i] >= 'A' && s[i] <= 'Z')
        up++, p[2][up] = i;
      else
        digit++, p[3][digit] = i;
    }
    if (low == 0) {
      if (up > 1)
        s[p[2][t2]] = 'a', t2++;
      else if (digit > 1)
        s[p[3][t3]] = 'a', t3++;
    }
    if (up == 0) {
      if (low > 1)
        s[p[1][t1]] = 'A', t1++;
      else if (digit > 1)
        s[p[3][t3]] = 'A', t3++;
    }
    if (digit == 0) {
      if (low > 1)
        s[p[1][t1]] = '1', t1++;
      else if (up > 1)
        s[p[2][t2]] = '1', t2++;
    }
    cout << s << '\n';
  }
  return 0;
}
