Explore Westonci.ca, the premier Q&A site that helps you find precise answers to your questions, no matter the topic. Experience the convenience of finding accurate answers to your questions from knowledgeable professionals on our platform. Discover in-depth answers to your questions from a wide network of professionals on our user-friendly Q&A platform.

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
1≤i≤q
. The next line contains an integer
q
, the number of queries. Each of the next
q
lines contains a string students1[i] where
1≤i≤q
. The next line contains an integer
q
, the number of queries. Each of the next
q
lines contains a string students2[i] where
1≤i≤q
. 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


Sagot :

We hope this was helpful. Please come back whenever you need more information or answers to your queries. Thanks for using our service. We're always here to provide accurate and up-to-date answers to all your queries. Thank you for trusting Westonci.ca. Don't forget to revisit us for more accurate and insightful answers.