#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <functional>
#include <complex>
#include <queue>
#include <stack>
#include <cmath>
#include <cassert>
#include <cstring>
using namespace std;
typedef long long LL;
typedef complex<double> CMP;

class InternetSecurity { public:
	vector <string> determineWebsite(vector <string> address, vector <string> keyword, vector <string> dangerous, int threshold) 
	{
		int N = address.size();

		vector< set<string> > kwd(N);
		for(int i=0; i<N; ++i) {
			stringstream ss(keyword[i]);
			for(string s; ss >> s; )
				kwd[i].insert(s);
		}

		set<string> dng(dangerous.begin(), dangerous.end());

		vector<bool> is_danger(N);

		bool changed = true;
		while( changed )
		{
			changed = false;
			for(int i=0; i<N; ++i)
				if( !is_danger[i] )
				{
					vector<string> buf;
					set_intersection( kwd[i].begin(), kwd[i].end(), dng.begin(), dng.end(), back_inserter(buf) );
					if( buf.size() >= threshold )
					{
						changed = true;
						dng.insert(kwd[i].begin(), kwd[i].end());
						is_danger[i] = true;
					}
				}
		}

		vector<string> result;
		for(int i=0; i<N; ++i)
			if( is_danger[i] )
				result.push_back( address[i] );
		return result;
	}
};

// BEGIN CUT HERE
#include <ctime>
double start_time; string timer()
 { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v)
 { os << "{ ";
   for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it)
   os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; }
void verify_case(const vector <string>& Expected, const vector <string>& Received) {
 bool ok = (Expected == Received);
 if(ok) cerr << "PASSED" << timer() << endl;  else { cerr << "FAILED" << timer() << endl;
 cerr << "\to: " << Expected << endl << "\tx: " << Received << endl; } }
#define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock();
#define END	 verify_case(_, InternetSecurity().determineWebsite(address, keyword, dangerous, threshold));}
int main(){

CASE(0)
	string address_[] = {"www.topcoder.com",
"www.sindicate_of_evil.com",
"www.happy_citizens.com"};
	  vector <string> address(address_, address_+sizeof(address_)/sizeof(*address_)); 
	string keyword_[] = {"hack encryption decryption internet algorithm",
"signal interference evil snake poison algorithm",
"flower baloon topcoder blue sky sea"};
	  vector <string> keyword(keyword_, keyword_+sizeof(keyword_)/sizeof(*keyword_)); 
	string dangerous_[] = {"hack","encryption","decryption","interference","signal","internet"};
	  vector <string> dangerous(dangerous_, dangerous_+sizeof(dangerous_)/sizeof(*dangerous_)); 
	int threshold = 3; 
	string __[] = {"www.topcoder.com", "www.sindicate_of_evil.com" };
	  vector <string> _(__, __+sizeof(__)/sizeof(*__)); 
END
CASE(1)
	string address_[] = {"brokenlink","flowerpower.net","purchasedomain.com"};
	  vector <string> address(address_, address_+sizeof(address_)/sizeof(*address_)); 
	string keyword_[] = {"broken","rose tulips","cheap free domain biggest greatest"};
	  vector <string> keyword(keyword_, keyword_+sizeof(keyword_)/sizeof(*keyword_)); 
	string dangerous_[] = {"biggest","enemy","hideout"};
	  vector <string> dangerous(dangerous_, dangerous_+sizeof(dangerous_)/sizeof(*dangerous_)); 
	int threshold = 2; 
	vector <string> _; 
END
CASE(2)
	string address_[] = {"a..a.ab.","...aa.b"};
	  vector <string> address(address_, address_+sizeof(address_)/sizeof(*address_)); 
	string keyword_[] = {"a bc def","def ghij klmno"};
	  vector <string> keyword(keyword_, keyword_+sizeof(keyword_)/sizeof(*keyword_)); 
	string dangerous_[] = {"a","b","c","d","e"};
	  vector <string> dangerous(dangerous_, dangerous_+sizeof(dangerous_)/sizeof(*dangerous_)); 
	int threshold = 1; 
	string __[] = {"a..a.ab.", "...aa.b" };
	  vector <string> _(__, __+sizeof(__)/sizeof(*__)); 
END
CASE(3)
	string address_[] = {"www.tsa.gov"};
	  vector <string> address(address_, address_+sizeof(address_)/sizeof(*address_)); 
	string keyword_[] = {"information assurance signal intelligence research"};
	  vector <string> keyword(keyword_, keyword_+sizeof(keyword_)/sizeof(*keyword_)); 
	string dangerous_[] = {"signal","assurance","penguin"};
	  vector <string> dangerous(dangerous_, dangerous_+sizeof(dangerous_)/sizeof(*dangerous_)); 
	int threshold = 2; 
	string __[] = {"www.tsa.gov" };
	  vector <string> _(__, __+sizeof(__)/sizeof(*__)); 
END
CASE(4)
string address_[] = {"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""};
	  vector <string> address(address_, address_+sizeof(address_)/sizeof(*address_)); 
	  string keyword_[] = {"a b c d e f g h i j k l m n o p q r s t u v w x y",
		  "A B C D E F G H I J K L M N O P Q R S T U V W X Y","a b c d e f g h i j k l m n o p q r s t u v w x y","a b c d e f g h i j k l m n o p q r s t u v w x y","a b c d e f g h i j k l m n o p q r s t u v w x y","a b c d e f g h i j k l m n o p q r s t u v w x y","a b c d e f g h i j k l m n o p q r s t u v w x y","a b c d e f g h i j k l m n o p q r s t u v w x y","a b c d e f g h i j k l m n o p q r s t u v w x y","a b c d e f g h i j k l m n o p q r s t u v w x y","a b c d e f g h i j k l m n o p q r s t u v w x y","a b c d e f g h i j k l m n o p q r s t u v w x y","a b c d e f g h i j k l m n o p q r s t u v w x y","a b c d e f g h i j k l m n o p q r s t u v w x y","a b c d e f g h i j k l m n o p q r s t u v w x y","a b c d e f g h i j k l m n o p q r s t u v w x y","a b c d e f g h i j k l m n o p q r s t u v w x y","a b c d e f g h i j k l m n o p q r s t u v w x y","a b c d e f g h i j k l m n o p q r s t u v w x y","a b c d e f g h i j k l m n o p q r s t u v w x y","a b c d e f g h i j k l m n o p q r s t u v w x y","a b c d e f g h i j k l m n o p q r s t u v w x y","a b c d e f g h i j k l m n o p q r s t u v w x y","a b c d e f g h i j k l m n o p q r s t u v w x y","a b c d e f g h i j k l m n o p q r s t u v w x y","a b c d e f g h i j k l m n o p q r s t u v w x y","a b c d e f g h i j k l m n o p q r s t u v w x y","a b c d e f g h i j k l m n o p q r s t u v w x y","a b c d e f g h i j k l m n o p q r s t u v w x y","a b c d e f g h i j k l m n o p q r s t u v w x y","a b c d e f g h i j k l m n o p q r s t u v w x y","a b c d e f g h i j k l m n o p q r s t u v w x y","a b c d e f g h i j k l m n o p q r s t u v w x y","a b c d e f g h i j k l m n o p q r s t u v w x y","a b c d e f g h i j k l m n o p q r s t u v w x y","a b c d e f g h i j k l m n o p q r s t u v w x y","a b c d e f g h i j k l m n o p q r s t u v w x y","a b c d e f g h i j k l m n o p q r s t u v w x y","a b c d e f g h i j k l m n o p q r s t u v w x y","a b c d e f g h i j k l m n o p q r s t u v w x y","a b c d e f g h i j k l m n o p q r s t u v w x y","a b c d e f g h i j k l m n o p q r s t u v w x y","a b c d e f g h i j k l m n o p q r s t u v w x y","a b c d e f g h i j k l m n o p q r s t u v w x y","a b c d e f g h i j k l m n o p q r s t u v w x y","a b c d e f g h i j k l m n o p q r s t u v w x y","a b c d e f g h i j k l m n o p q r s t u v w x y","a b c d e f g h i j k l m n o p q r s t u v w x y","a b c d e f g h i j k l m n o p q r s t u v w x y","a b c d e f g h i j k l m n o p q r s t u v w x y"};
	  vector <string> keyword(keyword_, keyword_+sizeof(keyword_)/sizeof(*keyword_)); 
	  string dangerous_[] = {"a","b","c"};
	  vector <string> dangerous(dangerous_, dangerous_+sizeof(dangerous_)/sizeof(*dangerous_)); 
	int threshold = 3; 
	string __[] = {"XXX"};
	  vector <string> _(__, __+sizeof(__)/sizeof(*__)); 
END
/*
CASE(5)
	string address_[] = ;
	  vector <string> address(address_, address_+sizeof(address_)/sizeof(*address_)); 
	string keyword_[] = ;
	  vector <string> keyword(keyword_, keyword_+sizeof(keyword_)/sizeof(*keyword_)); 
	string dangerous_[] = ;
	  vector <string> dangerous(dangerous_, dangerous_+sizeof(dangerous_)/sizeof(*dangerous_)); 
	int threshold = ; 
	string __[] = ;
	  vector <string> _(__, __+sizeof(__)/sizeof(*__)); 
END
*/
}
// END CUT HERE
