#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j, p, q, r, ma, in, x, y, z;
  bool found = false;
  string a;
  cin >> n;
  for (j = 1; j <= n; j++) {
    p = q = r = 0;
    found = false;
    cin >> a;
    for (i = 0; i < a.size(); i++) {
      if (a[i] >= 'a' && a[i] <= 'z') {
        p++;
        x = i;
      } else if (a[i] >= 'A' && a[i] <= 'Z') {
        q++;
        y = i;
      } else if (a[i] >= '0' && a[i] <= '9') {
        r++;
        z = i;
      }
      if (!found) {
        if (a[i] >= 'a' && a[i] <= 'z' && a[i + 1] >= 'a' && a[i + 1] <= 'z') {
          in = i;
          found = true;
        } else if (a[i] >= 'A' && a[i] <= 'Z' && a[i + 1] >= 'A' &&
                   a[i + 1] <= 'Z') {
          in = i;
          found = true;
        } else if (a[i] >= '0' && a[i] <= '9' && a[i + 1] >= '0' &&
                   a[i + 1] <= '9') {
          in = i;
          found = true;
        }
      }
    }
    if (p != 0 && q != 0 && r != 0)
      cout << a << endl;
    else if ((p == 0 && q == 0) || (q == 0 && r == 0) || (p == 0 && r == 0)) {
      if (p == 0 && q == 0) {
        a[in] = 'a';
        a[in + 1] = 'B';
      } else if (q == 0 && r == 0) {
        a[in] = '0';
        a[in + 1] = 'B';
      } else if (p == 0 && r == 0) {
        a[in] = 'a';
        a[in + 1] = '0';
      }
      cout << a << endl;
    } else {
      if (p == 0) {
        if (q > 1) {
          a[y] = 'a';
        } else if (r > 1) {
          a[z] = 'a';
        }
      } else if (q == 0) {
        if (p > 1) {
          a[x] = 'A';
        } else if (r > 1) {
          a[z] = 'A';
        }
      } else if (r == 0) {
        if (q > 1) {
          a[y] = '0';
        } else if (p > 1) {
          a[x] = '0';
        }
      }
      cout << a << endl;
    }
  }
  return 0;
}
