There are many long trees in a forest. You will be given some relevant information about the trees and your task is to guess the heights of the trees. Let me describe the relevant information.You will be given a list of pairs. Each pair consists of an integer number and . Here,
A positive integer number.
Number of trees which have a height of where
Note that there will be no two pairs in the list such that they contain the same value of . It is guaranteed that the list contains all the divisors of the heights. You have to guess the heights of the trees. It is guaranteed that an unique solution exists for the given list of pairs.
The first line of the input contains a single positive integer number where T denotes the number of testcases.
Each test case starts with a single integer . Each of the next N lines will contain two positive integer numbers and .
Note that, the sum of all in the input file will be at most
For each test case print “Case T:” in a line, where T denotes the test case number. Let there be unique heights of trees for this test case. Print in the next line. After that, You have to print pairs in the next lines. The pair will contain two space separated integers and . Here,
shortest unique height of the trees.
Number of trees of height
1 3 1 3 2 2 4 1
Case 1: 3 1 1 2 1 4 1
Login to submit
The list of heights is a subset of the DDD values in the given lists. The solution is given below: ...