CSES - Aalto Competitive Programming 2024 - wk12 - Mon - Integer Points
  • Time limit: 1.00 s
  • Memory limit: 512 MB

For the upcoming Christmas, Uoveli received nn lines of type x=y+cx=y+c and mm lines of type x=y+cx = -y+c. He wants to determine the number of pairs of lines that intersect in points with integer coordinates. He is busy preparing for the exams, so he asked you to help him with this task.

Input

The first line contains an integer nn. The following nn lines contain the coefficients cic_i for lines of type x=y+cx = y + c. The next line contains an integer mm. The following mm lines contain the coefficients cic_i for lines of type x=y+cx = -y + c.

Output

Output a single integer: the number of intersections.

Constraints

  • 1n,m1051 \le n, m \le 10^5

Example

Input:

3
1 3 2
2
0 3

Output:

3