3.1 Writers and Words
(RankList for this Question)
Score: 20pts
Time Limit: 5.00 sec
Three writers play a game: first, each writer writes down n distinct words of length 3 Then, they total up the number of points as follows:
a. if a word was written by one writer — that writer gets 3 points,
b. if a word was written by two writers— each of the two gets 1 point,
c. if a word was written by all — nobody gets any points.

1 <= t <= 100
1 <= n <= 1000

Input Format
The input consists of multiple test cases.

The first line contains an integer t (1≤t≤100) the number of test cases.

The description of the test cases follows:
The first line of each test case contains an integer n (1≤n≤1000) — the number of words written by each person.
The following three lines each contain n distinct strings — the words written by each person. Each string consists of 3 lowercase English characters.

Output Format
For each test case, output three space-separated integers — the number of points each of the three guys earned. You should output the answers in the same order as the input; the i-th integer should be the number of points earned by the i-th guy.

Example 1
orz for qaq
qaq orz for
cod for ces
iat roc hem ica lly
bac ter iol ogi sts
bac roc lly iol iat

1 3 1
2 2 6
9 11 5

In the first test case second writer has a unique word so that writer gets 3 points and other 2 writers get 1 point
In the second test case one word is repeated by all three and 2 words are common between first and second writers whereas the third writer has 2 unique words for the final scorecard becomes 2 2 6 respectively

Log In to solve the Question