407155: GYM102697 126 Subway System
Description
You're going to a city that has a large subway system. The subway system has $$$n$$$ lines, and each line has a certain number of stations. However, some stations are "transfer stations": multiple lines go through them.
Given a list of the stations that each subway line goes through, your task is to figure out how many transfer stations exist throughout the subway system.
Note that "loop lines" that start and end at the same station may appear in the input, and stations that are the start and end of the loop but have no other lines going through them do not count as transfer stations. For a station to be a transfer station, it has to have multiple distinct lines going through it.
InputThe first line of input contains a single positive integer $$$n$$$: the number of lines in the subway system.
The next $$$n$$$ test cases each consist of two lines of input.
The first line consists of a single positive integer $$$m$$$: the number of stations in the given subway line
The next line contains $$$m$$$ space-separated station names, representing the route of the given subway line. The subway line might be a loop line.
OutputOutput a single positive integer $$$s$$$: the number of transfer stations in the subway system. Then, output $$$s$$$ station names: the name of each transfer station in the subway system, in alphabetical order.
ExamplesInput6 7 Vienna EastFallsChurch Rosslyn MetroCenter LenfantPlaza StadiumArmory NewCarrolton 7 WiehleRestonEast EastFallsChurch Rosslyn MetroCenter LenfantPlaza StadiumArmory LargoTownCenter 8 FranconiaSpringfield KingStOldTown Pentagon Rosslyn MetroCenter LenfantPlaza StadiumArmory LargoTownCenter 5 BranchAvenue LenfantPlaza GalleryPlace FortTotten Greenbelt 6 Huntington KinStOldTown Pentagon LenfantPlaza GalleryPlace FortTotten 5 ShadyGrove MetroCenter GalleryPlace FortTotten GlenmontOutput
EastFallsChurch FortTotten GalleryPlace LargoTownCenter LenfantPlaza MetroCenter Pentagon Rosslyn StadiumArmoryInput
3 5 EastStation NorthStation WestStation SouthStation EastStation 2 WestStation CenterStation 2 NorthStation CenterStationOutput
CenterStation NorthStation WestStationNote
Can you figure out which city has the subway system described in the first test case?