int main(int argc, char *argv[])
{
	if(argc < 2)
	{
		PrintHelp();
		return 1;
	}
	
	map<string, string> systems;
	DisjointSet links;
	
	ifstream in(argv[1]);
	string line;
	string current;
	while(getline(in, line))
	{
		// Skip blank lines.
		if(IsEmpty(line))
			continue;
		// If this line is not indented, it starts a new root object.
		if(line[0] > ' ')
			current.clear();
		
		if(Token(line, 0) == "system")
			current = Token(line, 1);
		else if(!current.empty() && Token(line, 0) == "link")
			links.Join(current, Token(line, 1));
		
		if(!current.empty())
		{
			systems[current] += line;
			systems[current] += '\n';
		}
	}
	
	vector<string> components;
	for(char **it = argv + 2; *it; ++it)
		components.push_back(*it);
	for(const pair<string, string> &it : systems)
	{
		bool match = components.empty();
		for(const string &component : components)
			match |= links.IsJoined(it.first, component);
		
		if(match)
			cout << it.second << endl;
	}
	return 0;
}