You are given two trees. You are allowed to perform an operation several times: attaching a new vertex connect to an existing vertex of a tree. For each vertex A of the first tree and vertex B of second tree, we root the first tree at A and the second tree at B then your task is to find the minimum number of operations needed to make two trees isomorphic.
(Two rooted trees are isomorphic if they are the same size , and there is a permutation of such that P["root of the first tree"] = "root of the second tree" and there is an edge between in the first tree iff there is an edge between in the second tree.)
Input Format
The first line contains two space-separated integers denoting the number of vertices of two trees.
Each of next lines contains two space-separated integers denoting an edge of the first tree.
Each of next lines contains two space-separated integers denoting an edge of the second tree.
Output Format
Output lines, each line contains space-separated integers. -th number in the -th line contains the answer if we root the first tree at vertex and the second tree at vertex .
Constraints
First tree:
Second tree: