## GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

# [Solution] GBus count Kick Start Session Solution - Kick Start 2022

There exist some cities that are built along a straight road. The cities are numbered $1,2,3,\dots$ from left to right.

There are $N$ GBuses that operate along this road. For each GBus, the range of cities that it serves is provided: the $i$-th gBus serves the cities with numbers between ${\mathbf{A}}_{\mathbf{i}}$ and ${\mathbf{B}}_{\mathbf{i}}$, inclusive.

We are interested in a particular subset of $P$ cities. For each of those cities, we need to find out how many GBuses serve that particular city.

### Input

The first line of the input gives the number of test cases, $T$. Then, $T$ test cases follow; each case is separated from the next by one blank line. (Notice that this is unusual for Kickstart data sets.)

In each test case:

• The first line contains one integer $N$: the number of GBuses.
• The second line contains 2$N$ integers representing the ranges of cities that the buses serve, in the form ${\mathbf{A}}_{\mathbf{1}}$ ${\mathbf{B}}_{\mathbf{1}}$ ${\mathbf{A}}_{\mathbf{2}}$ ${\mathbf{B}}_{\mathbf{2}}$ ${\mathbf{A}}_{\mathbf{3}}$ ${\mathbf{B}}_{\mathbf{3}}$ ... ${\mathbf{A}}_{\mathbf{N}}$ ${\mathbf{B}}_{\mathbf{N}}$. That is, the first GBus serves the cities numbered from ${\mathbf{A}}_{\mathbf{1}}$ to ${\mathbf{B}}_{\mathbf{1}}$ (inclusive), the second GBus serves the cities numbered from ${\mathbf{A}}_{\mathbf{2}}$ to ${\mathbf{B}}_{\mathbf{2}}$ (inclusive), and so on.
• The third line contains one integer $P$: the number of cities we are interested in, as described above. (Note that this is not necessarily the same as the total number of cities in the problem, which is not given.)

Solution Click Below:-  👉
👇👇👇👇👇

• Finally, there are $P$ more lines; the $i$-th of these contains the number ${\mathbf{C}}_{\mathbf{i}}$ of a city we are interested in.

### Output

For each test case, output one line containing Case #x$x$: y$y$, where $x$ is the number of the test case (starting from 1), and $y$ is a list of $P$ integers, in which the $i$-th integer is the number of GBuses that serve city ${\mathbf{C}}_{\mathbf{i}}$.

### Limits

Memory limit: 1 GB.
$1\le \mathbf{T}\le 10$.

#### Test Set 1

Time limit: 60 seconds.
$1\le \mathbf{N}\le 50$.
$1\le {\mathbf{A}}_{\mathbf{i}}\le 500$, for all $i$.
$1\le {\mathbf{B}}_{\mathbf{i}}\le 500$, for all $i$.
$1\le {\mathbf{C}}_{\mathbf{i}}\le 500$, for all $i$.
$1\le \mathbf{P}\le 50$.

#### Test Set 2

Time limit: 120 seconds.
$1\le \mathbf{N}\le 500$.
$1\le {\mathbf{A}}_{\mathbf{i}}\le 5000$, for all $i$.
$1\le {\mathbf{B}}_{\mathbf{i}}\le 5000$, for all $i$.
$1\le {\mathbf{C}}_{\mathbf{i}}\le 5000$, for all $i$.
$1\le \mathbf{P}\le 500$.