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.

d_Coder00 | 163 |

VivSisMMM | 152 |

Astikeysingh | 148 |

Reetu_Kumari_MIT2018056 | 132 |

dungeon_master1299 | 126 |

Pulkit__Sharma__ | 658 |

Anirban166 | 531 |

abducodes | 518 |

Found_me | 494 |

Sathvik Avasarala | 466 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4559 |

Login to report an issue on this page.