You are given sorted arrays , and of size . You have to count the number of triplets (one number in each array) such that they are in for a given common ratio . Formally, number of indices , and such that , and are in and .
Similarly, you have to count the number of triplets (one number in each array) such that they are in for a given common difference . Formally, number of indices , and such that , and are in and .
Input:
First line contains an integer , the size of the arrays.
Next line contains two integers and , common ratio and common difference respectively.
Next 3 lines contains the array , and respectively.
Output:
In a single line print the number of triplets in and separated by a single space.
Constraints:
≤ ≤
≤ , , ≤
Note: Consider are in GP.
The possible triplets in GP are:
The possible triplets in AP are: