#include <string>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> solution(vector<string> name, vector<int> yearning, vector<vector<string>> photo)
{
vector<int> answer;
int sum;
int i, j, k;
for(i = 0; i < photo.size(); i++)
{
sum = 0;
for(j = 0; j < name.size(); j++)
{
auto it = find(photo[i].begin(), photo[i].end(), name[j]);
if(it != photo[i].end())
{
sum += yearning[j];
}
}
answer.push_back(sum);
}
return answer;
}