[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]:
define the main function
    n = int
    read n
    let num = 0, chr = 0, CHR = 0 be ints
    str = string
    for i = 0 to n exclusvie
        read str
        for j = 0 to length of str exclusive
            if str at j is between 'a' and 'z' both inclusive
                increment chr
            else if str at j is between 'A' and 'Z' both inclusive
                increment CHR
            else
                increment num
            end of the block
        end of the block
        if chr = and CHR = 0
            insert "aA" int str at 0
            call erase on str with args 2, 2
        else if chr and num are both = 0
            insert "a1" into str[0]
            call erase on str with args 2, 2
        else if CHR and num are both = 0
            insert "A1" into str[0]
            erase 2, 2 form str
        else if chr = 0
            for j = 0 to length of str
                if str at j >= 'A' bit and str[j] <= 'Z' bit and CHR > 1
                    insert "a" in str at j
                    erase j+1, 1 form str
                    exit loop
                else if str[j] is >= '0' bit and str[j] <= '9' bit and num > 1
                    insert "a", j into str
                    erase j+1, 1 from str
                    exit loop
                end of the block
            end of the block
        else if CHR = 0
            for j = 0 to length of str
                if str at j >= 'a' bit and str[j] <= 'z' bit and chr > 1
                    call insert on str with args j, "A"
                    erase j+1, 1 from str
                    exit loop
                else if str at j >= 'a' bit and str[j] <= 'z' bit and num > 1
                    call insert on str with args j, "A"
                    erase j+1, 1 from str
                    exit loop
                end of the block
            end of the block
        else if num = 0
            for j = 0 to length of str
                if str at j >= 'a' bit and str[j] <= 'z' bit and chr > 1
                    insert j, "1" into str
                    erase j+1, 1 from str
                    exit loop
                else if str at j >= 'A' bit and str[j] <= 'Z' bit and CHR > 1
                    insert j, "1" into str
                    erase j+1, 1 from str
                    exit loop
                end of the block
            end of the block
        end of the block
        print str
        set num to 0
        set chr to 0
        set CHR to 0
    end of the block
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    int n;
    cin >> n;
    int num = 0, chr = 0, CHR = 0;
    string str;
    for (int i = 0; i < n; i++) {
        cin >> str;
        for (int j = 0; j < str.length(); j++) {
            if (str[j] >= 'a' & str[j] <= 'z') {
                chr++;
            } else if (str[j] >= 'A' & str[j] <= 'Z') {
                CHR++;
            } else {
                num++;
            }
        }
        if (chr == 0 && CHR == 0) {
            str.insert(0, "aA");
            str.erase(2, 2);
        } else if (chr == 0 && num == 0) {
            str.insert(0, "a1");
            str.erase(2, 2);
        } else if (CHR == 0 && num == 0) {
            str.insert(0, "A1");
            str.erase(2, 2);
        } else if (chr == 0) {
            for (int j = 0; j < str.length(); j++) {
                if (str[j] >= 'A' & str[j] <= 'Z' & CHR > 1) {
                    str.insert(j, "a");
                    str.erase(j + 1, 1);
                    break;
                } else if (str[j] >= '0' & str[j] <= '9' & num > 1) {
                    str.insert(j, "a");
                    str.erase(j + 1, 1);
                    break;
                }
            }
        } else if (CHR == 0) {
            for (int j = 0; j < str.length(); j++) {
                if (str[j] >= 'a' & str[j] <= 'z' & chr > 1) {
                    str.insert(j, "A");
                    str.erase(j + 1, 1);
                    break;
                } else if (str[j] >= '0' & str[j] <= '9' & num > 1) {
                    str.insert(j, "A");
                    str.erase(j + 1, 1);
                    break;
                }
            }
        } else if (num == 0) {
            for (int j = 0; j < str.length(); j++) {
                if (str[j] >= 'a' & str[j] <= 'z' & chr > 1) {
                    str.insert(j, "1");
                    str.erase(j + 1, 1);
                    break;
                } else if (str[j] >= 'A' & str[j] <= 'Z' & CHR > 1) {
                    str.insert(j, "1");
                    str.erase(j + 1, 1);
                    break;
                }
            }
        }
        cout << str << endl;
        num = 0;
        chr = 0;
        CHR = 0;
    }
    return 0;
}