## Algorithm

Have you ever listened to the speeches of leaders (Political or non-political)? People often find these speeches monotonous and hopeless. The leaders also sometimes feel very embarrassed about their speeches and they are often afraid of covering the same topics in two different speeches. You can save our intelligent leaders from these kinds of embarrassments. For example, let’s consider that a leader has the following topics in his mind a) War b) Terror c) Peace d) Nuclear-Bomb e) Human-Right f) Food g) Oil-Crisis h) Equal-Right He delivers speeches on any two of these topics at once but never wants to cover the topics “OilCrisis” and “War” in the same speech. The same thing applies for the topics “Nuclear-Bomb” and “Equal-Right”. You can help him by making all possible combinations of topics (Of course considering the restrictions supplied by him) so that he can choose any one from them according to his convenience and can avoid any blunders. The specific details are given in the input and output specifications. Input The first line of the input file contains an integer n(n ≤ 100), which indicates how many sets of inputs are there. The description of each set is given in the paragraph below: The first line of each set has three integers t(0 < t < 16), p(0 ≤ p < t(t − 1)/2), s(0 < s ≤ 5). Here t denotes the number of topics in the leader’s mind, p denotes the number of prohibited pairs and s is the total number of topics the leader wants to cover in a single speech. The next t lines contain t topics of the leader’s mind. The topics are all different. Each topic will contain only alphanumeric characters and hyphens. Each of the next p lines contains two different topics in each line separated by a single space. These pairs of topics should not come in the same speech. Same pair of topics may appear more than once in the input. Each topic has a maximum length of 15. Output For each set you should first print the serial of that set. Each of the next lines should contain all the possible topic groups. The topics in each group should be separated by a single space. Print a blank line after the output for each set of input. In a group the topics should be printed in the descending order of their lengths. If lengths of two topics are same the lexicographically smaller one should come first. This order should also be maintained in the printing order of the groups. Topics should be considered case insensitive. While printing the topics print all the characters as uppercase. Print a blank line after the output for each case. Sample Input 2 8 2 2 WAR TERROR PEACE NUCLEAR-BOMB HUMAN-RIGHT FOOD OIL-CRISIS EQUAL-RIGHT WAR OIL-CRISIS EQUAL-RIGHT NUCLEAR-BOMB 8 0 1 WAR TERROR PEACE NUCLEAR-BOMB HUMAN-RIGHT FOOD OIL-CRISIS EQUAL-RIGHT Sample Output Set 1: NUCLEAR-BOMB HUMAN-RIGHT NUCLEAR-BOMB OIL-CRISIS NUCLEAR-BOMB TERROR NUCLEAR-BOMB PEACE NUCLEAR-BOMB FOOD NUCLEAR-BOMB WAR EQUAL-RIGHT HUMAN-RIGHT EQUAL-RIGHT OIL-CRISIS EQUAL-RIGHT TERROR EQUAL-RIGHT PEACE EQUAL-RIGHT FOOD EQUAL-RIGHT WAR HUMAN-RIGHT OIL-CRISIS HUMAN-RIGHT TERROR HUMAN-RIGHT PEACE HUMAN-RIGHT FOOD HUMAN-RIGHT WAR OIL-CRISIS TERROR OIL-CRISIS PEACE OIL-CRISIS FOOD TERROR PEACE TERROR FOOD TERROR WAR PEACE FOOD PEACE WAR FOOD WAR Set 2: NUCLEAR-BOMB EQUAL-RIGHT HUMAN-RIGHT OIL-CRISIS TERROR PEACE FOOD WAR

## Code Examples

### #1 Code Example with C++ Programming

```Code - C++ Programming```

``````#include <bits/stdc++.h>
using namespace std;

void dfs(int idx,vector < string>& cur,vector<string>& topics,
unordered_map{
cin >> t >> p >> s;
vector < string> topics;
vector<string> cur;
unordered_map < string,unordered_set > b.length();
});
printf("Set %d:\n",tc++);
dfs(0,cur,topics,unallowed,s);
cout << endl;
}
}``````
Copy The Code &

Input

cmd
2
8 2 2
WAR
TERROR
PEACE
NUCLEAR-BOMB
HUMAN-RIGHT
FOOD
OIL-CRISIS
EQUAL-RIGHT
WAR OIL-CRISIS
EQUAL-RIGHT NUCLEAR-
BOMB 8 0 1
WAR
TERROR
PEACE
NUCLEAR-BOMB
HUMAN-RIGHT
FOOD
OIL-CRISIS
EQUAL-RIGHT

Output

cmd
Set 1:
NUCLEAR-BOMB HUMAN-RIGHT
NUCLEAR-BOMB OIL-CRISIS
NUCLEAR-BOMB TERROR
NUCLEAR-BOMB PEACE
NUCLEAR-BOMB FOOD
NUCLEAR-BOMB WAR
EQUAL-RIGHT HUMAN-RIGHT
EQUAL-RIGHT OIL-CRISIS
EQUAL-RIGHT TERROR
EQUAL-RIGHT PEACE
EQUAL-RIGHT FOOD
EQUAL-RIGHT WAR
HUMAN-RIGHT OIL-CRISIS
HUMAN-RIGHT TERROR
HUMAN-RIGHT PEACE
HUMAN-RIGHT FOOD
HUMAN-RIGHT WAR
OIL-CRISIS TERROR
OIL-CRISIS PEACE
OIL-CRISIS FOOD
TERROR PEACE
TERROR FOOD
TERROR WAR
PEACE FOOD
PEACE WAR
FOOD WAR
Set 2:
NUCLEAR-BOMB
EQUAL-RIGHT
HUMAN-RIGHT
OIL-CRISIS
TERROR
PEACE
FOOD
WAR