// Justin Almazan
// 7/23/2025
// Solution to 2025 CP SI @ UCF Contest 5 Problem: Radix 67

#include <bits/stdc++.h>
using namespace std;

int tt;
string s;

string solve() {

    // This will be our answer
    string res = "";

    // Loop over batches of 6
    for (int i = 0; i < int(s.length()); i+=6) {

        // Get the substring and reverse it
        string t = s.substr(i, 6);
        reverse(t.begin(), t.end());

        // Compute the base 10 representation
        int base10 = 0;
        for (int j = 0; j < int(t.length()); j++) base10 += (1 << j) * (t[j] - '6');

        // Convert base 10 to the corresponding character and append to string
        if (base10 < 26) res += char('A' + base10);
        else if (base10 < 52) res += char('a' + base10 - 26);
        else if (base10 < 62) res += char('0' + base10 - 52);
        else if (base10 == 62) res += '+';
        else res += '/';
    }

    // Return answer
    return res;
}

int main() {

    // Num test cases
    cin >> tt;

    // Process test cases
    while (tt--) {

        // Get string
        cin >> s;

        // Answer
        cout << solve() << endl;
    }

    return 0;
}