Given two BSTs containing N**1** and N**2** distinct nodes respectively and given a value **x**. Your task is to complete the function **countPairs()**, that returns the count of all pairs from both the BSTs whose sum is equal to **x**.

Examples:

```
Input : BST 1: 5
/ \
3 7
/ \ / \
2 4 6 8
BST 2: 10
/ \
6 15
/ \ / \
3 8 11 18
x = 16
Output : 3
The pairs are:
```**(5, 11), (6, 10)** and **(8, 8)**

**Input:**

The function takes three arguments as input, first the reference pointer to the root(**root1**) of the BST1, then reference pointer to the root(**root2**) of the BST2 and last the element **X**.

There will be **T** test cases and for each test case the function will be called separately.

**Output:**

For each test cases print the required number of pairs on new line.

**Constraints:**

1<=T<=100

1<=N<=10^{3}

**Example:
Input:**

2

7

5 3 7 2 4 6 8

7

10 6 15 3 8 11 18

16

6

10 20 30 40 5 1

5

25 35 10 15 5

30

3

2

Author: harshitsidhwa

Anshul Wadhawan | 280 |

NoobNoob | 203 |

aild78 | 190 |

Shivam_Kumar_Singh | 183 |

stevecooper | 183 |

rambo | 868 |

Anshul Wadhawan | 740 |

Calahan | 677 |

fullmetal27 | 675 |

ks75 | 657 |

akhayrutdinov | 4698 |

Ibrahim Nash | 3664 |

sanjay05 | 3633 |

Quandray | 3491 |

surbhi_7 | 2748 |