#C3372. Product Price Categorization
Product Price Categorization
Product Price Categorization
You are given several test cases. For each test case, you are provided with a list of products. Each product has a category (a string) and a price (an integer). Your task is to classify each product into one of four price ranges, and count the number of products that fall into each range for every category. The four price ranges are defined as follows:
For each test case, output a JSON object (or dictionary) that maps each category to another JSON object containing the counts for these four ranges. In case there are multiple test cases, output a JSON array of these objects.
inputFormat
Input is read from standard input (stdin). The first line contains an integer $$t$$, the number of test cases. For each test case, the first line contains an integer $$n$$, the number of products. Following that, there are $$n$$ lines, each containing a category (string) and a price (integer) separated by a space.
outputFormat
For each test case, output a JSON object that maps each category to another JSON object with four keys: "Cheap", "Moderate", "Expensive", and "Luxury", representing the counts of products in each price range. If there are multiple test cases, output a JSON array of these objects. The result should be printed to standard output (stdout).## sample
1
1
electronics 10
[{"electronics": {"Cheap": 1, "Moderate": 0, "Expensive": 0, "Luxury": 0}}]