#include #include #include #include #include using namespace std; void makeGraph(vector wlist, int map[][200]); int getDist(string a, string b); int bfs(int map[][200], int start, int dest, int s); int main(){ int tc; cin>>tc; while(tc--){ string w=""; vector wlist; int map[200][200] = {0}; cin>>w; while(w!="*"){ wlist.push_back(w); cin>>w; } makeGraph(wlist, map); cin.ignore(); string line, s1, s2; getline(cin, line); while(line!=""){ int l1, l2; /* indices to words in map */ istringstream iss(line); iss>>s1>>s2; for(int i=0; i0) cout< q; int pred[200], n; bool visited[200] = {false}; q.push(start); while(!q.empty()){ n = q.front(); q.pop(); for(int i=0; i wlist, int map[][200]){ for(int i=0; i b.length()){ longer = a; shorter = b; } else{ /* Also accounts for equal length */ longer = b; shorter = a; } dist += longer.length() - shorter.length(); for(int i=0; i