Associated Course(s):
Sudo Placement 2019

Given two arrays **A **and **B**. Given **Q** queries each having a positive integer **i** denoting an index of the array **A**. For each query, your task is to find all the elements less than or equal to **A _{i}** in the array B.

**Input:**

The first line contains a single integer **T,**** **the number of test cases. The first line of each test case consists of a integer **N**. The second and third line of each test case consists of **N** spaced integers representing array A and array B respectively.** **The third line contains a positive integer Q, denoting the number of queries. Next Q lines contains queries.

**Output: **

For each testcase, print the required answer.

**Constraints:**

1 <= T <= 100

1 <= N <= 10^{7}

1 <= Ai, Bi <= 10^{7}

1 <= Q <= 10^{3}

**Example:
Input:**

1

6

1 2 3 4 7 9

0 1 2 1 1 4

2

5

4

6

6

**Explanation:
Testcase 1:** For 1

For 2

Author: saksham0751

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

thanuvinu94 | 425 |

the_coder95 | 380 |

RishabhTanwar1 | 320 |

kunalk02141 | 306 |

RitikRosan | 272 |

the_coder95 | 1226 |

RishabhTanwar1 | 1040 |

tathagat289 | 636 |

thanuvinu94 | 634 |

themanhasnoname | 620 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4885 |

Quandray | 4547 |

Login to report an issue on this page.