You are given unweighted, undirected graphs, , , and , with vertices each, where the graph has edges and the vertices in each graph are numbered from through . Find the number of ordered triples , where , , such that there is an edge in , an edge in , and an edge in .
The first line contains single integer, , denoting the number of vertices in the graphs. The subsequent lines define , , and . Each graph is defined as follows:
The first line contains an integer, , describing the number of edges in the graph being defined.
Each line of the subsequent lines (where ) contains space-separated integers describing the respective nodes, and connected by edge .
Each graph contains no cycles and any pair of directly connected nodes is connected by a maximum of edge.
Print a single integer denoting the number of distinct triples as described in the Problem Statement above.
There are three possible triples in our Sample Input: