#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, n, i, f1, f2, f3, c1, c2, c3, p1, p2, p3, flag;
  char ch[110];
  scanf("%d", &t);
  while (t--) {
    scanf("%s", ch);
    n = strlen(ch);
    f1 = 0, f2 = 0, f3 = 0;
    c1 = 0, c2 = 0, c3 = 0;
    for (i = 0; i < n; i++) {
      if ('a' <= ch[i] && ch[i] <= 'z')
        f1 = 1, c1++, p1 = i;
      else if ('A' <= ch[i] && ch[i] <= 'Z')
        f2 = 1, c2++, p2 = i;
      else
        f3 = 1, c3++, p3 = i;
    }
    if (f1 + f2 + f3 == 3)
      printf("%s\n", ch);
    else if (f1 + f2 + f3 == 2) {
      if (f1 == 0) {
        if (c2 > c3)
          ch[p2] = 'a';
        else
          ch[p3] = 'a';
      } else if (f2 == 0) {
        if (c1 > c3)
          ch[p1] = 'A';
        else
          ch[p3] = 'A';
      } else {
        if (c1 > c2)
          ch[p1] = '1';
        else
          ch[p2] = '1';
      }
      printf("%s\n", ch);
    } else {
      if (f1) {
        printf("A1");
        for (i = 2; i < n; i++) printf("%c", ch[i]);
        printf("\n");
      } else if (f2) {
        printf("a1");
        for (i = 2; i < n; i++) printf("%c", ch[i]);
        printf("\n");
      } else {
        printf("aA");
        for (i = 2; i < n; i++) printf("%c", ch[i]);
        printf("\n");
      }
    }
  }
  return 0;
}
