[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 map of strings to integers M
create 2d array of booleans like with size 7 by 7
declare strings s1, s2 and temp
create integer n and integer array g with size 3
create an array of integers team with size 3
create an array of integers heros with size 7
create integer b1 = INT_MAX and b2= -1
void function back_track with int argument a
    declare integers i and j
    if a is equal to 7
        declare an array of integers count with elements 0, 0, 0
        create ints mx = - and mn = INT_MAX
        for i = 0 to 7 exclusive increment count[heros[i]]
        if count[0], count[1] or count[2] = 0, return
        for i from 0 to 7 exclusive
            declare integer temp = g[heros[i]] / count[heros[i]]
            change mx to max of mx and temp
            change mn to min of mn and temp
        end of the block
        if mx - mn is greater than b1, return
        create int likeNum = 0
        loop i from 0 to 7 exclusive
            loop j from 0 to 7 exclusive
                if heros[i] = heros[j] and like[i][j] != 0, increment likeNum by one
        if mx - mn < b1 or mx - mn = b1and likeNum > b2
            set b1 to mx - mn
            set b2 to likeNum
        end of the block
        return
    end of the block
    loop i from 0 to 3 exclusive
        change heros[a] to i
        call back_track(a + 1)
    end of the block
end of the block
define the main function
    assign 0 to M["Anka"]
    assign 1 to M["Chapay"]
    assign 2 to M["Cleo"]
    assign 3 to M["Troll"]
    assign 4 to M["Dracul"]
    assign 5 to M["Snowy"]
    assign 6 to M["Hexadecimal"]
    loop i from 0 to 7 exclusive
        loop j from 0 to 7 exclusive, change like[i][j] to false
    read n
    while n != 0, decrement it and continue the loop
        read input to s1, temp and s2
        set value of like[M[s1]][M[s2]] to true
    end of the block
    read g[0], g[1] and g[2]
    call back_track(0)
    print b1, ' ' and b2
    return to indicate successful execution
end of the block

[CODE]:

map<string, int> M;
bool like[7][7];
string s1, s2, temp;
int n, g[3];
int team[3];
int heros[7];
int b1 = INT_MAX, b2 = -1;
void back_track(int a) {
    int i, j;
    if (a == 7) {
        int count[3] = {0, 0, 0};
        int mx = -1, mn = INT_MAX;
        for (i = 0; i < 7; i++) count[heros[i]]++;
        if (count[0] == 0 || count[1] == 0 || count[2] == 0) return;
        for (i = 0; i < 7; i++) {
            int temp = g[heros[i]] / count[heros[i]];
            mx = max(mx, temp);
            mn = min(mn, temp);
        }
        if (mx - mn > b1) return;
        int likeNum = 0;
        for (i = 0; i < 7; i++)
            for (j = 0; j < 7; j++)
                if (heros[i] == heros[j] && like[i][j]) likeNum++;
        if ((mx - mn) < b1 || (mx - mn) == b1 && likeNum > b2) {
            b1 = mx - mn;
            b2 = likeNum;
        }
        return;
    }
    for (i = 0; i < 3; i++) {
        heros[a] = i;
        back_track(a + 1);
    }
}
int main() {
    M["Anka"] = 0;
    M["Chapay"] = 1;
    M["Cleo"] = 2;
    M["Troll"] = 3;
    M["Dracul"] = 4;
    M["Snowy"] = 5;
    M["Hexadecimal"] = 6;
    for (int i = 0; i < 7; i++)
        for (int j = 0; j < 7; j++) like[i][j] = false;
    cin >> n;
    while (n--) {
        cin >> s1 >> temp >> s2;
        like[M[s1]][M[s2]] = true;
    }
    cin >> g[0] >> g[1] >> g[2];
    back_track(0);
    cout << b1 << ' ' << b2 << endl;
    return 0;
}