[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]:
N=2002
mp=map from string to long long
likes=map from pair of long long, long long to long long
define the main function
    n=7, sz=0, m, a, b, c = long long
    read m
    while decremented value of m not equal 0
        l,r=string
        read l,r,r
        if mp[l] is 0 increment sz, mp[l] = sz
        if mp[r] is 0 increment sz, mp[r] = sz
        likes[make_pair(mp[l], mp[r])] = l
    end of the block
    read a,b,c
    pt=2187, minimal=a+b+c, ml=long long
    for i=0 to pt excluisve
        t=array of 3 vector of long long
        k=i, m1,m2,m3=long long, lks=0
        for i=1 to n inclusive
            add i at end of t[k modulo 3]
            divide k by 3
        end of the block
        it size of t[0] and size of t[1] and size of t[2]
            m1=a/size of t[0]
            m2=b/size of t[1]
            m3=c/size of t[2]
            m1=max(m1, max(m2,m3))-min(m1, min(m2,m3))
            for i=0 to 3 exclusive
                for j=0 to size of t[i] exclusive
                    for k=0 to size of t[i] exclusive add likes[make_pair(t[i][j], t[i][k])] to lks
            if minimal>m1
                minimal=m1
                ml=lks
            else if minimal is m1
                ml=max(ml,lks)
        end of the block
    end of the block
    print minimal, space, ml
end of the block

[CODE]:

const long long N = 2002;
map<string, long long> mp;
map<pair<long long, long long>, long long> likes;
int main() {
    long long n = 7, m, sz = 0, a, b, c;
    cin >> m;
    while (m--) {
        string l, r;
        cin >> l >> r >> r;
        if (mp[l] == 0) mp[l] = ++sz;
        if (mp[r] == 0) mp[r] = ++sz;
        likes[make_pair(mp[l], mp[r])] = 1;
    }
    cin >> a >> b >> c;
    long long pt = 2187, minimal = a + b + c, ml;
    for (long long i = 0; i < pt; i++) {
        vector<long long> t[3];
        long long k = i, m1, m2, m3, lks = 0;
        for (long long i = 1; i <= n; i++) {
            t[k % 3].push_back(i);
            k /= 3;
        }
        if (t[0].size() && t[1].size() && t[2].size()) {
            m1 = a / t[0].size();
            m2 = b / t[1].size();
            m3 = c / t[2].size();
            m1 = max(m1, max(m2, m3)) - min(m1, min(m2, m3));
            for (long long i = 0; i < 3; i++)
                for (long long j = 0; j < t[i].size(); j++)
                    for (long long k = 0; k < t[i].size(); k++) lks += likes[make_pair(t[i][j], t[i][k])];
            if (minimal > m1) {
                minimal = m1;
                ml = lks;
            } else if (minimal == m1)
                ml = max(ml, lks);
        }
    }
    cout << minimal << " " << ml << endl;
}

3
Troll likes Dracul
Dracul likes Anka
Snowy likes Hexadecimal
210 200 180

2
Anka likes Chapay
Chapay likes Anka
10000 50 50

11
Snowy likes Dracul
Anka likes Dracul
Chapay likes Snowy
Hexadecimal likes Troll
Anka likes Cleo
Chapay likes Dracul
Anka likes Chapay
Snowy likes Troll
Anka likes Hexadecimal
Cleo likes Chapay
Troll likes Cleo
100 100 100

14
Chapay likes Cleo
Cleo likes Anka
Dracul likes Snowy
Snowy likes Cleo
Chapay likes Anka
Snowy likes Anka
Chapay likes Troll
Troll likes Anka
Anka likes Snowy
Chapay likes Dracul
Dracul likes Anka
Hexadecimal likes Chapay
Snowy likes Dracul
Cleo likes Dracul
15 15 15

4
Anka likes Cleo
Snowy likes Cleo
Anka likes Hexadecimal
Cleo likes Snowy
1 1 1

8
Snowy likes Anka
Hexadecimal likes Snowy
Troll likes Dracul
Hexadecimal likes Troll
Snowy likes Troll
Anka likes Snowy
Snowy likes Chapay
Anka likes Chapay
70 70 70

3
Chapay likes Hexadecimal
Anka likes Cleo
Troll likes Snowy
15 15000 90

13
Cleo likes Hexadecimal
Cleo likes Snowy
Hexadecimal likes Anka
Anka likes Snowy
Troll likes Snowy
Chapay likes Hexadecimal
Hexadecimal likes Snowy
Snowy likes Chapay
Troll likes Cleo
Anka likes Hexadecimal
Hexadecimal likes Cleo
Chapay likes Dracul
Snowy likes Dracul
1000000000 2000000000 1000000000

12
Cleo likes Hexadecimal
Chapay likes Anka
Hexadecimal likes Cleo
Anka likes Snowy
Anka likes Cleo
Dracul likes Snowy
Anka likes Troll
Snowy likes Anka
Cleo likes Anka
Hexadecimal likes Troll
Hexadecimal likes Chapay
Snowy likes Troll
1000000000 1 2000000000

2
Snowy likes Hexadecimal
Troll likes Dracul
2000000000 2000000000 2000000000

12
Snowy likes Chapay
Cleo likes Dracul
Hexadecimal likes Snowy
Hexadecimal likes Anka
Dracul likes Chapay
Cleo likes Troll
Dracul likes Snowy
Snowy likes Dracul
Troll likes Chapay
Dracul likes Anka
Chapay likes Hexadecimal
Troll likes Dracul
436364663 856574374 347564737

12
Anka likes Dracul
Dracul likes Troll
Cleo likes Troll
Snowy likes Hexadecimal
Hexadecimal likes Chapay
Cleo likes Dracul
Cleo likes Chapay
Hexadecimal likes Anka
Snowy likes Cleo
Hexadecimal likes Snowy
Cleo likes Snowy
Chapay likes Snowy
584329075 428752235 675234087

8
Anka likes Chapay
Dracul likes Snowy
Snowy likes Cleo
Cleo likes Anka
Cleo likes Troll
Hexadecimal likes Troll
Troll likes Cleo
Snowy likes Dracul
325432666 254352394 547360304

18
Snowy likes Troll
Chapay likes Hexadecimal
Cleo likes Snowy
Dracul likes Snowy
Snowy likes Chapay
Troll likes Cleo
Snowy likes Anka
Dracul likes Hexadecimal
Hexadecimal likes Anka
Anka likes Hexadecimal
Anka likes Chapay
Troll likes Anka
Anka likes Snowy
Anka likes Troll
Snowy likes Cleo
Hexadecimal likes Troll
Hexadecimal likes Dracul
Cleo likes Anka
20000 1000 20000

6
Chapay likes Troll
Troll likes Cleo
Cleo likes Troll
Chapay likes Snowy
Anka likes Snowy
Troll likes Dracul
987499608 272739716 133573597

6
Anka likes Troll
Troll likes Chapay
Troll likes Hexadecimal
Hexadecimal likes Cleo
Snowy likes Hexadecimal
Chapay likes Troll
740076959 230477703 987799796

17
Cleo likes Dracul
Troll likes Cleo
Anka likes Chapay
Anka likes Troll
Chapay likes Snowy
Troll likes Snowy
Chapay likes Dracul
Hexadecimal likes Snowy
Dracul likes Snowy
Troll likes Hexadecimal
Hexadecimal likes Anka
Cleo likes Snowy
Hexadecimal likes Dracul
Snowy likes Chapay
Snowy likes Hexadecimal
Snowy likes Dracul
Dracul likes Troll
112909524 619275170 403563648

18
Anka likes Troll
Dracul likes Chapay
Hexadecimal likes Dracul
Chapay likes Dracul
Anka likes Hexadecimal
Snowy likes Cleo
Dracul likes Anka
Snowy likes Anka
Snowy likes Hexadecimal
Dracul likes Troll
Dracul likes Snowy
Hexadecimal likes Anka
Chapay likes Hexadecimal
Snowy likes Dracul
Cleo likes Snowy
Chapay likes Cleo
Anka likes Dracul
Troll likes Anka
838821770 712931449 361810998

18
Hexadecimal likes Chapay
Troll likes Dracul
Troll likes Snowy
Cleo likes Dracul
Chapay likes Snowy
Dracul likes Chapay
Cleo likes Snowy
Dracul likes Hexadecimal
Troll likes Anka
Anka likes Troll
Hexadecimal likes Dracul
Chapay likes Hexadecimal
Cleo likes Chapay
Anka likes Hexadecimal
Snowy likes Dracul
Chapay likes Troll
Anka likes Snowy
Dracul likes Cleo
240256138 922743697 38909902

16
Chapay likes Snowy
Hexadecimal likes Anka
Chapay likes Troll
Dracul likes Cleo
Troll likes Hexadecimal
Hexadecimal likes Dracul
Chapay likes Cleo
Snowy likes Cleo
Snowy likes Anka
Troll likes Chapay
Snowy likes Hexadecimal
Troll likes Snowy
Cleo likes Hexadecimal
Anka likes Snowy
Snowy likes Chapay
Anka likes Dracul
843382501 58524777 503038818

5
Troll likes Chapay
Anka likes Snowy
Anka likes Dracul
Chapay likes Anka
Snowy likes Troll
709201888 431802832 597079932

18
Cleo likes Snowy
Snowy likes Hexadecimal
Cleo likes Hexadecimal
Troll likes Dracul
Hexadecimal likes Snowy
Dracul likes Troll
Chapay likes Anka
Chapay likes Cleo
Troll likes Chapay
Hexadecimal likes Chapay
Anka likes Snowy
Troll likes Snowy
Dracul likes Snowy
Dracul likes Chapay
Chapay likes Troll
Cleo likes Troll
Hexadecimal likes Cleo
Anka likes Chapay
864225278 509037060 402199775

12
Cleo likes Hexadecimal
Troll likes Cleo
Anka likes Cleo
Hexadecimal likes Troll
Anka likes Snowy
Hexadecimal likes Anka
Troll likes Hexadecimal
Troll likes Anka
Dracul likes Cleo
Cleo likes Troll
Dracul likes Troll
Chapay likes Anka
762445890 377707484 324080158

21
Chapay likes Dracul
Snowy likes Chapay
Snowy likes Troll
Cleo likes Chapay
Cleo likes Troll
Chapay likes Cleo
Snowy likes Anka
Dracul likes Anka
Troll likes Snowy
Snowy likes Cleo
Chapay likes Hexadecimal
Cleo likes Anka
Cleo likes Snowy
Hexadecimal likes Cleo
Hexadecimal likes Snowy
Hexadecimal likes Anka
Hexadecimal likes Troll
Anka likes Snowy
Dracul likes Troll
Chapay likes Anka
Snowy likes Hexadecimal
482557397 502108264 750230216

6
Troll likes Chapay
Hexadecimal likes Snowy
Cleo likes Dracul
Cleo likes Anka
Chapay likes Anka
Anka likes Chapay
758376921 432619768 578580897

5
Chapay likes Cleo
Anka likes Hexadecimal
Anka likes Chapay
Cleo likes Troll
Anka likes Cleo
299076810 225593528 36830738

13
Anka likes Cleo
Cleo likes Troll
Chapay likes Cleo
Snowy likes Troll
Chapay likes Anka
Chapay likes Snowy
Snowy likes Chapay
Anka likes Snowy
Snowy likes Dracul
Cleo likes Hexadecimal
Dracul likes Chapay
Anka likes Hexadecimal
Snowy likes Cleo
554338888 280967932 682619964

17
Hexadecimal likes Chapay
Chapay likes Snowy
Chapay likes Troll
Anka likes Hexadecimal
Cleo likes Troll
Snowy likes Cleo
Cleo likes Anka
Cleo likes Hexadecimal
Anka likes Snowy
Chapay likes Hexadecimal
Anka likes Cleo
Dracul likes Snowy
Chapay likes Anka
Troll likes Hexadecimal
Troll likes Anka
Anka likes Dracul
Hexadecimal likes Anka
828886798 548024213 166661324

2
Troll likes Cleo
Anka likes Cleo
14344913 559182022 405430772

22
Cleo likes Snowy
Cleo likes Troll
Chapay likes Dracul
Snowy likes Troll
Dracul likes Chapay
Dracul likes Snowy
Chapay likes Cleo
Snowy likes Chapay
Dracul likes Troll
Anka likes Hexadecimal
Snowy likes Anka
Hexadecimal likes Cleo
Hexadecimal likes Troll
Dracul likes Anka
Cleo likes Hexadecimal
Hexadecimal likes Dracul
Chapay likes Troll
Chapay likes Hexadecimal
Anka likes Snowy
Troll likes Hexadecimal
Snowy likes Hexadecimal
Anka likes Chapay
458053183 602148195 994999698

5
Troll likes Dracul
Anka likes Chapay
Cleo likes Anka
Chapay likes Cleo
Snowy likes Hexadecimal
222 400 400


[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 integer vector array vec with size 3
create map like from string to integer
create integers diff, ans, a, b, c, create 2d integer array mat with size 10 by 10
declare cal
    create integers sum, i, j, k, with sum = 0
    for i = 0 to 3 exclusive
        for j = 0 to integer casted size of vec[i]
            for k = 0 to integer casted size of vec[i] exclusive, increment sum by mat[vec[i][j]][vec[i][k]]
    end of the block
    return sum from function
end of the block
declare count with integer now as argument, returning void
    if now is 7
        if size of vec[0] and size of vec[1] and size of vec[2]
            create integer array x with x = { a / size of vec[0], b / size of vec[1], c / size of vec[2] }
            sort elements from x to x + 3
            if x[2] - x[0] is less than diff
                set diff to x[2] - x[0]
                set ans to result of run cal
            else if x[2] - x[0] is diff
                set ans to maximum of ans and result of run cal
        end of the block
        return from function
    end of the block
    for i = 0 to 3 exclusive
        add element now to end of vec[i]
        run count with now + 1 as argument
        remove last element from vec[i]
    end of the block
end of the block
define the main function
    set like[ "Anka" ] to 0
    set like[ "Chapay" ] to 1
    set like[ "Cleo" ] to 2
    set like[ "Troll" ] to 3
    set like[ "Dracul" ] to 4
    set like[ "Snowy" ] to 5
    set like[ "Hexadecimal" ] to 6
    create integers n, i
    create strings name1, str, name2
    while read n is true
        set diff to ( 1 bitshift left 31 ) - 1
        for i = 0 to 3 exclusive, remove all elements from vec[i]
        set bytes from mat to size of mat to value 0
        for i = 0 to n exclusive
            read name1 read str read name2
            increment mat[like[name1]][like[name2]]
        end of the block
        read a read b read c
        run count with 0 as argument
        print diff print " " print ans print newline
    end of the block
end of the block

[CODE]:

vector<int> vec[3];
map<string, int> like;
int diff, mat[10][10], ans, a, b, c;
int cal() {
    int sum = 0, i, j, k;
    for (i = 0; i < 3; i++) {
        for (j = 0; j < (int)vec[i].size(); j++)
            for (k = 0; k < (int)vec[i].size(); k++) sum += mat[vec[i][j]][vec[i][k]];
    }
    return sum;
}
void count(int now) {
    if (now == 7) {
        if (vec[0].size() && vec[1].size() && vec[2].size()) {
            int x[] = {a / vec[0].size(), b / vec[1].size(), c / vec[2].size()};
            sort(x, x + 3);
            if (x[2] - x[0] < diff) {
                diff = x[2] - x[0];
                ans = cal();
            } else if (x[2] - x[0] == diff)
                ans = max(ans, cal());
        }
        return;
    }
    for (int i = 0; i < 3; i++) {
        vec[i].push_back(now);
        count(now + 1);
        vec[i].pop_back();
    }
}
int main() {
    like["Anka"] = 0;
    like["Chapay"] = 1;
    like["Cleo"] = 2;
    like["Troll"] = 3;
    like["Dracul"] = 4;
    like["Snowy"] = 5;
    like["Hexadecimal"] = 6;
    int n, i;
    string name1, str, name2;
    while (cin >> n) {
        diff = (1 << 31) - 1;
        for (i = 0; i < 3; i++) vec[i].clear();
        memset(mat, 0, sizeof(mat));
        for (i = 0; i < n; i++) {
            cin >> name1 >> str >> name2;
            mat[like[name1]][like[name2]]++;
        }
        cin >> a >> b >> c;
        count(0);
        cout << diff << " " << ans << endl;
    }
}

3
Troll likes Dracul
Dracul likes Anka
Snowy likes Hexadecimal
210 200 180

2
Anka likes Chapay
Chapay likes Anka
10000 50 50

11
Snowy likes Dracul
Anka likes Dracul
Chapay likes Snowy
Hexadecimal likes Troll
Anka likes Cleo
Chapay likes Dracul
Anka likes Chapay
Snowy likes Troll
Anka likes Hexadecimal
Cleo likes Chapay
Troll likes Cleo
100 100 100

14
Chapay likes Cleo
Cleo likes Anka
Dracul likes Snowy
Snowy likes Cleo
Chapay likes Anka
Snowy likes Anka
Chapay likes Troll
Troll likes Anka
Anka likes Snowy
Chapay likes Dracul
Dracul likes Anka
Hexadecimal likes Chapay
Snowy likes Dracul
Cleo likes Dracul
15 15 15

4
Anka likes Cleo
Snowy likes Cleo
Anka likes Hexadecimal
Cleo likes Snowy
1 1 1

8
Snowy likes Anka
Hexadecimal likes Snowy
Troll likes Dracul
Hexadecimal likes Troll
Snowy likes Troll
Anka likes Snowy
Snowy likes Chapay
Anka likes Chapay
70 70 70

3
Chapay likes Hexadecimal
Anka likes Cleo
Troll likes Snowy
15 15000 90

13
Cleo likes Hexadecimal
Cleo likes Snowy
Hexadecimal likes Anka
Anka likes Snowy
Troll likes Snowy
Chapay likes Hexadecimal
Hexadecimal likes Snowy
Snowy likes Chapay
Troll likes Cleo
Anka likes Hexadecimal
Hexadecimal likes Cleo
Chapay likes Dracul
Snowy likes Dracul
1000000000 2000000000 1000000000

12
Cleo likes Hexadecimal
Chapay likes Anka
Hexadecimal likes Cleo
Anka likes Snowy
Anka likes Cleo
Dracul likes Snowy
Anka likes Troll
Snowy likes Anka
Cleo likes Anka
Hexadecimal likes Troll
Hexadecimal likes Chapay
Snowy likes Troll
1000000000 1 2000000000

2
Snowy likes Hexadecimal
Troll likes Dracul
2000000000 2000000000 2000000000

12
Snowy likes Chapay
Cleo likes Dracul
Hexadecimal likes Snowy
Hexadecimal likes Anka
Dracul likes Chapay
Cleo likes Troll
Dracul likes Snowy
Snowy likes Dracul
Troll likes Chapay
Dracul likes Anka
Chapay likes Hexadecimal
Troll likes Dracul
436364663 856574374 347564737

12
Anka likes Dracul
Dracul likes Troll
Cleo likes Troll
Snowy likes Hexadecimal
Hexadecimal likes Chapay
Cleo likes Dracul
Cleo likes Chapay
Hexadecimal likes Anka
Snowy likes Cleo
Hexadecimal likes Snowy
Cleo likes Snowy
Chapay likes Snowy
584329075 428752235 675234087

8
Anka likes Chapay
Dracul likes Snowy
Snowy likes Cleo
Cleo likes Anka
Cleo likes Troll
Hexadecimal likes Troll
Troll likes Cleo
Snowy likes Dracul
325432666 254352394 547360304

18
Snowy likes Troll
Chapay likes Hexadecimal
Cleo likes Snowy
Dracul likes Snowy
Snowy likes Chapay
Troll likes Cleo
Snowy likes Anka
Dracul likes Hexadecimal
Hexadecimal likes Anka
Anka likes Hexadecimal
Anka likes Chapay
Troll likes Anka
Anka likes Snowy
Anka likes Troll
Snowy likes Cleo
Hexadecimal likes Troll
Hexadecimal likes Dracul
Cleo likes Anka
20000 1000 20000

6
Chapay likes Troll
Troll likes Cleo
Cleo likes Troll
Chapay likes Snowy
Anka likes Snowy
Troll likes Dracul
987499608 272739716 133573597

6
Anka likes Troll
Troll likes Chapay
Troll likes Hexadecimal
Hexadecimal likes Cleo
Snowy likes Hexadecimal
Chapay likes Troll
740076959 230477703 987799796

17
Cleo likes Dracul
Troll likes Cleo
Anka likes Chapay
Anka likes Troll
Chapay likes Snowy
Troll likes Snowy
Chapay likes Dracul
Hexadecimal likes Snowy
Dracul likes Snowy
Troll likes Hexadecimal
Hexadecimal likes Anka
Cleo likes Snowy
Hexadecimal likes Dracul
Snowy likes Chapay
Snowy likes Hexadecimal
Snowy likes Dracul
Dracul likes Troll
112909524 619275170 403563648

18
Anka likes Troll
Dracul likes Chapay
Hexadecimal likes Dracul
Chapay likes Dracul
Anka likes Hexadecimal
Snowy likes Cleo
Dracul likes Anka
Snowy likes Anka
Snowy likes Hexadecimal
Dracul likes Troll
Dracul likes Snowy
Hexadecimal likes Anka
Chapay likes Hexadecimal
Snowy likes Dracul
Cleo likes Snowy
Chapay likes Cleo
Anka likes Dracul
Troll likes Anka
838821770 712931449 361810998

18
Hexadecimal likes Chapay
Troll likes Dracul
Troll likes Snowy
Cleo likes Dracul
Chapay likes Snowy
Dracul likes Chapay
Cleo likes Snowy
Dracul likes Hexadecimal
Troll likes Anka
Anka likes Troll
Hexadecimal likes Dracul
Chapay likes Hexadecimal
Cleo likes Chapay
Anka likes Hexadecimal
Snowy likes Dracul
Chapay likes Troll
Anka likes Snowy
Dracul likes Cleo
240256138 922743697 38909902

16
Chapay likes Snowy
Hexadecimal likes Anka
Chapay likes Troll
Dracul likes Cleo
Troll likes Hexadecimal
Hexadecimal likes Dracul
Chapay likes Cleo
Snowy likes Cleo
Snowy likes Anka
Troll likes Chapay
Snowy likes Hexadecimal
Troll likes Snowy
Cleo likes Hexadecimal
Anka likes Snowy
Snowy likes Chapay
Anka likes Dracul
843382501 58524777 503038818

5
Troll likes Chapay
Anka likes Snowy
Anka likes Dracul
Chapay likes Anka
Snowy likes Troll
709201888 431802832 597079932

18
Cleo likes Snowy
Snowy likes Hexadecimal
Cleo likes Hexadecimal
Troll likes Dracul
Hexadecimal likes Snowy
Dracul likes Troll
Chapay likes Anka
Chapay likes Cleo
Troll likes Chapay
Hexadecimal likes Chapay
Anka likes Snowy
Troll likes Snowy
Dracul likes Snowy
Dracul likes Chapay
Chapay likes Troll
Cleo likes Troll
Hexadecimal likes Cleo
Anka likes Chapay
864225278 509037060 402199775

12
Cleo likes Hexadecimal
Troll likes Cleo
Anka likes Cleo
Hexadecimal likes Troll
Anka likes Snowy
Hexadecimal likes Anka
Troll likes Hexadecimal
Troll likes Anka
Dracul likes Cleo
Cleo likes Troll
Dracul likes Troll
Chapay likes Anka
762445890 377707484 324080158

21
Chapay likes Dracul
Snowy likes Chapay
Snowy likes Troll
Cleo likes Chapay
Cleo likes Troll
Chapay likes Cleo
Snowy likes Anka
Dracul likes Anka
Troll likes Snowy
Snowy likes Cleo
Chapay likes Hexadecimal
Cleo likes Anka
Cleo likes Snowy
Hexadecimal likes Cleo
Hexadecimal likes Snowy
Hexadecimal likes Anka
Hexadecimal likes Troll
Anka likes Snowy
Dracul likes Troll
Chapay likes Anka
Snowy likes Hexadecimal
482557397 502108264 750230216

6
Troll likes Chapay
Hexadecimal likes Snowy
Cleo likes Dracul
Cleo likes Anka
Chapay likes Anka
Anka likes Chapay
758376921 432619768 578580897

5
Chapay likes Cleo
Anka likes Hexadecimal
Anka likes Chapay
Cleo likes Troll
Anka likes Cleo
299076810 225593528 36830738

13
Anka likes Cleo
Cleo likes Troll
Chapay likes Cleo
Snowy likes Troll
Chapay likes Anka
Chapay likes Snowy
Snowy likes Chapay
Anka likes Snowy
Snowy likes Dracul
Cleo likes Hexadecimal
Dracul likes Chapay
Anka likes Hexadecimal
Snowy likes Cleo
554338888 280967932 682619964

17
Hexadecimal likes Chapay
Chapay likes Snowy
Chapay likes Troll
Anka likes Hexadecimal
Cleo likes Troll
Snowy likes Cleo
Cleo likes Anka
Cleo likes Hexadecimal
Anka likes Snowy
Chapay likes Hexadecimal
Anka likes Cleo
Dracul likes Snowy
Chapay likes Anka
Troll likes Hexadecimal
Troll likes Anka
Anka likes Dracul
Hexadecimal likes Anka
828886798 548024213 166661324

2
Troll likes Cleo
Anka likes Cleo
14344913 559182022 405430772

22
Cleo likes Snowy
Cleo likes Troll
Chapay likes Dracul
Snowy likes Troll
Dracul likes Chapay
Dracul likes Snowy
Chapay likes Cleo
Snowy likes Chapay
Dracul likes Troll
Anka likes Hexadecimal
Snowy likes Anka
Hexadecimal likes Cleo
Hexadecimal likes Troll
Dracul likes Anka
Cleo likes Hexadecimal
Hexadecimal likes Dracul
Chapay likes Troll
Chapay likes Hexadecimal
Anka likes Snowy
Troll likes Hexadecimal
Snowy likes Hexadecimal
Anka likes Chapay
458053183 602148195 994999698

5
Troll likes Dracul
Anka likes Chapay
Cleo likes Anka
Chapay likes Cleo
Snowy likes Hexadecimal
222 400 400


[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 integers b1, b2, b3, emm1, emm2 and integer array lk of size 10 within an array of size 10
create integer array a of size 8
create string key-type integer map m
declare js taking in integers x, y, and z and returning integer
    set x to b1 / x
    set y to b2 / y
    set z to b3 / z
    set emm1 = the max of abs(x - y), max(abs(y - z), abs(x - z)) and return emm1
end of the block
declare haogan taking in integers x, y, and z and returning integer
    create integer ss = 0
    for i = 1 to x inclusive
        for j = 1 to x inclusive
            if lk[a[i][a[j]] is truthy, increment ss
    for i = x + 1 to x + y inclusive
        for j = x + 1 to x + y inclusive
            if lk[a[i]][a[j]] is truthy, increment ss
    for i = x + y + 1 to 7 inclusive
        for j = x + y + 1 to 7 inclusive
            if lk[a[i]][a[j]] is truthy, increment ss
    set emm2 to ss and return emm2
end of the block
define the main function
    set m["Anka"] to 1
    set m["Chapay"] to 2
    set m["Cleo"] to 3
    set m["Troll"] to 4
    set m["Dracul"] to 5
    set m["Snowy"] to 6
    set m["Hexadecimal"] to 7
    create integer n
    read n
    while n-- is truthy
        create strings s1, s, and s2
        read s1, s, and s2
        set lk[m[s1]][m[s2]] to 1
    end of the block
    create integers ans1 = 1e9 and ans2 = -1e9
    read b1, b2, and b3
    if b1 is less than b2, swap the values of b1 and b2
    if b2 is less than b3, swap the values of b2 and b3
    if b1 is less than b2, swap the values of b1 and b2
    for i = 1 to 7 inclusive, set a[i] to i
    do
        if the return value of js(4, 2, 1) is equal to ans1 and the return value of haogan(4, 2, 1) is greater than ans2, set ans2 to emm2
        if emm1 is less than ans1
            set ans1 to emm1
            set ans2 to the return value of haogan(4, 2, 1)
        end of the block
        if the return value of js(3, 3, 1) is equal to ans1 and the return value of haogan(3, 3, 1) is greater than ans2, set ans2 to emm2
        if emm1 is less than ans1
            set ans1 to emm1
            set ans2 to the return value of haogan(3, 3, 1)
        end of the block
        if the return value of js(3, 2, 2) is equal to ans1 and the return value of haogan(3, 2, 2) is greater than ans2, set ans2 to emm2
        if emm1 is less than ans1
            set ans1 to emm1
            set ans2 to the return value of haogan(3, 2, 2)
        end of the block
        if the return value of js(5, 1, 1) is equal to ans1 and the return value of haogan(5, 1, 1) is greater than ans2, set ans2 to emm2
        if emm1 is less than ans1
            set ans1 to emm1
            set ans2 to haogan(5, 1, 1)
        end of the block
    while the return value of next_permutation(a + 1, a + 7 + 1) is truthy
    print ans1, ' ', and ans2
end of the block

[CODE]:

int b1, b2, b3, emm1, emm2, lk[10][10];
int a[8];
map<string, int> m;
int js(int x, int y, int z) {
    x = b1 / x;
    y = b2 / y;
    z = b3 / z;
    return emm1 = max(abs(x - y), max(abs(y - z), abs(x - z)));
}
int haogan(int x, int y, int z) {
    int ss = 0;
    for (int i = 1; i <= x; i++)
        for (int j = 1; j <= x; j++)
            if (lk[a[i]][a[j]]) ss++;
    for (int i = x + 1; i <= x + y; i++)
        for (int j = x + 1; j <= x + y; j++)
            if (lk[a[i]][a[j]]) ss++;
    for (int i = x + y + 1; i <= 7; i++)
        for (int j = x + y + 1; j <= 7; j++)
            if (lk[a[i]][a[j]]) ss++;
    return emm2 = ss;
}
int main() {
    m["Anka"] = 1;
    m["Chapay"] = 2;
    m["Cleo"] = 3;
    m["Troll"] = 4;
    m["Dracul"] = 5;
    m["Snowy"] = 6;
    m["Hexadecimal"] = 7;
    int n;
    cin >> n;
    while (n--) {
        string s1, s, s2;
        cin >> s1 >> s >> s2;
        lk[m[s1]][m[s2]] = 1;
    }
    int ans1 = 1e9, ans2 = -1e9;
    cin >> b1 >> b2 >> b3;
    if (b1 < b2) swap(b1, b2);
    if (b2 < b3) swap(b2, b3);
    if (b1 < b2) swap(b1, b2);
    for (int i = 1; i <= 7; i++) a[i] = i;
    do {
        if ((js(4, 2, 1) == ans1) && (haogan(4, 2, 1) > ans2)) { ans2 = emm2; }
        if (emm1 < ans1) {
            ans1 = emm1;
            ans2 = haogan(4, 2, 1);
        }
        if ((js(3, 3, 1) == ans1) && (haogan(3, 3, 1) > ans2)) { ans2 = emm2; }
        if (emm1 < ans1) {
            ans1 = emm1;
            ans2 = haogan(3, 3, 1);
        }
        if ((js(3, 2, 2) == ans1) && (haogan(3, 2, 2) > ans2)) { ans2 = emm2; }
        if (emm1 < ans1) {
            ans1 = emm1;
            ans2 = haogan(3, 2, 2);
        }
        if ((js(5, 1, 1) == ans1) && (haogan(5, 1, 1) > ans2)) { ans2 = emm2; }
        if (emm1 < ans1) {
            ans1 = emm1;
            ans2 = haogan(5, 1, 1);
        }
    } while (next_permutation(a + 1, a + 7 + 1));
    cout << ans1 << ' ' << ans2 << endl;
}

3
Troll likes Dracul
Dracul likes Anka
Snowy likes Hexadecimal
210 200 180

2
Anka likes Chapay
Chapay likes Anka
10000 50 50

11
Snowy likes Dracul
Anka likes Dracul
Chapay likes Snowy
Hexadecimal likes Troll
Anka likes Cleo
Chapay likes Dracul
Anka likes Chapay
Snowy likes Troll
Anka likes Hexadecimal
Cleo likes Chapay
Troll likes Cleo
100 100 100

14
Chapay likes Cleo
Cleo likes Anka
Dracul likes Snowy
Snowy likes Cleo
Chapay likes Anka
Snowy likes Anka
Chapay likes Troll
Troll likes Anka
Anka likes Snowy
Chapay likes Dracul
Dracul likes Anka
Hexadecimal likes Chapay
Snowy likes Dracul
Cleo likes Dracul
15 15 15

4
Anka likes Cleo
Snowy likes Cleo
Anka likes Hexadecimal
Cleo likes Snowy
1 1 1

8
Snowy likes Anka
Hexadecimal likes Snowy
Troll likes Dracul
Hexadecimal likes Troll
Snowy likes Troll
Anka likes Snowy
Snowy likes Chapay
Anka likes Chapay
70 70 70

3
Chapay likes Hexadecimal
Anka likes Cleo
Troll likes Snowy
15 15000 90

13
Cleo likes Hexadecimal
Cleo likes Snowy
Hexadecimal likes Anka
Anka likes Snowy
Troll likes Snowy
Chapay likes Hexadecimal
Hexadecimal likes Snowy
Snowy likes Chapay
Troll likes Cleo
Anka likes Hexadecimal
Hexadecimal likes Cleo
Chapay likes Dracul
Snowy likes Dracul
1000000000 2000000000 1000000000

12
Cleo likes Hexadecimal
Chapay likes Anka
Hexadecimal likes Cleo
Anka likes Snowy
Anka likes Cleo
Dracul likes Snowy
Anka likes Troll
Snowy likes Anka
Cleo likes Anka
Hexadecimal likes Troll
Hexadecimal likes Chapay
Snowy likes Troll
1000000000 1 2000000000

2
Snowy likes Hexadecimal
Troll likes Dracul
2000000000 2000000000 2000000000

12
Snowy likes Chapay
Cleo likes Dracul
Hexadecimal likes Snowy
Hexadecimal likes Anka
Dracul likes Chapay
Cleo likes Troll
Dracul likes Snowy
Snowy likes Dracul
Troll likes Chapay
Dracul likes Anka
Chapay likes Hexadecimal
Troll likes Dracul
436364663 856574374 347564737

12
Anka likes Dracul
Dracul likes Troll
Cleo likes Troll
Snowy likes Hexadecimal
Hexadecimal likes Chapay
Cleo likes Dracul
Cleo likes Chapay
Hexadecimal likes Anka
Snowy likes Cleo
Hexadecimal likes Snowy
Cleo likes Snowy
Chapay likes Snowy
584329075 428752235 675234087

8
Anka likes Chapay
Dracul likes Snowy
Snowy likes Cleo
Cleo likes Anka
Cleo likes Troll
Hexadecimal likes Troll
Troll likes Cleo
Snowy likes Dracul
325432666 254352394 547360304

18
Snowy likes Troll
Chapay likes Hexadecimal
Cleo likes Snowy
Dracul likes Snowy
Snowy likes Chapay
Troll likes Cleo
Snowy likes Anka
Dracul likes Hexadecimal
Hexadecimal likes Anka
Anka likes Hexadecimal
Anka likes Chapay
Troll likes Anka
Anka likes Snowy
Anka likes Troll
Snowy likes Cleo
Hexadecimal likes Troll
Hexadecimal likes Dracul
Cleo likes Anka
20000 1000 20000

6
Chapay likes Troll
Troll likes Cleo
Cleo likes Troll
Chapay likes Snowy
Anka likes Snowy
Troll likes Dracul
987499608 272739716 133573597

6
Anka likes Troll
Troll likes Chapay
Troll likes Hexadecimal
Hexadecimal likes Cleo
Snowy likes Hexadecimal
Chapay likes Troll
740076959 230477703 987799796

17
Cleo likes Dracul
Troll likes Cleo
Anka likes Chapay
Anka likes Troll
Chapay likes Snowy
Troll likes Snowy
Chapay likes Dracul
Hexadecimal likes Snowy
Dracul likes Snowy
Troll likes Hexadecimal
Hexadecimal likes Anka
Cleo likes Snowy
Hexadecimal likes Dracul
Snowy likes Chapay
Snowy likes Hexadecimal
Snowy likes Dracul
Dracul likes Troll
112909524 619275170 403563648

18
Anka likes Troll
Dracul likes Chapay
Hexadecimal likes Dracul
Chapay likes Dracul
Anka likes Hexadecimal
Snowy likes Cleo
Dracul likes Anka
Snowy likes Anka
Snowy likes Hexadecimal
Dracul likes Troll
Dracul likes Snowy
Hexadecimal likes Anka
Chapay likes Hexadecimal
Snowy likes Dracul
Cleo likes Snowy
Chapay likes Cleo
Anka likes Dracul
Troll likes Anka
838821770 712931449 361810998

18
Hexadecimal likes Chapay
Troll likes Dracul
Troll likes Snowy
Cleo likes Dracul
Chapay likes Snowy
Dracul likes Chapay
Cleo likes Snowy
Dracul likes Hexadecimal
Troll likes Anka
Anka likes Troll
Hexadecimal likes Dracul
Chapay likes Hexadecimal
Cleo likes Chapay
Anka likes Hexadecimal
Snowy likes Dracul
Chapay likes Troll
Anka likes Snowy
Dracul likes Cleo
240256138 922743697 38909902

16
Chapay likes Snowy
Hexadecimal likes Anka
Chapay likes Troll
Dracul likes Cleo
Troll likes Hexadecimal
Hexadecimal likes Dracul
Chapay likes Cleo
Snowy likes Cleo
Snowy likes Anka
Troll likes Chapay
Snowy likes Hexadecimal
Troll likes Snowy
Cleo likes Hexadecimal
Anka likes Snowy
Snowy likes Chapay
Anka likes Dracul
843382501 58524777 503038818

5
Troll likes Chapay
Anka likes Snowy
Anka likes Dracul
Chapay likes Anka
Snowy likes Troll
709201888 431802832 597079932

18
Cleo likes Snowy
Snowy likes Hexadecimal
Cleo likes Hexadecimal
Troll likes Dracul
Hexadecimal likes Snowy
Dracul likes Troll
Chapay likes Anka
Chapay likes Cleo
Troll likes Chapay
Hexadecimal likes Chapay
Anka likes Snowy
Troll likes Snowy
Dracul likes Snowy
Dracul likes Chapay
Chapay likes Troll
Cleo likes Troll
Hexadecimal likes Cleo
Anka likes Chapay
864225278 509037060 402199775

12
Cleo likes Hexadecimal
Troll likes Cleo
Anka likes Cleo
Hexadecimal likes Troll
Anka likes Snowy
Hexadecimal likes Anka
Troll likes Hexadecimal
Troll likes Anka
Dracul likes Cleo
Cleo likes Troll
Dracul likes Troll
Chapay likes Anka
762445890 377707484 324080158

21
Chapay likes Dracul
Snowy likes Chapay
Snowy likes Troll
Cleo likes Chapay
Cleo likes Troll
Chapay likes Cleo
Snowy likes Anka
Dracul likes Anka
Troll likes Snowy
Snowy likes Cleo
Chapay likes Hexadecimal
Cleo likes Anka
Cleo likes Snowy
Hexadecimal likes Cleo
Hexadecimal likes Snowy
Hexadecimal likes Anka
Hexadecimal likes Troll
Anka likes Snowy
Dracul likes Troll
Chapay likes Anka
Snowy likes Hexadecimal
482557397 502108264 750230216

6
Troll likes Chapay
Hexadecimal likes Snowy
Cleo likes Dracul
Cleo likes Anka
Chapay likes Anka
Anka likes Chapay
758376921 432619768 578580897

5
Chapay likes Cleo
Anka likes Hexadecimal
Anka likes Chapay
Cleo likes Troll
Anka likes Cleo
299076810 225593528 36830738

13
Anka likes Cleo
Cleo likes Troll
Chapay likes Cleo
Snowy likes Troll
Chapay likes Anka
Chapay likes Snowy
Snowy likes Chapay
Anka likes Snowy
Snowy likes Dracul
Cleo likes Hexadecimal
Dracul likes Chapay
Anka likes Hexadecimal
Snowy likes Cleo
554338888 280967932 682619964

17
Hexadecimal likes Chapay
Chapay likes Snowy
Chapay likes Troll
Anka likes Hexadecimal
Cleo likes Troll
Snowy likes Cleo
Cleo likes Anka
Cleo likes Hexadecimal
Anka likes Snowy
Chapay likes Hexadecimal
Anka likes Cleo
Dracul likes Snowy
Chapay likes Anka
Troll likes Hexadecimal
Troll likes Anka
Anka likes Dracul
Hexadecimal likes Anka
828886798 548024213 166661324

2
Troll likes Cleo
Anka likes Cleo
14344913 559182022 405430772

22
Cleo likes Snowy
Cleo likes Troll
Chapay likes Dracul
Snowy likes Troll
Dracul likes Chapay
Dracul likes Snowy
Chapay likes Cleo
Snowy likes Chapay
Dracul likes Troll
Anka likes Hexadecimal
Snowy likes Anka
Hexadecimal likes Cleo
Hexadecimal likes Troll
Dracul likes Anka
Cleo likes Hexadecimal
Hexadecimal likes Dracul
Chapay likes Troll
Chapay likes Hexadecimal
Anka likes Snowy
Troll likes Hexadecimal
Snowy likes Hexadecimal
Anka likes Chapay
458053183 602148195 994999698

5
Troll likes Dracul
Anka likes Chapay
Cleo likes Anka
Chapay likes Cleo
Snowy likes Hexadecimal
222 400 400


[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]:
vec = int vector array of size 3
like = string and int map
diff, ans, a, b, c = int and mat = two dimensional int array of sizes 10 and 10
in function cal returning an int
    sum, i, j, k = int with sum = 0
    for i = 0 to 3
        for j = 0 to size of vec[i]
            for k = 0 to size of vec[i] increment sum by mat[vec[i][j]][vec[i][k]]
    end of the block
    return sum
end of the block
in function count taking an int now
    if now is 7
        if size of vec[0] and size of vec[1] and size of vec[2] are all not 0
            x = int array with the values a / size of vec[0], b / size of vec[1] and c / size of vec[2]
            sort x
            if x[2] - x[0] is less than diff
                set diff to x[2] - x[0]
                set ans to cal
            else if x[2] - x[0] is diff
                set ans to max of ans and cal
        end of the block
        return
    end of the block
    for i = 0 to 3
        append now to vec[i]
        call count of now + 1
        remove last value of vec[i]
    end of the block
end of the block
define the main function
    set like["Anka"] to 0
    set like["Chapay"] to 1
    set like["Cleo"] to 2
    set like["Troll"] to 3
    set like["Dracul"] to 4
    set like["Snowy"] to 5
    set like["Hexadecimal"] to 6
    n, i = int
    name1, str, name2 = string
    loop while reading n
        set diff to (1 bitshift right by 31) - 1
        for i = 0 to 3 clear vec[i]
        set all values of mat to 0
        for i = 0 to n
            read name1 then str then name2
            increment mat[like[name1]][like[name2]]
        end of the block
        read a then b then c
        call count of 0
        print diff and ans
    end of the block
end of the block

[CODE]:

vector<int> vec[3];
map<string, int> like;
int diff, mat[10][10], ans, a, b, c;
int cal() {
    int sum = 0, i, j, k;
    for (i = 0; i < 3; i++) {
        for (j = 0; j < vec[i].size(); j++)
            for (k = 0; k < vec[i].size(); k++) sum += mat[vec[i][j]][vec[i][k]];
    }
    return sum;
}
void count(int now) {
    if (now == 7) {
        if (vec[0].size() && vec[1].size() && vec[2].size()) {
            int x[] = {a / vec[0].size(), b / vec[1].size(), c / vec[2].size()};
            sort(x, x + 3);
            if (x[2] - x[0] < diff) {
                diff = x[2] - x[0];
                ans = cal();
            } else if (x[2] - x[0] == diff)
                ans = max(ans, cal());
        }
        return;
    }
    for (int i = 0; i < 3; i++) {
        vec[i].push_back(now);
        count(now + 1);
        vec[i].pop_back();
    }
}
int main() {
    like["Anka"] = 0;
    like["Chapay"] = 1;
    like["Cleo"] = 2;
    like["Troll"] = 3;
    like["Dracul"] = 4;
    like["Snowy"] = 5;
    like["Hexadecimal"] = 6;
    int n, i;
    string name1, str, name2;
    while (cin >> n) {
        diff = (1 << 31) - 1;
        for (i = 0; i < 3; i++) vec[i].clear();
        memset(mat, 0, sizeof(mat));
        for (i = 0; i < n; i++) {
            cin >> name1 >> str >> name2;
            mat[like[name1]][like[name2]]++;
        }
        cin >> a >> b >> c;
        count(0);
        cout << diff << " " << ans << endl;
    }
}

3
Troll likes Dracul
Dracul likes Anka
Snowy likes Hexadecimal
210 200 180

2
Anka likes Chapay
Chapay likes Anka
10000 50 50

11
Snowy likes Dracul
Anka likes Dracul
Chapay likes Snowy
Hexadecimal likes Troll
Anka likes Cleo
Chapay likes Dracul
Anka likes Chapay
Snowy likes Troll
Anka likes Hexadecimal
Cleo likes Chapay
Troll likes Cleo
100 100 100

14
Chapay likes Cleo
Cleo likes Anka
Dracul likes Snowy
Snowy likes Cleo
Chapay likes Anka
Snowy likes Anka
Chapay likes Troll
Troll likes Anka
Anka likes Snowy
Chapay likes Dracul
Dracul likes Anka
Hexadecimal likes Chapay
Snowy likes Dracul
Cleo likes Dracul
15 15 15

4
Anka likes Cleo
Snowy likes Cleo
Anka likes Hexadecimal
Cleo likes Snowy
1 1 1

8
Snowy likes Anka
Hexadecimal likes Snowy
Troll likes Dracul
Hexadecimal likes Troll
Snowy likes Troll
Anka likes Snowy
Snowy likes Chapay
Anka likes Chapay
70 70 70

3
Chapay likes Hexadecimal
Anka likes Cleo
Troll likes Snowy
15 15000 90

13
Cleo likes Hexadecimal
Cleo likes Snowy
Hexadecimal likes Anka
Anka likes Snowy
Troll likes Snowy
Chapay likes Hexadecimal
Hexadecimal likes Snowy
Snowy likes Chapay
Troll likes Cleo
Anka likes Hexadecimal
Hexadecimal likes Cleo
Chapay likes Dracul
Snowy likes Dracul
1000000000 2000000000 1000000000

12
Cleo likes Hexadecimal
Chapay likes Anka
Hexadecimal likes Cleo
Anka likes Snowy
Anka likes Cleo
Dracul likes Snowy
Anka likes Troll
Snowy likes Anka
Cleo likes Anka
Hexadecimal likes Troll
Hexadecimal likes Chapay
Snowy likes Troll
1000000000 1 2000000000

2
Snowy likes Hexadecimal
Troll likes Dracul
2000000000 2000000000 2000000000

12
Snowy likes Chapay
Cleo likes Dracul
Hexadecimal likes Snowy
Hexadecimal likes Anka
Dracul likes Chapay
Cleo likes Troll
Dracul likes Snowy
Snowy likes Dracul
Troll likes Chapay
Dracul likes Anka
Chapay likes Hexadecimal
Troll likes Dracul
436364663 856574374 347564737

12
Anka likes Dracul
Dracul likes Troll
Cleo likes Troll
Snowy likes Hexadecimal
Hexadecimal likes Chapay
Cleo likes Dracul
Cleo likes Chapay
Hexadecimal likes Anka
Snowy likes Cleo
Hexadecimal likes Snowy
Cleo likes Snowy
Chapay likes Snowy
584329075 428752235 675234087

8
Anka likes Chapay
Dracul likes Snowy
Snowy likes Cleo
Cleo likes Anka
Cleo likes Troll
Hexadecimal likes Troll
Troll likes Cleo
Snowy likes Dracul
325432666 254352394 547360304

18
Snowy likes Troll
Chapay likes Hexadecimal
Cleo likes Snowy
Dracul likes Snowy
Snowy likes Chapay
Troll likes Cleo
Snowy likes Anka
Dracul likes Hexadecimal
Hexadecimal likes Anka
Anka likes Hexadecimal
Anka likes Chapay
Troll likes Anka
Anka likes Snowy
Anka likes Troll
Snowy likes Cleo
Hexadecimal likes Troll
Hexadecimal likes Dracul
Cleo likes Anka
20000 1000 20000

6
Chapay likes Troll
Troll likes Cleo
Cleo likes Troll
Chapay likes Snowy
Anka likes Snowy
Troll likes Dracul
987499608 272739716 133573597

6
Anka likes Troll
Troll likes Chapay
Troll likes Hexadecimal
Hexadecimal likes Cleo
Snowy likes Hexadecimal
Chapay likes Troll
740076959 230477703 987799796

17
Cleo likes Dracul
Troll likes Cleo
Anka likes Chapay
Anka likes Troll
Chapay likes Snowy
Troll likes Snowy
Chapay likes Dracul
Hexadecimal likes Snowy
Dracul likes Snowy
Troll likes Hexadecimal
Hexadecimal likes Anka
Cleo likes Snowy
Hexadecimal likes Dracul
Snowy likes Chapay
Snowy likes Hexadecimal
Snowy likes Dracul
Dracul likes Troll
112909524 619275170 403563648

18
Anka likes Troll
Dracul likes Chapay
Hexadecimal likes Dracul
Chapay likes Dracul
Anka likes Hexadecimal
Snowy likes Cleo
Dracul likes Anka
Snowy likes Anka
Snowy likes Hexadecimal
Dracul likes Troll
Dracul likes Snowy
Hexadecimal likes Anka
Chapay likes Hexadecimal
Snowy likes Dracul
Cleo likes Snowy
Chapay likes Cleo
Anka likes Dracul
Troll likes Anka
838821770 712931449 361810998

18
Hexadecimal likes Chapay
Troll likes Dracul
Troll likes Snowy
Cleo likes Dracul
Chapay likes Snowy
Dracul likes Chapay
Cleo likes Snowy
Dracul likes Hexadecimal
Troll likes Anka
Anka likes Troll
Hexadecimal likes Dracul
Chapay likes Hexadecimal
Cleo likes Chapay
Anka likes Hexadecimal
Snowy likes Dracul
Chapay likes Troll
Anka likes Snowy
Dracul likes Cleo
240256138 922743697 38909902

16
Chapay likes Snowy
Hexadecimal likes Anka
Chapay likes Troll
Dracul likes Cleo
Troll likes Hexadecimal
Hexadecimal likes Dracul
Chapay likes Cleo
Snowy likes Cleo
Snowy likes Anka
Troll likes Chapay
Snowy likes Hexadecimal
Troll likes Snowy
Cleo likes Hexadecimal
Anka likes Snowy
Snowy likes Chapay
Anka likes Dracul
843382501 58524777 503038818

5
Troll likes Chapay
Anka likes Snowy
Anka likes Dracul
Chapay likes Anka
Snowy likes Troll
709201888 431802832 597079932

18
Cleo likes Snowy
Snowy likes Hexadecimal
Cleo likes Hexadecimal
Troll likes Dracul
Hexadecimal likes Snowy
Dracul likes Troll
Chapay likes Anka
Chapay likes Cleo
Troll likes Chapay
Hexadecimal likes Chapay
Anka likes Snowy
Troll likes Snowy
Dracul likes Snowy
Dracul likes Chapay
Chapay likes Troll
Cleo likes Troll
Hexadecimal likes Cleo
Anka likes Chapay
864225278 509037060 402199775

12
Cleo likes Hexadecimal
Troll likes Cleo
Anka likes Cleo
Hexadecimal likes Troll
Anka likes Snowy
Hexadecimal likes Anka
Troll likes Hexadecimal
Troll likes Anka
Dracul likes Cleo
Cleo likes Troll
Dracul likes Troll
Chapay likes Anka
762445890 377707484 324080158

21
Chapay likes Dracul
Snowy likes Chapay
Snowy likes Troll
Cleo likes Chapay
Cleo likes Troll
Chapay likes Cleo
Snowy likes Anka
Dracul likes Anka
Troll likes Snowy
Snowy likes Cleo
Chapay likes Hexadecimal
Cleo likes Anka
Cleo likes Snowy
Hexadecimal likes Cleo
Hexadecimal likes Snowy
Hexadecimal likes Anka
Hexadecimal likes Troll
Anka likes Snowy
Dracul likes Troll
Chapay likes Anka
Snowy likes Hexadecimal
482557397 502108264 750230216

6
Troll likes Chapay
Hexadecimal likes Snowy
Cleo likes Dracul
Cleo likes Anka
Chapay likes Anka
Anka likes Chapay
758376921 432619768 578580897

5
Chapay likes Cleo
Anka likes Hexadecimal
Anka likes Chapay
Cleo likes Troll
Anka likes Cleo
299076810 225593528 36830738

13
Anka likes Cleo
Cleo likes Troll
Chapay likes Cleo
Snowy likes Troll
Chapay likes Anka
Chapay likes Snowy
Snowy likes Chapay
Anka likes Snowy
Snowy likes Dracul
Cleo likes Hexadecimal
Dracul likes Chapay
Anka likes Hexadecimal
Snowy likes Cleo
554338888 280967932 682619964

17
Hexadecimal likes Chapay
Chapay likes Snowy
Chapay likes Troll
Anka likes Hexadecimal
Cleo likes Troll
Snowy likes Cleo
Cleo likes Anka
Cleo likes Hexadecimal
Anka likes Snowy
Chapay likes Hexadecimal
Anka likes Cleo
Dracul likes Snowy
Chapay likes Anka
Troll likes Hexadecimal
Troll likes Anka
Anka likes Dracul
Hexadecimal likes Anka
828886798 548024213 166661324

2
Troll likes Cleo
Anka likes Cleo
14344913 559182022 405430772

22
Cleo likes Snowy
Cleo likes Troll
Chapay likes Dracul
Snowy likes Troll
Dracul likes Chapay
Dracul likes Snowy
Chapay likes Cleo
Snowy likes Chapay
Dracul likes Troll
Anka likes Hexadecimal
Snowy likes Anka
Hexadecimal likes Cleo
Hexadecimal likes Troll
Dracul likes Anka
Cleo likes Hexadecimal
Hexadecimal likes Dracul
Chapay likes Troll
Chapay likes Hexadecimal
Anka likes Snowy
Troll likes Hexadecimal
Snowy likes Hexadecimal
Anka likes Chapay
458053183 602148195 994999698

5
Troll likes Dracul
Anka likes Chapay
Cleo likes Anka
Chapay likes Cleo
Snowy likes Hexadecimal
222 400 400


[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 long longs ml = 0 and md = 10e10
create vector of ints team with 7 elements filled with 0
create map of string to int called hashi
create map of int/int pairs to bool called likes
create vector of long long called xp with 3 elements
tri is a void function with int argument i
    if i is equal to 7
        create long longs mie = 10e10 and mae and lik = 0
        create bool can = true
        for integer j = 0 to 3 exclusive
            create long long co = 0
            loop k from 0 to 7 exclusive
                if team[k] is equal to j
                    increment co
                    for l = 0 to 7 exclusive
                        if team[l] = j and likes[pair<int, int>(k, l)] is true, increment lik by one
                    end of the block
                end of the block
            end of the block
            if co is equal to 0
                assign false to can
                break
            end of the block
            change mie to min of mie and xp[j] / co
            change mae to max of mae and xp[j] / co
        end of the block
        if can is true
            create long long dif = mae - mie
            if dif = md
                set ml to max of lik and ml
            else if dif < md
                assign dif to md
                assign lik to ml
            end of the block
        end of the block
    else
        for integer j = 0 to 3 exclusive
            set team[i] to j
            call tri(i + 1)
        end of the block
    end of the block
    return
end of the block
define the main function
    declare int variable n
    read input to n
    assign 0 to hashi["Trolong long"]
    assign 1 to hashi["Dracul"]
    assign 2 to hashi["Anka"]
    assign 3 to hashi["Snowy"]
    assign 4 to hashi["Hexadecimal"]
    assign 5 to hashi["Chapay"]
    assign 6 to hashi["Cleo"]
    loop, decrementing n, while it is not 0
        create strings p and q
        read input to p, q and q
        set likes[pair<int, int>(hashi[p], hashi[q])] to true
    end of the block
    loop i from 0 to 3 exclusive, read xp[i]
    call tri(0)
    print md, " ", ml and "\n"
    return to indicate successful execution
end of the block

[CODE]:

long long md = 10e10, ml = 0;
vector<int> team(7, 0);
map<string, int> hashi;
map<pair<int, int>, bool> likes;
vector<long long> xp(3);
void tri(int i) {
    if (i == 7) {
        long long mie = 10e10, mae = 0, lik = 0;
        bool can = true;
        for (int j = 0; j < 3; j++) {
            long long co = 0;
            for (int k = 0; k < 7; k++) {
                if (team[k] == j) {
                    co++;
                    for (int l = 0; l < 7; l++) {
                        if (team[l] == j && likes[pair<int, int>(k, l)]) { lik++; }
                    }
                }
            }
            if (co == 0) {
                can = false;
                break;
            }
            mie = min(mie, xp[j] / co);
            mae = max(mae, xp[j] / co);
        }
        if (can) {
            long long dif = mae - mie;
            if (dif == md)
                ml = max(lik, ml);
            else if (dif < md) {
                md = dif;
                ml = lik;
            }
        }
    } else {
        for (int j = 0; j < 3; j++) {
            team[i] = j;
            tri(i + 1);
        }
    }
    return;
}
int main() {
    int n;
    cin >> n;
    hashi["Trolong long"] = 0;
    hashi["Dracul"] = 1;
    hashi["Anka"] = 2;
    hashi["Snowy"] = 3;
    hashi["Hexadecimal"] = 4;
    hashi["Chapay"] = 5;
    hashi["Cleo"] = 6;
    while (n--) {
        string p, q;
        cin >> p >> q >> q;
        likes[pair<int, int>(hashi[p], hashi[q])] = true;
    }
    for (int i = 0; i < 3; i++) cin >> xp[i];
    tri(0);
    cout << md << " " << ml << "\n";
    return 0;
}

3
Troll likes Dracul
Dracul likes Anka
Snowy likes Hexadecimal
210 200 180

2
Anka likes Chapay
Chapay likes Anka
10000 50 50

11
Snowy likes Dracul
Anka likes Dracul
Chapay likes Snowy
Hexadecimal likes Troll
Anka likes Cleo
Chapay likes Dracul
Anka likes Chapay
Snowy likes Troll
Anka likes Hexadecimal
Cleo likes Chapay
Troll likes Cleo
100 100 100

14
Chapay likes Cleo
Cleo likes Anka
Dracul likes Snowy
Snowy likes Cleo
Chapay likes Anka
Snowy likes Anka
Chapay likes Troll
Troll likes Anka
Anka likes Snowy
Chapay likes Dracul
Dracul likes Anka
Hexadecimal likes Chapay
Snowy likes Dracul
Cleo likes Dracul
15 15 15

4
Anka likes Cleo
Snowy likes Cleo
Anka likes Hexadecimal
Cleo likes Snowy
1 1 1

8
Snowy likes Anka
Hexadecimal likes Snowy
Troll likes Dracul
Hexadecimal likes Troll
Snowy likes Troll
Anka likes Snowy
Snowy likes Chapay
Anka likes Chapay
70 70 70

3
Chapay likes Hexadecimal
Anka likes Cleo
Troll likes Snowy
15 15000 90

13
Cleo likes Hexadecimal
Cleo likes Snowy
Hexadecimal likes Anka
Anka likes Snowy
Troll likes Snowy
Chapay likes Hexadecimal
Hexadecimal likes Snowy
Snowy likes Chapay
Troll likes Cleo
Anka likes Hexadecimal
Hexadecimal likes Cleo
Chapay likes Dracul
Snowy likes Dracul
1000000000 2000000000 1000000000

12
Cleo likes Hexadecimal
Chapay likes Anka
Hexadecimal likes Cleo
Anka likes Snowy
Anka likes Cleo
Dracul likes Snowy
Anka likes Troll
Snowy likes Anka
Cleo likes Anka
Hexadecimal likes Troll
Hexadecimal likes Chapay
Snowy likes Troll
1000000000 1 2000000000

2
Snowy likes Hexadecimal
Troll likes Dracul
2000000000 2000000000 2000000000

12
Snowy likes Chapay
Cleo likes Dracul
Hexadecimal likes Snowy
Hexadecimal likes Anka
Dracul likes Chapay
Cleo likes Troll
Dracul likes Snowy
Snowy likes Dracul
Troll likes Chapay
Dracul likes Anka
Chapay likes Hexadecimal
Troll likes Dracul
436364663 856574374 347564737

12
Anka likes Dracul
Dracul likes Troll
Cleo likes Troll
Snowy likes Hexadecimal
Hexadecimal likes Chapay
Cleo likes Dracul
Cleo likes Chapay
Hexadecimal likes Anka
Snowy likes Cleo
Hexadecimal likes Snowy
Cleo likes Snowy
Chapay likes Snowy
584329075 428752235 675234087

8
Anka likes Chapay
Dracul likes Snowy
Snowy likes Cleo
Cleo likes Anka
Cleo likes Troll
Hexadecimal likes Troll
Troll likes Cleo
Snowy likes Dracul
325432666 254352394 547360304

18
Snowy likes Troll
Chapay likes Hexadecimal
Cleo likes Snowy
Dracul likes Snowy
Snowy likes Chapay
Troll likes Cleo
Snowy likes Anka
Dracul likes Hexadecimal
Hexadecimal likes Anka
Anka likes Hexadecimal
Anka likes Chapay
Troll likes Anka
Anka likes Snowy
Anka likes Troll
Snowy likes Cleo
Hexadecimal likes Troll
Hexadecimal likes Dracul
Cleo likes Anka
20000 1000 20000

6
Chapay likes Troll
Troll likes Cleo
Cleo likes Troll
Chapay likes Snowy
Anka likes Snowy
Troll likes Dracul
987499608 272739716 133573597

6
Anka likes Troll
Troll likes Chapay
Troll likes Hexadecimal
Hexadecimal likes Cleo
Snowy likes Hexadecimal
Chapay likes Troll
740076959 230477703 987799796

17
Cleo likes Dracul
Troll likes Cleo
Anka likes Chapay
Anka likes Troll
Chapay likes Snowy
Troll likes Snowy
Chapay likes Dracul
Hexadecimal likes Snowy
Dracul likes Snowy
Troll likes Hexadecimal
Hexadecimal likes Anka
Cleo likes Snowy
Hexadecimal likes Dracul
Snowy likes Chapay
Snowy likes Hexadecimal
Snowy likes Dracul
Dracul likes Troll
112909524 619275170 403563648

18
Anka likes Troll
Dracul likes Chapay
Hexadecimal likes Dracul
Chapay likes Dracul
Anka likes Hexadecimal
Snowy likes Cleo
Dracul likes Anka
Snowy likes Anka
Snowy likes Hexadecimal
Dracul likes Troll
Dracul likes Snowy
Hexadecimal likes Anka
Chapay likes Hexadecimal
Snowy likes Dracul
Cleo likes Snowy
Chapay likes Cleo
Anka likes Dracul
Troll likes Anka
838821770 712931449 361810998

18
Hexadecimal likes Chapay
Troll likes Dracul
Troll likes Snowy
Cleo likes Dracul
Chapay likes Snowy
Dracul likes Chapay
Cleo likes Snowy
Dracul likes Hexadecimal
Troll likes Anka
Anka likes Troll
Hexadecimal likes Dracul
Chapay likes Hexadecimal
Cleo likes Chapay
Anka likes Hexadecimal
Snowy likes Dracul
Chapay likes Troll
Anka likes Snowy
Dracul likes Cleo
240256138 922743697 38909902

16
Chapay likes Snowy
Hexadecimal likes Anka
Chapay likes Troll
Dracul likes Cleo
Troll likes Hexadecimal
Hexadecimal likes Dracul
Chapay likes Cleo
Snowy likes Cleo
Snowy likes Anka
Troll likes Chapay
Snowy likes Hexadecimal
Troll likes Snowy
Cleo likes Hexadecimal
Anka likes Snowy
Snowy likes Chapay
Anka likes Dracul
843382501 58524777 503038818

5
Troll likes Chapay
Anka likes Snowy
Anka likes Dracul
Chapay likes Anka
Snowy likes Troll
709201888 431802832 597079932

18
Cleo likes Snowy
Snowy likes Hexadecimal
Cleo likes Hexadecimal
Troll likes Dracul
Hexadecimal likes Snowy
Dracul likes Troll
Chapay likes Anka
Chapay likes Cleo
Troll likes Chapay
Hexadecimal likes Chapay
Anka likes Snowy
Troll likes Snowy
Dracul likes Snowy
Dracul likes Chapay
Chapay likes Troll
Cleo likes Troll
Hexadecimal likes Cleo
Anka likes Chapay
864225278 509037060 402199775

12
Cleo likes Hexadecimal
Troll likes Cleo
Anka likes Cleo
Hexadecimal likes Troll
Anka likes Snowy
Hexadecimal likes Anka
Troll likes Hexadecimal
Troll likes Anka
Dracul likes Cleo
Cleo likes Troll
Dracul likes Troll
Chapay likes Anka
762445890 377707484 324080158

21
Chapay likes Dracul
Snowy likes Chapay
Snowy likes Troll
Cleo likes Chapay
Cleo likes Troll
Chapay likes Cleo
Snowy likes Anka
Dracul likes Anka
Troll likes Snowy
Snowy likes Cleo
Chapay likes Hexadecimal
Cleo likes Anka
Cleo likes Snowy
Hexadecimal likes Cleo
Hexadecimal likes Snowy
Hexadecimal likes Anka
Hexadecimal likes Troll
Anka likes Snowy
Dracul likes Troll
Chapay likes Anka
Snowy likes Hexadecimal
482557397 502108264 750230216

6
Troll likes Chapay
Hexadecimal likes Snowy
Cleo likes Dracul
Cleo likes Anka
Chapay likes Anka
Anka likes Chapay
758376921 432619768 578580897

5
Chapay likes Cleo
Anka likes Hexadecimal
Anka likes Chapay
Cleo likes Troll
Anka likes Cleo
299076810 225593528 36830738

13
Anka likes Cleo
Cleo likes Troll
Chapay likes Cleo
Snowy likes Troll
Chapay likes Anka
Chapay likes Snowy
Snowy likes Chapay
Anka likes Snowy
Snowy likes Dracul
Cleo likes Hexadecimal
Dracul likes Chapay
Anka likes Hexadecimal
Snowy likes Cleo
554338888 280967932 682619964

17
Hexadecimal likes Chapay
Chapay likes Snowy
Chapay likes Troll
Anka likes Hexadecimal
Cleo likes Troll
Snowy likes Cleo
Cleo likes Anka
Cleo likes Hexadecimal
Anka likes Snowy
Chapay likes Hexadecimal
Anka likes Cleo
Dracul likes Snowy
Chapay likes Anka
Troll likes Hexadecimal
Troll likes Anka
Anka likes Dracul
Hexadecimal likes Anka
828886798 548024213 166661324

2
Troll likes Cleo
Anka likes Cleo
14344913 559182022 405430772

22
Cleo likes Snowy
Cleo likes Troll
Chapay likes Dracul
Snowy likes Troll
Dracul likes Chapay
Dracul likes Snowy
Chapay likes Cleo
Snowy likes Chapay
Dracul likes Troll
Anka likes Hexadecimal
Snowy likes Anka
Hexadecimal likes Cleo
Hexadecimal likes Troll
Dracul likes Anka
Cleo likes Hexadecimal
Hexadecimal likes Dracul
Chapay likes Troll
Chapay likes Hexadecimal
Anka likes Snowy
Troll likes Hexadecimal
Snowy likes Hexadecimal
Anka likes Chapay
458053183 602148195 994999698

5
Troll likes Dracul
Anka likes Chapay
Cleo likes Anka
Chapay likes Cleo
Snowy likes Hexadecimal
222 400 400


[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]:
let mat be a logical matrix of size 7x7
in int function calc which takes string s
    let r = 0 = integer
    for i = 0 to 7 exlusive
        for j = 0 to 7 exclusive
            if s at i is same as s at j and mat at i and j is not 0 then increment r
        end of the block
    end of the block
    return r
end of the block
define the main function
    let n, ans, temp, lans, ltemp be int with ans = temp = lans = ltemp = INT_MAX
    read n
    let arr, t be long long arrays of size 3 both with all 0
    for i = 0 to 7 exclusive
        for j = 0 to 7 exclusive, set mat[i][j] to false
    let hero be a map form string to int
    set hero at "Anka" to 0
    set hero at "Chapay" to 1
    set hero["Cleo"] = 2
    set hero["Dracul"] to 3
    set hero["Dracul"] tp 4
    hero["Snowy"] = 5
    set hero at Hexadecimal = 6
    let x, y, z, q be strings
    for i = 0 to n exclusive
        read x, y, z
        set mat[hero[x]][hero[z]] to true
    end of the block
    read arr at 0, arra at 1, arr at 2
    sort the first 3 elements of arr
    let h be a set of strings
    let it be a set string iterator
    set t at 2 = arr[2] / 5
    t[1] = arr[1]
    set t at 0 to arr[0]
    sort the first 3 elements of t
    set temp to t[2] - t[0]
    if temp is less than ans
        set ans to temp
        call insert on h with arg "aaaaabc"
    end of the block
    set t at 2 = arr[2]/4
    set t at 1 = arr[1]/2
    set t at 0 to arr at 0
    sort the first three elements of arr
    set temp = t[2] - t[0]
    if temp is less than ans
        set ans to temp
        clear h
        insert "aaaabbc" in h
    else if temp is same as ans
        insert "aaaabbc" in h
    end of the block
    set t[2] = arr[2] / 3
    set t[1] = arr[1] / 3
    set t at 0 to arr at 0
    sort the first 3 elements of t
    set tempo to t[2] - t[0]
    if temp < ans
        set ans to temp
        clear h
        insert "aaaabbc" in h
    else if temp is same as ans
        insert "aaaabbc" in h
    end of the block
    set t[2] to arr[2] / 3
    set t[1] to arr[1] / 2
    set t[0] to arr[0] / 2
    sort the first 3 elements of t
    set temp to t[2] - t[0]
    if temp is less than ans
        set ans to temp
        clear h
        insert "aaabbcc" in h
    if temp = ans
        insert "aaabbcc" in h
    end of the block
    while h is not empty
        set q to be q * the first element of h
        do loop
            set ltemp to calc of q
            if ltemp is greater than lans then set lans to ltemp
        while the result of calling next_permutation with args start of q and end of q is not 0
        erase q from h
    end of the block
    print ans and space and lans
    return to indicate successful execution
end of the block

[CODE]:

bool mat[7][7];
int calc(string s) {
    int r = 0;
    for (int i = 0; i < 7; i++) {
        for (int j = 0; j < 7; j++) {
            if (s[i] == s[j] && mat[i][j]) r++;
        }
    }
    return r;
}
int main() {
    int n, ans = INT_MAX, temp = INT_MAX, lans = 0, ltemp = 0;
    cin >> n;
    long long arr[3], t[3] = {0, 0, 0};
    for (int i = 0; i < 7; i++)
        for (int j = 0; j < 7; j++) mat[i][j] = false;
    map<string, int> hero;
    hero["Anka"] = 0;
    hero["Chapay"] = 1;
    hero["Cleo"] = 2;
    hero["Troll"] = 3;
    hero["Dracul"] = 4;
    hero["Snowy"] = 5;
    hero["Hexadecimal"] = 6;
    string x, y, z, q;
    for (int i = 0; i < n; i++) {
        cin >> x >> y >> z;
        mat[hero[x]][hero[z]] = true;
    }
    cin >> arr[0] >> arr[1] >> arr[2];
    sort(arr, arr + 3);
    set<string> h;
    set<string>::iterator it;
    t[2] = arr[2] / 5;
    t[1] = arr[1];
    t[0] = arr[0];
    sort(t, t + 3);
    temp = t[2] - t[0];
    if (temp < ans) {
        ans = temp;
        h.insert("aaaaabc");
    }
    t[2] = arr[2] / 4;
    t[1] = arr[1] / 2;
    t[0] = arr[0];
    sort(t, t + 3);
    temp = t[2] - t[0];
    if (temp < ans) {
        ans = temp;
        h.clear();
        h.insert("aaaabbc");
    } else if (temp == ans) {
        h.insert("aaaabbc");
    }
    t[2] = arr[2] / 3;
    t[1] = arr[1] / 3;
    t[0] = arr[0];
    sort(t, t + 3);
    temp = t[2] - t[0];
    if (temp < ans) {
        ans = temp;
        h.clear();
        h.insert("aaabbbc");
    } else if (temp == ans) {
        h.insert("aaabbbc");
    }
    t[2] = arr[2] / 3;
    t[1] = arr[1] / 2;
    t[0] = arr[0] / 2;
    sort(t, t + 3);
    temp = t[2] - t[0];
    if (temp < ans) {
        ans = temp;
        h.clear();
        h.insert("aaabbcc");
    } else if (temp == ans) {
        h.insert("aaabbcc");
    }
    while (!h.empty()) {
        q = *(h.begin());
        do {
            ltemp = calc(q);
            if (ltemp > lans) lans = ltemp;
        } while (next_permutation(q.begin(), q.end()));
        h.erase(q);
    }
    cout << ans << " " << lans << endl;
    return 0;
}

3
Troll likes Dracul
Dracul likes Anka
Snowy likes Hexadecimal
210 200 180

2
Anka likes Chapay
Chapay likes Anka
10000 50 50

11
Snowy likes Dracul
Anka likes Dracul
Chapay likes Snowy
Hexadecimal likes Troll
Anka likes Cleo
Chapay likes Dracul
Anka likes Chapay
Snowy likes Troll
Anka likes Hexadecimal
Cleo likes Chapay
Troll likes Cleo
100 100 100

14
Chapay likes Cleo
Cleo likes Anka
Dracul likes Snowy
Snowy likes Cleo
Chapay likes Anka
Snowy likes Anka
Chapay likes Troll
Troll likes Anka
Anka likes Snowy
Chapay likes Dracul
Dracul likes Anka
Hexadecimal likes Chapay
Snowy likes Dracul
Cleo likes Dracul
15 15 15

4
Anka likes Cleo
Snowy likes Cleo
Anka likes Hexadecimal
Cleo likes Snowy
1 1 1

8
Snowy likes Anka
Hexadecimal likes Snowy
Troll likes Dracul
Hexadecimal likes Troll
Snowy likes Troll
Anka likes Snowy
Snowy likes Chapay
Anka likes Chapay
70 70 70

3
Chapay likes Hexadecimal
Anka likes Cleo
Troll likes Snowy
15 15000 90

13
Cleo likes Hexadecimal
Cleo likes Snowy
Hexadecimal likes Anka
Anka likes Snowy
Troll likes Snowy
Chapay likes Hexadecimal
Hexadecimal likes Snowy
Snowy likes Chapay
Troll likes Cleo
Anka likes Hexadecimal
Hexadecimal likes Cleo
Chapay likes Dracul
Snowy likes Dracul
1000000000 2000000000 1000000000

12
Cleo likes Hexadecimal
Chapay likes Anka
Hexadecimal likes Cleo
Anka likes Snowy
Anka likes Cleo
Dracul likes Snowy
Anka likes Troll
Snowy likes Anka
Cleo likes Anka
Hexadecimal likes Troll
Hexadecimal likes Chapay
Snowy likes Troll
1000000000 1 2000000000

2
Snowy likes Hexadecimal
Troll likes Dracul
2000000000 2000000000 2000000000

12
Snowy likes Chapay
Cleo likes Dracul
Hexadecimal likes Snowy
Hexadecimal likes Anka
Dracul likes Chapay
Cleo likes Troll
Dracul likes Snowy
Snowy likes Dracul
Troll likes Chapay
Dracul likes Anka
Chapay likes Hexadecimal
Troll likes Dracul
436364663 856574374 347564737

12
Anka likes Dracul
Dracul likes Troll
Cleo likes Troll
Snowy likes Hexadecimal
Hexadecimal likes Chapay
Cleo likes Dracul
Cleo likes Chapay
Hexadecimal likes Anka
Snowy likes Cleo
Hexadecimal likes Snowy
Cleo likes Snowy
Chapay likes Snowy
584329075 428752235 675234087

8
Anka likes Chapay
Dracul likes Snowy
Snowy likes Cleo
Cleo likes Anka
Cleo likes Troll
Hexadecimal likes Troll
Troll likes Cleo
Snowy likes Dracul
325432666 254352394 547360304

18
Snowy likes Troll
Chapay likes Hexadecimal
Cleo likes Snowy
Dracul likes Snowy
Snowy likes Chapay
Troll likes Cleo
Snowy likes Anka
Dracul likes Hexadecimal
Hexadecimal likes Anka
Anka likes Hexadecimal
Anka likes Chapay
Troll likes Anka
Anka likes Snowy
Anka likes Troll
Snowy likes Cleo
Hexadecimal likes Troll
Hexadecimal likes Dracul
Cleo likes Anka
20000 1000 20000

6
Chapay likes Troll
Troll likes Cleo
Cleo likes Troll
Chapay likes Snowy
Anka likes Snowy
Troll likes Dracul
987499608 272739716 133573597

6
Anka likes Troll
Troll likes Chapay
Troll likes Hexadecimal
Hexadecimal likes Cleo
Snowy likes Hexadecimal
Chapay likes Troll
740076959 230477703 987799796

17
Cleo likes Dracul
Troll likes Cleo
Anka likes Chapay
Anka likes Troll
Chapay likes Snowy
Troll likes Snowy
Chapay likes Dracul
Hexadecimal likes Snowy
Dracul likes Snowy
Troll likes Hexadecimal
Hexadecimal likes Anka
Cleo likes Snowy
Hexadecimal likes Dracul
Snowy likes Chapay
Snowy likes Hexadecimal
Snowy likes Dracul
Dracul likes Troll
112909524 619275170 403563648

18
Anka likes Troll
Dracul likes Chapay
Hexadecimal likes Dracul
Chapay likes Dracul
Anka likes Hexadecimal
Snowy likes Cleo
Dracul likes Anka
Snowy likes Anka
Snowy likes Hexadecimal
Dracul likes Troll
Dracul likes Snowy
Hexadecimal likes Anka
Chapay likes Hexadecimal
Snowy likes Dracul
Cleo likes Snowy
Chapay likes Cleo
Anka likes Dracul
Troll likes Anka
838821770 712931449 361810998

18
Hexadecimal likes Chapay
Troll likes Dracul
Troll likes Snowy
Cleo likes Dracul
Chapay likes Snowy
Dracul likes Chapay
Cleo likes Snowy
Dracul likes Hexadecimal
Troll likes Anka
Anka likes Troll
Hexadecimal likes Dracul
Chapay likes Hexadecimal
Cleo likes Chapay
Anka likes Hexadecimal
Snowy likes Dracul
Chapay likes Troll
Anka likes Snowy
Dracul likes Cleo
240256138 922743697 38909902

16
Chapay likes Snowy
Hexadecimal likes Anka
Chapay likes Troll
Dracul likes Cleo
Troll likes Hexadecimal
Hexadecimal likes Dracul
Chapay likes Cleo
Snowy likes Cleo
Snowy likes Anka
Troll likes Chapay
Snowy likes Hexadecimal
Troll likes Snowy
Cleo likes Hexadecimal
Anka likes Snowy
Snowy likes Chapay
Anka likes Dracul
843382501 58524777 503038818

5
Troll likes Chapay
Anka likes Snowy
Anka likes Dracul
Chapay likes Anka
Snowy likes Troll
709201888 431802832 597079932

18
Cleo likes Snowy
Snowy likes Hexadecimal
Cleo likes Hexadecimal
Troll likes Dracul
Hexadecimal likes Snowy
Dracul likes Troll
Chapay likes Anka
Chapay likes Cleo
Troll likes Chapay
Hexadecimal likes Chapay
Anka likes Snowy
Troll likes Snowy
Dracul likes Snowy
Dracul likes Chapay
Chapay likes Troll
Cleo likes Troll
Hexadecimal likes Cleo
Anka likes Chapay
864225278 509037060 402199775

12
Cleo likes Hexadecimal
Troll likes Cleo
Anka likes Cleo
Hexadecimal likes Troll
Anka likes Snowy
Hexadecimal likes Anka
Troll likes Hexadecimal
Troll likes Anka
Dracul likes Cleo
Cleo likes Troll
Dracul likes Troll
Chapay likes Anka
762445890 377707484 324080158

21
Chapay likes Dracul
Snowy likes Chapay
Snowy likes Troll
Cleo likes Chapay
Cleo likes Troll
Chapay likes Cleo
Snowy likes Anka
Dracul likes Anka
Troll likes Snowy
Snowy likes Cleo
Chapay likes Hexadecimal
Cleo likes Anka
Cleo likes Snowy
Hexadecimal likes Cleo
Hexadecimal likes Snowy
Hexadecimal likes Anka
Hexadecimal likes Troll
Anka likes Snowy
Dracul likes Troll
Chapay likes Anka
Snowy likes Hexadecimal
482557397 502108264 750230216

6
Troll likes Chapay
Hexadecimal likes Snowy
Cleo likes Dracul
Cleo likes Anka
Chapay likes Anka
Anka likes Chapay
758376921 432619768 578580897

5
Chapay likes Cleo
Anka likes Hexadecimal
Anka likes Chapay
Cleo likes Troll
Anka likes Cleo
299076810 225593528 36830738

13
Anka likes Cleo
Cleo likes Troll
Chapay likes Cleo
Snowy likes Troll
Chapay likes Anka
Chapay likes Snowy
Snowy likes Chapay
Anka likes Snowy
Snowy likes Dracul
Cleo likes Hexadecimal
Dracul likes Chapay
Anka likes Hexadecimal
Snowy likes Cleo
554338888 280967932 682619964

17
Hexadecimal likes Chapay
Chapay likes Snowy
Chapay likes Troll
Anka likes Hexadecimal
Cleo likes Troll
Snowy likes Cleo
Cleo likes Anka
Cleo likes Hexadecimal
Anka likes Snowy
Chapay likes Hexadecimal
Anka likes Cleo
Dracul likes Snowy
Chapay likes Anka
Troll likes Hexadecimal
Troll likes Anka
Anka likes Dracul
Hexadecimal likes Anka
828886798 548024213 166661324

2
Troll likes Cleo
Anka likes Cleo
14344913 559182022 405430772

22
Cleo likes Snowy
Cleo likes Troll
Chapay likes Dracul
Snowy likes Troll
Dracul likes Chapay
Dracul likes Snowy
Chapay likes Cleo
Snowy likes Chapay
Dracul likes Troll
Anka likes Hexadecimal
Snowy likes Anka
Hexadecimal likes Cleo
Hexadecimal likes Troll
Dracul likes Anka
Cleo likes Hexadecimal
Hexadecimal likes Dracul
Chapay likes Troll
Chapay likes Hexadecimal
Anka likes Snowy
Troll likes Hexadecimal
Snowy likes Hexadecimal
Anka likes Chapay
458053183 602148195 994999698

5
Troll likes Dracul
Anka likes Chapay
Cleo likes Anka
Chapay likes Cleo
Snowy likes Hexadecimal
222 400 400


[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 const long long integer mod = 1e9 + 9
declare mod_pow taking in long long ints x and n and returning long long integer
    make long long res = 1
    while n is greater than 0
        if n & 1 is truthy, set res to res * x % mod
        set x to x * x % mod
        move bits of n 1 place to right
    end of the block
    return res
end of the block
declare extgcd taking in long long ints a, b, &x, and &y and returning long long integer
    make long long int d = a
    if b is not 0
        set d to extgcd(b, a % b, y, x)
        set y to y - (a / b) * x
    else do
        set x to 1
        set y to 0
    end of the block
    return d
end of the block
declare mod_inverse taking in long long a and returning long long int
    create long long ints x, y, and m
    set m to mod
    call extgcd(a, m, x, y)
    return the result of (m + x % m) % m
end of the block
define the main function
    make long long ints n, a, b, k, ans, temp, rec, and q
    make string s
    read n, a, b, and k
    read s
    set ans to 0
    for i = 0 to k exclusive
        set temp to (mod_pow(a, n - i) * mod_pow(b, i)) % mod
        if s[i] is equal to '+'
            set ans to (ans + temp) % mod
        else do
            set ans to (ans - temp) % mod
        if ans is less than 0, set ans to ans + mod
    end of the block
    if n + 1 is k
        print ans
        return to indicate successful execution
    end of the block
    set rec to (n + 1) / k
    set q to mod_pow((mod_inverse(a) * b) % mod, k) % mod
    if q is equal to 1
        set ans to (ans * rec) % mod
    otherwise
        set ans to ((ans * (mod_pow(q, rec) - 1) % mod) * mod_inverse(q - 1)) % mod
    display ans
    return to indicate successful execution
end of the block

[CODE]:

const long long mod = 1e9 + 9;
long long mod_pow(long long x, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
long long extgcd(long long a, long long b, long long &x, long long &y) {
    long long d = a;
    if (b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    } else {
        x = 1;
        y = 0;
    }
    return d;
}
long long mod_inverse(long long a) {
    long long x, y, m;
    m = mod;
    extgcd(a, m, x, y);
    return (m + x % m) % m;
}
int main() {
    long long n, a, b, k, ans, temp, rec, q;
    string s;
    cin >> n >> a >> b >> k;
    cin >> s;
    ans = 0;
    for (int i = 0; i < k; i++) {
        temp = (mod_pow(a, n - i) * mod_pow(b, i)) % mod;
        if (s[i] == '+')
            ans = (ans + temp) % mod;
        else
            ans = (ans - temp) % mod;
        if (ans < 0) ans += mod;
    }
    if (n + 1 == k) {
        cout << ans << endl;
        return 0;
    }
    rec = (n + 1) / k;
    q = mod_pow((mod_inverse(a) * b) % mod, k) % mod;
    if (q == 1)
        ans = (ans * rec) % mod;
    else
        ans = ((ans * (mod_pow(q, rec) - 1) % mod) * mod_inverse(q - 1)) % mod;
    cout << ans << endl;
    return 0;
}


[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 N = 2e5 + 10
declare long long integers n, a, b, k, MOD = 1e9 + 9
declare fast_power with long longs base, power as arguments, returning long long
    declare long long result = 1
    while power is greater than 0
        if power % 2 is 1, let result be (result * base) % MOD
        let base be (base * base) % MOD
        let power be power / 2
    end of the block
    return result from function
end of the block
define the main function
    read n, a, b, k
    declare string s
    read s
    declare integer l = (n + 1) / k - 1
    declare long long integer val = (b * result of run fast_power(a, MOD - 2)) % MOD
    declare long long integer valp = result of run fast_power(val, k)
    declare long long integer ans = 0
    declare long long integer geo
    if valp is not 1
        let geo be (result of run fast_power(valp, l + 1) - 1) % MOD + MOD
        let geo be geo * result of run fast_power((valp - 1) % MOD + MOD, MOD - 2) % MOD
        let geo be geo % MOD
    else
        let geo be l + 1
    for i = 0 to k exclusive
        declare long long integer calc = result of run fast_power(b, i) * result of run fast_power(a, n - i) % MOD
        if s[i] is '-'
            let ans be (ans - (geo * calc % MOD)) % MOD + MOD
        else
            let ans be (ans + (geo * calc % MOD) % MOD)
        let ans be ans % MOD
    end of the block
    print ans and newline
    return to indicate successful execution
end of the block

[CODE]:

const int N = 2e5 + 10;
long long int n, a, b, k, MOD = 1e9 + 9;
long long fast_power(long long base, long long power) {
    long long result = 1;
    while (power > 0) {
        if (power % 2 == 1) { result = (result * base) % MOD; }
        base = (base * base) % MOD;
        power = power / 2;
    }
    return result;
}
int main() {
    cin >> n >> a >> b >> k;
    string s;
    cin >> s;
    int l = (n + 1) / k - 1;
    long long int val = (b * fast_power(a, MOD - 2)) % MOD;
    long long int valp = fast_power(val, k);
    long long int ans = 0;
    long long int geo;
    if (valp != 1) {
        geo = (fast_power(valp, l + 1) - 1) % MOD + MOD;
        geo = geo * fast_power((valp - 1) % MOD + MOD, MOD - 2) % MOD;
        geo %= MOD;
    } else
        geo = l + 1;
    for (int i = 0; i < k; i++) {
        long long int calc = fast_power(b, i) * fast_power(a, n - i) % MOD;
        if (s[i] == '-')
            ans = (ans - (geo * calc % MOD)) % MOD + MOD;
        else
            ans = (ans + (geo * calc % MOD) % MOD);
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


[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 new long long variable mod with value 1e9+9
new array of characters s with size 500005
long long function power with long long arguments a and b
    create long long variable ret = 1
    change a to a modulo mod
    while b is not 0
        if b & 1 is not 0, change ret to ret * a % mod
        change a to a squared modulo mod
        set b to b >> 1
    end of the block
    return ret
end of the block
define the main function
    declare long long variables n, a, b and k
    read n, a, b and k from the user input
    read input an store it into s
    read input into s
    declare new long long called t with value (n + 1) / k
    declare new long long u = power(b, k) * power(power(a, k), mod - 2) % mod
    assign (power(u, t) + mod - 1) % mod * power(u - 1 + mod, mod - 2) % mod to t
    if u = 1, assign (n + 1) / k to t
    declare long long variable with name ans with value 0
    for i = 0 to k exclusive incrementing i
        declare long long variable tmp
        assign the new value = power(a, n - i) * power(b, i) % mod
        assign tmp * t % mod to tmp
        if s[i] = '+'
            change the value of ans to (ans + tmp) % mod
        else
            change ans to ans - tmp + mod
            change the value of ans to ans modulo mod
        end of the block
    end of the block
    print ans
    return to indicate successful execution
end of the block

[CODE]:

long long mod = 1e9 + 9;
char s[500005];
long long power(long long a, long long b) {
    long long ret = 1;
    a %= mod;
    while (b) {
        if (b & 1) ret = ret * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ret;
}
int main() {
    long long n, a, b, k;
    cin >> n >> a >> b >> k;
    gets(s);
    gets(s);
    long long t = (n + 1) / k;
    long long u = power(b, k) * power(power(a, k), mod - 2) % mod;
    t = (power(u, t) + mod - 1) % mod * power(u - 1 + mod, mod - 2) % mod;
    if (u == 1) t = (n + 1) / k;
    long long ans = 0;
    for (int i = 0; i < k; ++i) {
        long long tmp;
        tmp = power(a, n - i) * power(b, i) % mod;
        tmp = tmp * t % mod;
        if (s[i] == '+') {
            ans = (ans + tmp) % mod;
        } else {
            ans = ans - tmp + mod;
            ans %= mod;
        }
    }
    cout << ans << endl;
    return 0;
}


[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 integer MOD = 1000000009
into the function pw which takes two long long integers a and b and returns a long long integer
    if b is 0 then return 1
    if b is 1 then return a % MOD
    if b%2 is true
        create long long rs= pw(a,b-1)
        return (rs * a) % MOD
    end of the block
    create long long integer rs= pw(a,b/2)
    return (rs * rs) % MOD
end of the block
sm = long long integer vector
into the function solve which takes a and b
    if b is 0 then return 0
    for i=0 to 35 exclusive
        create long long integer ba = (1LL << i) & b
        if ba is equal to 0 then continue
        return sm[i] + solve(a, b - (1LL << i)) * pw(a, (1LL << i))) % MOD
    end of the block
end of the block
define the main function
    n,a,b,k = long long integers
    read n,a,b,k
    s=string
    read s
    create long long integers X and Y with values 1
    for i=o to k exclusive
        set X = X * b
        set X = X % MOD
    end of the block
    for i=0 to k exclusive
        set Y = Y * a
        set Y = Y % MOD
    end of the block
    set X = X * pw(Y, MOD - 2)
    set X = X % MOD
    add 1 to the end of sm
    for i=0 to 40 exclusive
        add sm.back() + sm.back() * pw(X, (1LL << i) to end of sm
        set sm.back() = sm.back() % MOD
    end of the block
    create long long integer st = solve(X, (n + 1) / k)
    create long long integer ans=0
    for i=0 to k exclusive
        create long long integer rs = (pw(b, i) * pw(a, n - i)) % MOD
        if s[i] is '-' then set rs = rs * -1
        set rs = rs * st
        set ans = ans + rs
        set ans = ans % MOD
    end of the block
    if ans is less than 0 then set ans = ans + MOD
    print ans
end of the block

[CODE]:

long long MOD = 1000000009;
long long pw(long long a, long long b) {
    if (b == 0) return 1;
    if (b == 1) return a % MOD;
    if (b % 2) {
        long long rs = pw(a, b - 1);
        return (rs * a) % MOD;
    }
    long long rs = pw(a, b / 2);
    return (rs * rs) % MOD;
}
vector<long long> sm;
long long solve(long long a, long long b) {
    if (b == 0) return 0;
    for (long long i = 0; i < 35; i++) {
        long long ba = (1LL << i) & b;
        if (ba == 0) continue;
        return (sm[i] + solve(a, b - (1LL << i)) * pw(a, (1LL << i))) % MOD;
    }
}
int main() {
    long long n, a, b, k;
    cin >> n >> a >> b >> k;
    string s;
    cin >> s;
    long long X = 1, Y = 1;
    for (long long i = 0; i < k; i++) {
        X *= b;
        X %= MOD;
    }
    for (long long i = 0; i < k; i++) {
        Y *= a;
        Y %= MOD;
    }
    X *= pw(Y, MOD - 2);
    X %= MOD;
    sm.push_back(1);
    for (long long i = 0; i < 40; i++) {
        sm.push_back(sm.back() + sm.back() * pw(X, (1LL << i)));
        sm.back() %= MOD;
    }
    long long st = solve(X, (n + 1) / k);
    long long ans = 0;
    for (long long i = 0; i < k; i++) {
        long long rs = (pw(b, i) * pw(a, n - i)) % MOD;
        if (s[i] == '-') rs *= -1;
        rs *= st;
        ans += rs;
        ans %= MOD;
    }
    if (ans < 0) ans += MOD;
    cout << ans << endl;
}


[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]:
make long long int mod = 1e9 + 9
create ints d, x, and y
declare fastexp taking in long long ints b and p and returning long long integer
    if p is 0, return 1
    create long long int ans = fastexp(b, p / 2) % mod
    if p modulo 2 is truthy
        return the result of ((1LL * b * ans % mod) * 1LL * ans) % mod
    else do
        return the result of (1LL * ans * ans + mod) % mod
end of the block
define the main function
    make long long ints a, n, b, and k
    create string s
    make long long integers v1, v2, v3, and sum = 0
    read n, a, b, and k
    read s
    for h = 0 to k exclusive
        if s[h] equals '+'
            set v1 to fastexp(a, n - h) % mod
            set v2 to fastexp(b, h) % mod
            set v3 to (v1 * v2 + mod) % mod
            set sum to (sum % mod + v3 % mod + mod) % mod
        else do
            set v1 to fastexp(a, n - h)
            set v2 to return value of fastexp(b, h)
            set v3 to (v1 * v2 + mod) % mod
            set sum to (sum % mod - v3 % mod + mod) % mod
        end of the block
    end of the block
    create long long int v1 = (n + 1) / k
    make long long integer inv_a = fastexp(a, mod - 2) % mod
    make long long integer vv = ((inv_a % mod) * (b % mod) + mod) % mod
    let long long integer vl1 = ((fastexp(vv, k) % mod)) % mod
    if vl1 is 1
        create long long int ans = ((v1 * sum) + mod) % mod
        display ans
        return to indicate successful execution
    end of the block
    create long long integer vl4 = fastexp(vl1, vl) % mod
    set vl4 to (vl4 - 1 + mod) % mod
    set vl4 to (vl4 * sum + mod) % mod
    make long long integer vl2 = (((vl1 + mod) % mod) - 1 + mod) % mod
    create long long integer vl3 = (vl4 * (fastexp(vl2, mod - 2)) + mod) % mod
    print the result of vl3 % mod
end of the block

[CODE]:

long long int mod = 1e9 + 9;
int d, x, y;
long long int fastexp(long long int b, long long int p) {
    if (p == 0) return 1;
    long long int ans = fastexp(b, p / 2) % mod;
    if (p % 2)
        return ((1LL * b * ans % mod) * 1LL * ans) % mod;
    else
        return (1LL * ans * ans + mod) % mod;
}
int main() {
    long long int a, n, b, k;
    string s;
    long long int v1, v2, v3, sum = 0;
    cin >> n >> a >> b >> k;
    cin >> s;
    for (int h = 0; h < k; h++) {
        if (s[h] == '+') {
            v1 = fastexp(a, n - h) % mod;
            v2 = fastexp(b, h) % mod;
            v3 = (v1 * v2 + mod) % mod;
            sum = (sum % mod + v3 % mod + mod) % mod;
        } else {
            v1 = fastexp(a, n - h);
            v2 = fastexp(b, h);
            v3 = (v1 * v2 + mod) % mod;
            sum = (sum % mod - v3 % mod + mod) % mod;
        }
    }
    long long int vl = (n + 1) / k;
    long long int inv_a = fastexp(a, mod - 2) % mod;
    long long int vv = ((inv_a % mod) * (b % mod) + mod) % mod;
    long long int vl1 = ((fastexp(vv, k) % mod)) % mod;
    if (vl1 == 1) {
        long long int ans = ((vl * sum) + mod) % mod;
        cout << ans << endl;
        return 0;
    }
    long long int vl4 = fastexp(vl1, vl) % mod;
    vl4 = (vl4 - 1 + mod) % mod;
    vl4 = (vl4 * sum + mod) % mod;
    long long int vl2 = (((vl1 + mod) % mod) - 1 + mod) % mod;
    long long int vl3 = (vl4 * (fastexp(vl2, mod - 2)) + mod) % mod;
    cout << vl3 % mod << endl;
}


[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]:
MAXN = constant integer = 100000
MOD = constant long long = 1000000009
in function poww_mod with arguments long long a and long long b that returns long long
    ans = long long = 1
    a = a modulo MOD
    while b is nonzero
        if b ends in a one in bits, then ans = (a * ans) modulo MOD
        a = (a * a) modulo MOD
        b shifted by one bit to the right
    end of the block
    return ans modulo MOD
end of the block
in function inv with arguments of long long t and long long p that returns a long long
    t = t modulo p
    return 1 if t is 1 else return (p - p / t) * (call inv with arguments of p modulo t and p) modulo p
end of the block
n = integer = 0, k = integer = 0, a = integer = 0, b = integer = 0
ans = long long array of size MAX + 5, answer = long long = 0
s = string
define the main function
    read n, a, b, k
    read s
    pre = long long = 0
    while k < 10000 and k < n
        k = k * 2
        s = s + s
    end of the block
    for i = 0 to k exclusive
        if s[i] is +
            ans[i] = pre + (call poww_mod with arguments of a, n - i) * (call poww_mod with arguments of b, i) modulo MOD
        else
            ans[i] = pre - (call poww_mod with arguments of a, n - i) * (call poww_mod with arguments of b, i) modulo MOD
        pre = ans[i]
    end of the block
    if n < k
        if ans[n] < 0, then ans[n] = ans[n] + mod
        print ans[n]
    else
        beishu = integer = n / k
        save = integer = n - n / k
        mode = long long =(call poww_mod with arguments of b, k) * (inverse of arguments of (the result of calling poww_mod with arguments of a, k), i) MOD )modulo MOD
        answer = pre
        for i = 1 to beishu exclusive
            pre = (pre * mode) modulo MOD
            answer = (answer + pre) modulo MOD
        end of the block
        for i = n / k * k to n inclusive
            if s[i modulo k] is +
                answer = (answer + (call poww_mod with arguments of a, n - i) * (call poww_mod with arguments of b, i)) modulo MOD
            else
                answer = (answer - (call poww_mod with arguments of a, n - i) * (call poww_mod with arguments of b, i)) modulo MOD
        end of the block
        if answer < 0, then answer = answer + MOD
        print answer
    end of the block
end of the block

[CODE]:

const int MAXN = 100000;
const long long MOD = 1000000009;
long long poww_mod(long long a, long long b) {
    long long ans = 1;
    a = a % MOD;
    while (b) {
        if (b & 1) ans = (a * ans) % MOD;
        a = (a * a) % MOD;
        b >>= 1;
    }
    return ans % MOD;
}
long long inv(long long t, long long p) {
    t = t % p;
    return t == 1 ? 1 : (p - p / t) * inv(p % t, p) % p;
}
int n = 0, k = 0, a = 0, b = 0;
long long ans[MAXN + 5], answer = 0;
string s;
int main() {
    cin >> n >> a >> b >> k;
    cin >> s;
    long long pre = 0;
    while (k < 10000 && k < n) {
        k = k * 2;
        s = s + s;
    }
    for (int i = 0; i < k; ++i) {
        if (s[i] == '+')
            ans[i] = (pre + poww_mod(a, n - i) * poww_mod(b, i)) % MOD;
        else
            ans[i] = (pre - poww_mod(a, n - i) * poww_mod(b, i)) % MOD;
        pre = ans[i];
    }
    if (n < k) {
        if (ans[n] < 0) ans[n] += MOD;
        cout << ans[n] << endl;
    } else {
        int beishu = n / k;
        int save = n - n / k;
        long long mode = (poww_mod(b, k) * inv(poww_mod(a, k), MOD)) % MOD;
        answer = pre;
        for (int i = 1; i < beishu; ++i) {
            pre = (pre * mode) % MOD;
            answer = (answer + pre) % MOD;
        }
        for (int i = (n / k) * k; i <= n; ++i) {
            if (s[i % k] == '+')
                answer = (answer + poww_mod(a, n - i) * poww_mod(b, i)) % MOD;
            else
                answer = (answer - poww_mod(a, n - i) * poww_mod(b, i)) % MOD;
        }
        if (answer < 0) answer += MOD;
        cout << answer << endl;
    }
}