#t468. 查找二叉树

查找二叉树

Background

Special for beginners, ^_^

Description

A binary tree is stored using an adjacency-list structure. Search, in inorder traversal, for the node whose value is xx, and report which node it is (its position in the inorder traversal). For example, the data-file format of the binary tree in the figure is as follows:

Format

Input

The first line, nn, is the number of nodes in the binary tree, n≤100n\le 100;

The second line, xx, is the value of the node to be searched for;

The following data give, in the first column, the value of each node, in the second column the index of its left child, and in the third column the index of its right child.

Output

Output a single integer: the position of the searched node in the inorder traversal.

Samples

7
15
5 2 3
12 4 5
10 0 0
29 0 0
15 6 7
8 0 0
23 0 0
4

Limitation

1s, 1024KiB for each test case.