#include <bits/stdc++.h>
using namespace std;
bool in_a(char c) { return c >= 'a' && c <= 'z'; }
bool in_A(char c) { return c >= 'A' && c <= 'Z'; }
bool out(char c) { return !in_a(c) && !in_A(c); }
string s, ch = "";
char next(int l, int r) {
  set<char> st;
  st.insert('a'), st.insert('A'), st.insert('6');
  for (int i = l; i <= r; i++) {
    st.erase(ch[i]);
  }
  return *st.begin();
}
int main() {
  int tc;
  cin >> tc;
  while (tc--) {
    ch = "";
    cin >> s;
    for (int i = 0; i < s.length(); i++) {
      if (in_a(s[i]))
        ch += 'a';
      else if (in_A(s[i]))
        ch += 'A';
      else
        ch += '6';
    }
    set<int> a, A, _;
    for (int i = 0; i < s.length(); i++) {
      if (s[i] >= 'a' && s[i] <= 'z')
        a.insert(i);
      else if (s[i] >= 'A' && s[i] <= 'Z')
        A.insert(i);
      else
        _.insert(i);
    }
    if (a.size() && A.size() && _.size()) {
      cout << s << '\n';
      continue;
    }
    if (a.size() && !A.size() && !_.size()) {
      s[0] = '0', s[1] = 'A';
      cout << s << '\n';
      continue;
    }
    if (!a.size() && A.size() && !_.size()) {
      s[0] = '0', s[1] = 'a';
      cout << s << '\n';
      continue;
    }
    if (!a.size() && !A.size() && _.size()) {
      s[0] = 'a', s[1] = 'A';
      cout << s << '\n';
      continue;
    }
    for (int i = 1; i < s.length() - 1; i++) {
      if (ch[i - 1] == ch[i + 1] && ch[i] != ch[i + 1]) {
        s[i + 1] = next(i - 1, i + 1);
        break;
      }
      if (ch[i - 1] == ch[i] && ch[i] != ch[i + 1]) {
        s[i] = next(i - 1, i + 1);
        break;
      }
      if (ch[i + 1] == ch[i] && ch[i] != ch[i - 1]) {
        s[i] = next(i - 1, i + 1);
        break;
      }
    }
    cout << s << '\n';
  }
  return 0;
}
