We’re preparing your current view and syncing the latest data.
Xenny likes to rank coins based on their denomination values. Each coin falls into one of several categories based on predefined value ranges. Given a list of Xenny's coins and categories with specified value intervals, determine the best possible ranks of coins in each category considering possible ordering within coins of same values.
The first line contains an integer T, the number of test cases. Each test case starts with two integers N and M, where N is the number of coins Xenny has and M is the number of categories. The second line contains N space-separated integers denoting the values of each coin. The next M lines each contain two integers L and R, representing the inclusive range of values for that category.
For each test case, output M lines — the best possible rank for Xenny’s coins in each category.
1 ≤ T ≤ 10 1 ≤ N, M ≤ 10^5 1 ≤ Coin values ≤ 10^9 1 ≤ L ≤ R ≤ 10^9