The Sorting Hat

5

5 votes
Implementation, Easy
Problem

Hogwarts School of Witchcraft and Wizardry is divided into four houses: Gryffindor, Hufflepuff, Ravenclaw & Slytherin. The newly admitted witches & wizards are to be assigned a house among these four.

The Sorting Hat magically determines which of the four Houses each new student belongs to. To do this, the Sorting Hat assigns a value to each new student based on its magical algorithm. This value is called the H factor.

The students are classified as follows:
H factor       House
1  - 5         Gryffindor
6  - 10        Hufflepuff
11 - 15        Ravenclaw
16 - 20        Slytherin

Given the H factor of each student, your job is to simply determine the number of new students that are assigned Gryffindor, Hufflepuff, Ravenclaw & Slytherin respectively.

Input:
The first line contains a single integer 'T' denoting the number of test cases.
For each test case:
The first line contains an integer 'N' denoting number of new students.
The second line contains 'N' space separated integers denoting the H factors of students 1, 2, 3, 4, 5, ... N respectively.

Output:
For each test case, print the number of students assigned Gryffindor, Hufflepuff, Ravenclaw and Slytherin separated by a space.
Print the answer for each testcase in a new line.

Constraints:
1 <= T <= 10
1 <= N <= 10^5
1 <= H factor <= 20

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

Testcase 1:
Students 2, 4, & 5 are assigned Gryffindor.
Students 1 & 6 are assigned Hufflepuff.
Student 3 is assigned Ravenclaw.
Student 7 is assigned Slytherin.
So answer is: 3 2 1 1

Testcase 2:
The no. of students in the houses are 1, 2, 2, 0 respectively

Editor Image

?