{"trustable":true,"sections":[{"title":"","value":{"format":"MD","content":"Woohoo and MarcoHard are two prominent software companies. But due to the rise of rival firms, they decided that they need to merge in order to compete with them. For this, the management in Woohoo and MarcoHard are facing some troubles.\n\nBoth Woohoo and MarcoHard maintain a hierarchy of employees. In both companies, the head of the company is the CEO. Every other employee has exactly one immediate superior.\n\nTo make the merger successful, they have to maintain exactly same hierarchy in both the companies. They decided not to fire any of the employees. They can change the name of the employee\u0027s post (e.g. one company has a post for \u0027Software Developer\u0027, in other company it is called \u0027Code Ninja\u0027), but they can\u0027t promote or demote anyone (e.g. they can\u0027t make Developer a Project Manager or vice versa), nor can they break the existing hierarchy (that is if **a** is an immediate superior of **b**, they should be the same in the new hierarchy). But they can make new posts and hire new employees. Now, they need to make a similar hierarchy by hiring minimum number of employees. Since, they are people in HR, and not much familiar with computing algorithms, they are finding it really tough to figure out how many people to hire. So, you are asked to this job for them. And guess what, you may be awarded a balloon if you can help them in this great dilemma."}},{"title":"Input","value":{"format":"MD","content":"Input starts with an integer **T (\u0026le; 200)**, denoting the number of test cases.\n\nEach test case contains a blank line and two more lines, the hierarchy of WooHoo and Marcohard. Each hierarchy description starts with an integer **N (1 \u0026le; N \u0026le; 100)**, the number of employees except the CEO, followed by **N** integers, each describing the immediate superior of that employee. The CEO is identified by **0\u003csup\u003eth\u003c/sup\u003e** employee and every other employee is identified by an integer between **1** and **N**.\n\nYou can assume that, the hierarchy is valid, that is every employee is direct or indirect subordinate of the CEO and no one is a direct or indirect superior of himself."}},{"title":"Output","value":{"format":"MD","content":"For each test case, print the case number and the minimum number employees to hire. Both WooHoo and MarcoHard can hire, so, this number will be the total number of new employees hired by these two companies."}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e2\n\n4 0 0 1 1\n4 0 1 2 2\n\n4 0 0 1 1\n4 0 0 2 2\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eCase 1: 4\nCase 2: 0\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}