SOLVE
LATER
Arya Stark is now a trained assassin, and her aim is to destroy and kill Queen Cersei to avenge her father’s death. Being a trained assassin, Arya can easily sneak into enemy’s territory.
She uses this ability to enter the area where Cersei’s army is residing into their tents. There are ‘N’ number of tents in this area having ID 1,2,3..N . Some tents may be connected to each other via ropes. Arya wants to kill and injure as many warriors of Cersei’s army by burning the tents.
If there are ‘c’ no. of tents which are connected to each other via ropes, then Arya can light any one of these connected tents as warriors/soldiers of other ‘c-1’ tents will be alarmed by this activity. Suppose, Arya lights tent ‘X’ out of these c tents, then all the warriors of the tent ‘X’ will get killed and the warriors which are in the rest of the connected tents i.e. c-1 tents will get injured.
See sample explanation for more details.
Note –
Now, Arya Stark wants to kill maximum no. of soldiers of Cersei’s army. Can you tell in advance how many soldiers will be killed and how many will get injured by this act of Arya Stark? Also output the number (ID) of tents which will be lighten by Arya. If more than one connected tents can be lighten then Arya will choose to light the tent whose ID will be minimum.
Input:
First line will contain two space separated integers N and M, i.e. the total number of tents and total number of connections between the tents.
Second line will contain ‘N’ space separated integers denoting the number of soldiers in i’th tent 1<=i<=N.
Next ‘M’ lines contains two spaced separated ‘a’ and ‘b’ denoting Tent ‘a’ and Tent ‘b’ are connected to each other via rope.
Output:
Two space separated integers denoting number of soldiers killed and number of soldiers injured respectively.
Next line contains the space separated ID of the lighten tents in increasing order of their ID’s.
Constraints:
In the given case, there are 6 Tents numbered 1 to 6, which have 3,4,3,2,4,5 soldiers in respective tents.
Tents 1,2,3,5 are connected and Tents 4,6 are connected.
Arya will light tents numbered 2 and 6, lighting of tent 2 will result in killing of 4 soldiers in it and injuring soldiers of tents 1,3,5 and lighting of tent 6 will result in killing of 5 soldiers in it and injuring soldiers of tent 4. So, this will result in killing 9 soldiers and causing injury to 12 soldiers.