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.

thanuvinu94 | 238 |

the_coder95 | 215 |

ShivayLamba | 208 |

sandeep.prajapati | 129 |

Ashish Kumar Vaishy | 114 |

the_coder95 | 1441 |

RishabhTanwar1 | 1110 |

thanuvinu94 | 914 |

tathagat289 | 668 |

themanhasnoname | 620 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4897 |

Quandray | 4547 |

Login to report an issue on this page.