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.

KshatriyaYash | 658 |

RuntimeTerror | 446 |

nikhil_sojan | 388 |

cypherr | 384 |

striver119 | 378 |

KshatriyaYash | 1066 |

nikhil_sojan | 972 |

lonecoder | 909 |

mazumderrohit8 | 864 |

SumitSingh27 | 832 |

blackshadows | 5327 |

Ibrahim Nash | 5215 |

akhayrutdinov | 5111 |

mb1973 | 4462 |

Quandray | 4444 |

Login to report an issue on this page.