# Geralt of Rivia SOLUTION GORIV

Page Contents

### Geralt of Rivia SOLUTION GORIV

Geralt of Rivia is an extremely well known witcher on the planet. The Nilfgard nation is loaded with witches and the ruler can just consider Geralt to take out every one of them. He summons Geralt to a city utilizing his bringing capacities and discloses to Geralt that he will give him gold coins to take out witches. Geralt couldn’t care less about the witches yet he needs the gold. The ruler advises him to dispense with the same number of witches as he can. In the event that Geralt slaughters all the witches in a city, at that point he gets gold coins equivalent to the all out number of active ways from a city.

Geralt gets a paper containing a rundown of the apparent multitude of ways from a city to another city in Nilfgard. On the off chance that a way is “Temeria Redania” at that point that implies geralt can go to Redania in the event that he is in Temeria. Geralt begins his excursion at the city of bringing. He slaughters each witch in the city he goes to, acquires gold coins equivalent to the all out active ways from that city and afterward picks the following unvisited way and goes to a city. In the event that geralt comes to one city for the second time, he will have no witches to kill along these lines he will essentially move onto the following unvisited way and not get any gold for that city once more. Geralt will proceed with this until he can no longer go to an unvisited way from his present area. Tell the most extreme measure of gold coins Geralt will gain from this mission.

Note: If there are different active ways from a city, Geralt picks the unvisited way that previously showed up on the paper he was given. “an” and “An” are considered as various urban communities.

Info:

First line will contain T, number of testcases. At that point the testcases follow.

First line of each Testcase will contain number of ways n and the city of calling c.

Next n lines will contain sets of city names, which is a substantial way in Nilfgard.

Yield:

For each testcase, yield a solitary line answer which contains the absolute number of gold coins Geralt will gain.

Limitations

1≤T≤10

1≤n≤2000

Test Input:

11 a

a b

a c

b c

b d

an e

c e

c b

e f

e g

b g

f a

Test Output:

11

Explaination:

Current City Earned Gold Coins (Total active ways from the current city)

a 3

b 3

c 2

e 2

f 1

a –

c –

b –

d No accessible/unvisited ways

Absolute Gold earned : 11

THANKS FOR JOINING THE LIVE
SOLUTIONS WILL BE SHARED HERE SOON