Problem: A professor of anthropology was interested in people living in isolated islands and their history. He collected their family trees to conduct some anthropological experiment. For the experiment, he needed to process the family trees with a computer. For that purpose he translated them into text files. The following is an example of a text file representing a family tree.


John
Robert
Frank
Andrew
Nancy
David


Each line contains the given name of a person. The name in the first line is the oldest ancestor in this family tree. The family tree contains only the descendants of the oldest ancestor. Their husbands and wives are not shown in the family tree. The children of a person are indented with one more space than the parent. For example, Robert and Nancy are the children of John, and Frank and Andrew are the children of Robert. David is indented with one more space than Robert, but he is not a child of Robert, but of Nancy. To represent a family tree in this way, the professor excluded some people from the family trees so that no one had both parents in a family tree.

For the experiment, the professor also collected documents of the families and extracted the set of statements about relations of two persons in each family tree. The following are some examples of statements about the family above.


John is the parent of Robert.
Robert is a sibling of Nancy.
David is a descendant of Robert.


For the experiment, he needs to check whether each statement is true or not. For example, the first two statements above are true and the last statement is false. Since this task is tedious, he would like to check it by a computer program.



Input

The input contains several data sets. Each data set consists of a family tree and a set of statements. The first line of each data set contains two integers n (0 < n < 1000) and m (0 < m < 1000) which represent the number of names in the family tree and the number of statements, respectively. Each line of the input has less than 70 characters.

As a name, we consider any character string consisting of only alphabetic characters. The names in a family tree have less than 20 characters. The name in the first line of the family tree has no leading spaces. The other names in the family tree are indented with at least one space, i.e., they are descendants of the person in the first line. You can assume that if a name in the family tree is indented with k spaces, the name in the next line is indented with at most k + 1 spaces. This guarantees that each person except the oldest ancestor has his or her parent in the family tree. No name appears twice in the same family tree. Each line of the family tree contains no redundant spaces at the end.

Each statement occupies one line and is written in one of the following formats, where X and Y are different names in the family tree.


X is a child of Y.
X is the parent of Y.
X is a sibling of Y.
X is a descendant of Y.
X is an ancestor of Y.


Names not appearing in the family tree are never used in the statements. Consecutive words in a statement are separated by a single space. Each statement contains no redundant spaces at the beginning and at the end of the line.

The end of the input is indicated by two zeros.

Output

For each statement in a data set, your program should output one line containing True or False. The first letter of True or False in the output must be a capital. The output for each data set should be followed by an empty line.

Examples

Input

6 5
John
 Robert
  Frank
  Andrew
 Nancy
  David
Robert is a child of John.
Robert is an ancestor of Andrew.
Robert is a sibling of Nancy.
Nancy is the parent of Frank.
John is a descendant of Andrew.
2 1
abc
 xyz
xyz is a child of abc.
0 0


Output

True
True
True
False
False

True


Input

6 5
John
Robert
Frank
Andrew
Nancy
David
Robert is a child of John.
Robert is an ancestor of Andrew.
Robert is a sibling of Nancy.
Nancy is the parent of Frank.
John is a descendant of Andrew.
2 1
abc
xyz
xyz is a child of abc.
0 0


Output

True
True
True
False
False

True

Solution (in CPP):

Solution:
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;

#define BIG_NUM 2000000000

using namespace std;

struct Info{
	char name[21];
	int parent;
	vector<int> children;
};

bool strCmp(char* base, char* comp){
	int length1 = 0,length2 = 0;
	for(int i=0;base[i] != '\0'; i++)length1++;
	for(int i=0;comp[i] != '\0'; i++)length2++;
	if(length1 != length2)return false;


	for(int i=0;base[i] != '\0'; i++){
		if(base[i] != comp[i])return false;
	}
	return true;
}

void strcpy(char* to,char* str){
	for(int i=0;str[i] != '\0';i++){
		to[i] = str[i];
		to[i+1] = '\0';
	}
}

void func(int num_of_family,int num_of_statement){
	int index = 0,space_num,last_appeared[71],work_index;
	Info info[num_of_family];

	char line[100],work[21];

	scanf("%s",line);
	strcpy(info[0].name,line);
	info[0].parent = -1;
	last_appeared[0] = 0;
	getchar();

	for(int loop = 1; loop < num_of_family;loop++){
		fgets(line,100,stdin);
		for(space_num = 0; line[space_num] == ' ';space_num++);

		info[last_appeared[space_num-1]].children.push_back(++index);
		info[index].parent = last_appeared[space_num-1];

		work_index = 0;
		for(int i = space_num; line[i] != '\n' && line[i] != '\0';i++){
			work[work_index++] = line[i];
		}
		work[work_index] = '\0';

		strcpy(info[index].name,work);
		last_appeared[space_num] = index;
	}

	char X[21],is[3],buf1[6],buf2[15],buf3[15],Y[22];
	bool FLG;

	for(int loop = 0; loop < num_of_statement; loop++){
		scanf("%s %s %s %s %s %s",X,is,buf1,buf2,buf3,Y);

		for(int p = 0; Y[p] != '\0';p++){
			if(Y[p] == '.'){
				Y[p] = '\0';
			}
		}

		FLG = false;
		switch(buf2[0]){
		case 'c':
			for(int i = 0; i <= index; i++){
				if(strCmp(info[i].name,X)){
					if(info[i].parent != -1 && strCmp(info[info[i].parent].name,Y) == true){
						FLG = true;
					}
					break;
				}
			}
			break;
		case 'p': //X is the parent of Y
			for(int i = 0; i <= index; i++){
				if(strCmp(info[i].name,Y)){
					if(info[i].parent != -1 && strCmp(info[info[i].parent].name,X) == true){
						FLG = true;
					}
					break;
				}
			}
			break;
		case 's': //X is a silbling of Y
			for(int i = 0; i <= index; i++){
				if(strCmp(info[i].name,Y)){
					if(info[i].parent == -1)break;

					for(int k = 0; k < info[info[i].parent].children.size();k++){
						if(strCmp(info[info[info[i].parent].children[k]].name,X)){
							FLG = true;
							break;
						}
					}
					break;
				}
			}
			break;
		case 'd': //X is a descendant of Y
			for(int i = 0; i <= index; i++){
				if(strCmp(info[i].name,X)){
					int t = info[i].parent;

					while(t != -1){
						if(strCmp(info[t].name,Y)){
							FLG = true;
							break;
						}

						t = info[t].parent;
					}
					break;
				}
			}
			break;
		case 'a': //X is an ancestor of Y
			for(int i = 0; i <= index; i++){
				if(strCmp(info[i].name,Y)){
					int t = info[i].parent;

					while(t != -1){
						if(strCmp(info[t].name,X)){
							FLG = true;
							break;
						}

						t = info[t].parent;
					}
					break;
				}
			}
			break;

		}
		if(FLG){
			printf("True\n");
		}else{
			printf("False\n");
		}
	}

	printf("\n");
}


int main(){

	int num_of_family,num_of_statement;
	while(true){
		scanf("%d %d",&num_of_family,&num_of_statement);
		if(num_of_family == 0 && num_of_statement == 0)break;

		func(num_of_family,num_of_statement);
	}

	return 0;
}