Associated Course(s):
Must Do Interview Preparation

Given two arrays **X** and **Y** of positive integers, find number of pairs such that **x ^{y} > y^{x}**

**Input:**

The first line of input contains an integer **T**, denoting the number of test cases. Then T test cases follow. Each test consists of three lines. The first line of each test case consists of two space separated M and N denoting size of arrays X and Y respectively. The second line of each test case contains M space separated integers denoting the elements of array X. The third line of each test case contains N space separated integers denoting elements of array Y.

**Output:**

Corresponding to each test case, print in a new line, the number of pairs such that **x ^{y} > y^{x}**.

**Constraints:**

1 ≤ T ≤ 100

1 ≤ M, N ≤ 10^{5}

1 ≤ X[i], Y[i] ≤ 10^{3}

**Example:**

**Input**

1

3 2

2 1 6

1 5

**Output**

3

**Explanation:
Testcase 1:** The pairs which follow x

Author: rajatjha

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.

KarlBreitkopf | 391 |

taruncrrm | 150 |

kaushalsahu3236 | 144 |

vikeshkumar1 | 112 |

RABB_RAAKHA | 108 |

bhupinderkumar | 690 |

Liza123 | 665 |

xbuttercupx | 657 |

vikeshkumar1 | 650 |

nishant.ns19 | 644 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4781 |

Quandray | 4444 |

Login to report an issue on this page.