Engineering

As new students begin to arrive at college, each receives a unique ID number, 1 to n . Initially, the students do not know one another, and each has a different circle of friends. As the semester progresses, other groups of friends begin to form randomly. There will be three arrays, each aligned by an index. The first array will contain a queryType which will be either Friend or Total. The next two arrays, students1 and students2, will each contain a student ID. If the query type is Friend, the two students become friends. If the query type is Total, report the sum of the sizes of each group of friends for the two students. Example n=4 queryType = ['Friend', 'Friend', 'Total'] student 1=[1,2,1] student2 =[2,3,4] The queries are assembled, aligned by index: Input from stdin will be processed and passed to the function as follows: The first line contains an integer n , the number of students. The next line contains an integer q , the number of queries. Each of the next q lines contains a string queryType[i] where 1iq . The next line contains an integer q , the number of queries. Each of the next q lines contains a string students1[i] where 1iq . The next line contains an integer q , the number of queries. Each of the next q lines contains a string students2[i] where 1iq . Sample Case 0 Sample Input 0 STDIN 0 3 2 Friend query = [Friend, Tota Total 2 1 2 2 2 Function 0.0 n=3 queryType [ ] size q=2 students 1[] size q=2 students 1=[1,2] students 2[] size q=2 students2 =[2,3] Sample Output 0 3 Fynlanation 0