Pathological Paths

Time limit1sMemory limit128 MB

Problem

Professor Pathfinder is a distinguished authority on the structure of hyperlinks in the World Wide Web. To test his hypotheses he has been building software agents that automatically traverse hyperlinks and analyze the structure of the Web. Today he has had an intriguing idea to improve those agents, but he is very busy and needs help from good programmers. You are asked to join his team and write a small but critical module of his new agents.

As they follow hyperlinks, Pathfinder's agents incrementally build a map of the parts of the Web they have visited, so they must keep a list of the hyperlinks they have traversed and the web pages they have seen. One difficulty is that two or more different URLs can point to the same web page. For example, typing any one of the following five URLs probably brings your browser to the same page — the home page of the ACM-ICPC Ehime contest.

http://www.ehime-u.ac.jp/ICPC/
http://www.ehime-u.ac.jp/ICPC
http://www.ehime-u.ac.jp/ICPC/../ICPC/
http://www.ehime-u.ac.jp/ICPC/./
http://www.ehime-u.ac.jp/ICPC/index.html

Handling this perfectly would require rather complicated logic, so we simplify the problem in a slightly unrealistic way. You should look only at the path part of each URL (i.e. /ICPC/, /ICPC, /ICPC/../ICPC/, /ICPC/./, and /ICPC/index.html in the example above) and ignore the scheme part (e.g. http://), the server part (e.g. www.ehime-u.ac.jp), and any other optional parts. Read the following rules carefully, because some of them do not match how today's Web and URLs actually behave.

Each path in this problem is an absolute pathname that specifies a route from the root directory to some web page in a hierarchical (tree-shaped) directory structure. A pathname always starts with a slash (/), which represents the root directory, followed by path segments separated by slashes. For instance, /ICPC/index.html is a pathname with two segments, ICPC and index.html.

Every segment except the last must be a directory name, and the last segment must be the name of an ordinary file that stores a web page. There is one exception: an ordinary file named index.html at the end of a pathname may be omitted. For example, /ICPC/index.html may be shortened to /ICPC/ when index.html is an existing ordinary file. More precisely, if ICPC is an existing directory just under the root and index.html is an existing ordinary file just under /ICPC, then /ICPC/index.html and /ICPC/ refer to the same web page. Furthermore, the trailing slash after the last segment may also be omitted, so /ICPC/ may be further shortened to /ICPC. However, /index.html can only be abbreviated to / (a single slash).

Pay special attention to segments consisting of a single period (.) or a double period (..); both are always treated as directory names. A single period denotes the directory itself, and a double period denotes its parent directory. Therefore, if /ICPC/ refers to some web page, then both /ICPC/./ and /ICPC/../ICPC/ refer to the same page. Likewise, /ICPC2/../ICPC/ refers to that page when ICPC2 is an existing directory just under the root; otherwise it refers to no web page. Note that the root directory has no parent, so pathnames such as /../ and /ICPC/../../index.html cannot point to any web page.

Your task is to write a program that checks whether two given pathnames refer to existing web pages and, if so, whether they refer to the same one.

Input

The input consists of multiple datasets. The first line of each dataset contains two positive integers $N$ and $M$, separated by a single space; both are at most $100$.

The rest of the dataset consists of $N + 2M$ lines, each containing a syntactically correct pathname of at most $100$ characters. You may assume that every path segment enclosed by two slashes has length at least one — in other words, two consecutive slashes never occur in a pathname. Each segment contains nothing but alphanumeric characters (az, AZ, and 09) and periods (.).

The first $N$ pathnames enumerate all of the web pages (the ordinary files). Every existing directory name appears at least once among these pathnames. You may assume that none of these $N$ pathnames contains a segment made solely of a single or double period, and that their last segments are ordinary file names, so you need not apply the special rules for index.html or for single/double periods to them. You may also assume that no two of the $N$ pathnames point to the same page.

Each of the following $M$ pairs of pathnames is a question: do the two pathnames point to the same web page? These pathnames may contain single or double periods and may end with a slash. They may also contain names that do not correspond to any existing directory or ordinary file.

A line containing two zeros indicates the end of the input.

Output

For each dataset, output the $M$ answers to its $M$ questions, one per line. Each answer should be yes if both pathnames point to the same web page, not found if at least one of the pathnames does not point to any of the first $N$ web pages listed in the input, and no otherwise.