[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]:
create long long vector prime of size 10000005 and value 0
declare mM taking in long long ints a, b, and mod and returning long long
    create long long res = 0
    set a to a % mod
    while b is truthy
        if b & 1 is truthy, set res to (res + a) % mod
        set a to (2 * a) % mod
        move bits of b 1 place to the right
    end of the block
    return res
end of the block
declare fpow taking long long ints first, second, and p and returning long long integer
    set first to first % p
    make long long res = 1
    while second is truthy
        if second & 1 is truthy, set res to (res * first) % p
        set res to res % p
        if res is less than 0, set res to (res + p) % p
        set second to second >> 1
        set first to (first * first) % p
        if first is less than 0, set first to (first + p) % p
        set first to first % p
    end of the block
    return res
end of the block
declare inv taking in long long int n and returning long long
    return the result of fpow(n, 1000000007 - 2, 1000000007)
end of the block
declare modmul taking in long long ints first and second and returning long long
    return ((first % 1000000007) * (second % 1000000007)) % 1000000007
end of the block
declare modadd taking in long long ints first and second and returning long long integer
    create long long temp = first % 1000000007 + second % 1000000007
    set temp to temp % 1000000007
    if temp is less than 0, set temp to (temp + 1000000007) % 1000000007
    return temp
end of the block
declare sieve
    set prime[1] to 1
    for i = 2 to 10000005 exclusive
        if prime[i] is falsy
            for j = i to 10000005 exclusive
                if !prime[j] is truthy, set prime[j] to i
end of the block
define the main function
    create long long integer t
    set t to 1
    while t-- is truthy
        create long long integer n
        read n
        make string vector s of size n
        for i = 0 to n exclusive, read s[i]
        make string w
        create char tc
        read w and tc
        make long long vector check of size w.size() and value 0
        for i = 0 to n exclusive
            for j = 0 to w.size() exclusive
                create string s1 = w.substr(j, s[i].size())
                create bool ok = true
                if size of s1 is less than size of s[i]
                    set ok to false
                else do
                    make string temp = s[i]
                    make all contents of temp lowercase
                    make all content of s1 lowercase
                    if s1 is not equal to temp, set ok to false
                end of the block
                if ok is truthy
                    for k = j while k < j + s[i].size(), set check[k] to 1
            end of the block
        for i = 0 to w.size() exclusive
            if check[i] is truthy
                create char temp = w[i]
                if temp is greater than or equal to 'A' and temp is less than or equal to 'Z'
                    set temp to temp - 'A'
                else do
                    subtract 'a' from temp
                add 'a' to temp
                if temp is equal to tc and tc is equal to 'a'
                    if w[i] is greater than or equal to 'a' and w[i] is less than or equal to 'z'
                        set w[i] to 'b'
                    else do
                        set w[i] to 'B'
                else if temp is equal to tc and tc is not equal to 'a'
                    if w[i] is greater than or equal to 'a' and w[i] is less than or equal to 'z'
                        set w[i] to 'a'
                    otherwise
                        set w[i] to 'A'
                else
                    if w[i] is greater than or equal to 'a' and w[i] is less than or equal to 'z'
                        set w[i] to tc
                    else do
                        set w[i] to tc - 'a' + 'A'
                end of the block
            end of the block
        print w
    end of the block
end of the block

[CODE]:

vector<long long> prime(10000005, 0);
long long mM(long long a, long long b, long long mod) {
    long long res = 0;
    a %= mod;
    while (b) {
        if (b & 1) res = (res + a) % mod;
        a = (2 * a) % mod;
        b >>= 1;
    }
    return res;
}
long long fpow(long long first, long long second, long long p) {
    first = first % p;
    long long res = 1;
    while (second) {
        if (second & 1) res = (res * first) % p;
        res %= p;
        if (res < 0) res = (res + p) % p;
        second = second >> 1;
        first = (first * first) % p;
        if (first < 0) first = (first + p) % p;
        first %= p;
    }
    return res;
}
long long inv(long long n) {
    return fpow(n, 1000000007 - 2, 1000000007);
}
long long modmul(long long first, long long second) {
    return ((first % 1000000007) * (second % 1000000007)) % 1000000007;
}
long long modadd(long long first, long long second) {
    long long temp = first % 1000000007 + second % 1000000007;
    temp %= 1000000007;
    if (temp < 0) temp = (temp + 1000000007) % 1000000007;
    return temp;
}
void sieve() {
    prime[1] = 1;
    for (long long i = 2; i < 10000005; i++)
        if (!prime[i])
            for (long long j = i; j < 10000005; j += i)
                if (!prime[j]) prime[j] = i;
}
int main() {
    long long t;
    t = 1;
    while (t--) {
        long long n;
        cin >> n;
        vector<string> s(n);
        for (int i = 0; i < n; i++) cin >> s[i];
        string w;
        char tc;
        cin >> w >> tc;
        vector<long long> check(w.size(), 0);
        for (int i = 0; i < n; i++)
            for (int j = 0; j < w.size(); j++) {
                string s1 = w.substr(j, s[i].size());
                bool ok = true;
                if (s1.size() < s[i].size())
                    ok = false;
                else {
                    string temp = s[i];
                    transform(temp.begin(), temp.end(), temp.begin(), ::tolower);
                    transform(s1.begin(), s1.end(), s1.begin(), ::tolower);
                    if (s1 != temp) ok = false;
                }
                if (ok)
                    for (int k = j; k < j + s[i].size(); k++) check[k] = 1;
            }
        for (int i = 0; i < w.size(); i++)
            if (check[i]) {
                char temp = w[i];
                if (temp >= 'A' && temp <= 'Z')
                    temp -= 'A';
                else
                    temp -= 'a';
                temp += 'a';
                if (temp == tc && tc == 'a') {
                    if (w[i] >= 'a' && w[i] <= 'z')
                        w[i] = 'b';
                    else
                        w[i] = 'B';
                } else if (temp == tc && tc != 'a') {
                    if (w[i] >= 'a' && w[i] <= 'z')
                        w[i] = 'a';
                    else
                        w[i] = 'A';
                } else {
                    if (w[i] >= 'a' && w[i] <= 'z')
                        w[i] = tc;
                    else
                        w[i] = tc - 'a' + 'A';
                }
            }
        cout << w << "\n";
    }
}