[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
declare constant integer INF = 1e9 + 10
declare map from integer to character rep
declare integer arrays cnt size 3, tp size 110
declare con with character ch as argument, returning integer
    if 'a' is less than or equal to ch and ch is less than or equal to 'z', return 0 from function
    if 'A' is less than or equal to ch and ch is less than or equal to 'Z', return 1 from function
    return 2
end of the block
define the main function
    let rep[1] be 'a'
    let rep[2] be 'A'
    let rep[4] be '1'
    declare integer Tst
    read Tst
    while decrement Tst is true
        declare string s
        read s
        declare integer msk = 0
        let cnt[0] be cnt[1] be cnt[2] be 0
        for i = 0 to integer casted size of s exclusive
            let tp[i] be result of run con(s[i])
            let msk be msk bitwise or ( 1 bitshift left tp[i] )
            increment cnt[tp[i]]
        end of the block
        if msk is 7
            print s, '\n'
        else if result of run __builtin_popcount(msk) is 2
            for i = 0 to integer casted size of s exclusive
                if cnt[tp[i]] is greater than 1
                    let s[i] be rep[7 bitwise xor msk]
                    end loop
                end of the block
            print s, '\n'
        else
            declare integer M = 7 bitwise xor msk
            declare integer t = result of run __builtin_ctz(M)
            let M be M bitwise xor ( 1 bitshift left t )
            let s[0] be rep[1 bitshift left t]
            let s[1] be rep[1 bitshift left result of run __builtin_ctz(M)]
            print s, '\n'
        end of the block
    end of the block
    return to indicate successful execution
end of the block

[CODE]:

const int INF = 1e9 + 10;
map<int, char> rep;
int cnt[3], tp[110];
int con(char ch) {
    if ('a' <= ch && ch <= 'z') return 0;
    if ('A' <= ch && ch <= 'Z') return 1;
    return 2;
}
int main() {
    rep[1] = 'a';
    rep[2] = 'A';
    rep[4] = '1';
    int Tst;
    cin >> Tst;
    while (Tst--) {
        string s;
        cin >> s;
        int msk = 0;
        cnt[0] = cnt[1] = cnt[2] = 0;
        for (int i = 0; i < ((int)(s).size()); i++) {
            tp[i] = con(s[i]);
            msk |= 1 << tp[i];
            ++cnt[tp[i]];
        }
        if (msk == 7)
            cout << s << '\n';
        else if (__builtin_popcount(msk) == 2) {
            for (int i = 0; i < ((int)(s).size()); i++)
                if (cnt[tp[i]] > 1) {
                    s[i] = rep[7 ^ msk];
                    break;
                }
            cout << s << '\n';
        } else {
            int M = 7 ^ msk;
            int t = __builtin_ctz(M);
            M ^= 1 << t;
            s[0] = rep[1 << t];
            s[1] = rep[1 << (__builtin_ctz(M))];
            cout << s << '\n';
        }
    }
    return 0;
}