import java.io.*; import java.util.*; import javax.naming.InterruptedNamingException; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); while (in.hasNext()) { Map<Integer, Node> map = new HashMap<Integer, Node>(); Set<Integer> cSet = ...