#include <string> #include <algorithm> #include <vector> #include <iostream> #include <iterator> #include <cassert> #include <cstring> #include <cstdlib> using namespace std; #undef _DEBUG int main() { int n; cin >> n; while(cin.get() != '/n') {} while(n-- > 0) { string text; string word; getline(cin, text); getline(cin, word); #ifdef _DEBUG cout << "text = " << text << "/n"; cout << "word = " << word << "/n"; #endif vector <char> ans; int i = -1; while(true) { while(++i < text.size() && text[i] == ' ') {} if(i >= text.size()) { break; } int k = i; while(++k < text.size() && text[k] != ' ') {} #ifdef _DEBUG cout << "i = " << i << "/n"; cout << "k = " << k << "/n"; #endif if(k - i == word.size()) { int d = (text[i] - word[0] + 26) % 26; bool ok = true; for(int m=0; m<word.size() && ok; ++m) { if((text[i + m] - d + 26 - 'a') % 26 + 'a' != word[m]) { ok = false; } } if(ok) { ans.push_back('a' + d); } } i = k; } sort(ans.begin(), ans.end()); copy(ans.begin(), ans.end(), ostream_iterator <char> (cout)); cout << "/n"; } return 0; }