Favorite Tree
시간 제한0.1초메모리 제한1024 MB
두 트리가 주어질 때 첫 번째 트리의 부분트리 중 두 번째 트리와 동형인 것이 있는지 판정한다.
문제
After learning about tree isomorphism, Telio couldn’t avoid but wonder in how many trees out there his favorite tree is hiding.
Given two trees, and , can you help him determine if there is a subtree of isomorphic to ?
Two trees are isomorphic if it is possible to label their vertices in such a way that they become exactly the same tree. For instance, a tree having edges is isomorphic to a tree having edges .
The figure below corresponds to the first sample, with tree on the left and tree on the right. The subtree of formed by all of its vertices but vertex is isomorphic to .

입력
There are two groups of lines, each group describing a tree. The first group describes the tree , while the second group describes the tree .
Within each group describing a tree, the first line contains an integer () representing the number of vertices in the tree. Vertices are identified by distinct integers from to . Each of the next lines contains two integers and ( and ), indicating that the tree has the edge .
It is guaranteed that the input describes two valid trees.
출력
Output a single line with the uppercase letter “Y” if there is a subtree of that is isomorphic to , and the uppercase letter “N” otherwise.