[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]:
s = vector of string
b1 = bool array of size 100000
cap = bool array of size 100000
define the main function
    w = string
    s1 = string
    n = integer
    read n
    for i = 0 to n exclusive
        read s1
        for j = 0 to s1.length() exclusive
            if (s1[j] >= A and s1[j] <= Z), s1[j] = s1[j] + a - A
        append s1 in s
    end of the block
    read w
    set all contents of cap to 0
    for i = 0 to w.length() exclusive
        if (w[i] >= A and w[i] <= Z)
            cap[i] = true
            w[i] = w[i] + a - A
        end of the block
    b = bool
    set all contents of b1 to 0
    for i = 0 to n exclusive
        for j = 0 to w.length() exclusive
            b = true
            if (j + s[i].length() > w.length())
                b = false
            else
                for k = j to j + s[i].length() exclusive
                    if (w[k] is not s[i][k - j]), b = false
            end of the block
            if (b)
                for k = j to j + s[i].length(), b1[k] = true
            end of the block
        end of the block
    end of the block
    l = character
    read l
    for i = 0 to w.length() exclusive
        if (b1[i])
            if (w[i] is not l)
                w[i] = l
            else if (w[i] is not a)
                w[i] = a
            else
                w[i] = b
        end of the block
    for i = 0 to w.length() exclusive
        if (cap[i]), w[i] = w[i] + A - a
    print w
    return to indicate successful execution
end of the block

[CODE]:

vector<string> s;
bool b1[100000];
bool cap[100000];
int main() {
    string w;
    string s1;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s1;
        for (int j = 0; j < s1.length(); j++)
            if (s1[j] >= 'A' && s1[j] <= 'Z') s1[j] += 'a' - 'A';
        s.push_back(s1);
    }
    cin >> w;
    memset(cap, 0, sizeof cap);
    for (int i = 0; i < w.length(); i++)
        if (w[i] >= 'A' && w[i] <= 'Z') {
            cap[i] = true;
            w[i] += 'a' - 'A';
        }
    bool b;
    memset(b1, 0, sizeof b1);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < w.length(); j++) {
            b = true;
            if (j + s[i].length() > w.length())
                b = false;
            else {
                for (int k = j; k < j + s[i].length(); k++)
                    if (w[k] != s[i][k - j]) b = false;
            }
            if (b) {
                for (int k = j; k < j + s[i].length(); k++) b1[k] = true;
            }
        }
    }
    char l;
    cin >> l;
    for (int i = 0; i < w.length(); i++)
        if (b1[i]) {
            if (w[i] != l)
                w[i] = l;
            else if (w[i] != 'a')
                w[i] = 'a';
            else
                w[i] = 'b';
        }
    for (int i = 0; i < w.length(); i++)
        if (cap[i]) w[i] += 'A' - 'a';
    cout << w << endl;
    return 0;
}