[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;
    }
}