\problemname{Is-A? Has-A? Who Knowz-A?}
Two familiar concepts in object oriented programming are the is-a and has-a
relationships. Given two classes A and B, we say that A is-a B if A is a
subclass of B; we say A has-a B if one of the fields of A is of type B.  For
example, we could imagine an object-oriented language (call it ICPC++) with code
like that in Figure \ref{isa_1}, where the class {\tt Day} is-a {\tt Time}, the
class {\tt Appointment} is both a {\tt DateBook} and a {\tt Reminder}, and class
{\tt Appointment} has-a {\tt Day}.

\begin{figure}[!h]
\centering
\begin{verbatim}
 class Day extends Time    class Appointment extends Datebook, Reminder
 {                         {
    ...                       private Day date;
 }                            ...
                           }
\end{verbatim}
  \vspace{-0.2in}%
  \caption{Two ICPC++ classes.}
  \label{isa_1}
\end{figure}
These two relationships are transitive.  For example if A is-a B and B is-a C
then it follows that A is-a C.  This holds as well if we change all the is-a's
in the last sentence to has-a's.  It also works with combinations of is-a's and
has-a's: in the example above, {\tt Appointment} has-a {\tt Time}, since it
has-a {\tt Day} and {\tt Day} is-a {\tt Time}. Similarly, if class
{\tt DateBook} has-a {\tt Year} then {\tt Appointment} has-a {\tt Year}, since
{\tt Appointment} is-a {\tt DateBook}.

In this problem you will be given a set of is-a and has-a relationships and
a set of queries of the form A is/has-a B.  You must determine if each
query is true or false.

\section*{Input:}
Input starts with two integers $n$ and $m$, ($1 \leq n,m \leq 10\,000$), where
$n$ specifies the number of given is-a and has-a relationships and $m$ specifies
the number of queries.  The next $n$ lines each contain one given relationship
in the form $c_1$ $r$ $c_2$ where $c_1$ and $c_2$ are single-word class names,
and $r$ is either the string ``is-a'' or ``has-a''.  Following this are $m$
queries, one per line, using the same format.  There will be at most $500$
distinct class names in the $n+m$ lines, and all class names in the last $m$
lines will appear at least once in the initial $n$ lines.  All is-a and has-a
relationships between the given classes can be deduced from the $n$ given
relationships.
Is-a relationships can not be circular (apart from the trivial identity
``$x$ is-a $x$'').


\section*{Output}
For each query, display the query number (starting at one) and whether the
query is true or false.
%(where we consider an unknown answer as false).
