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

For the upcoming Christmas, Uoveli received n lines of type x=y+c and m lines of type x = -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 n. The following n lines contain the coefficients c_i for lines of type x = y + c. The next line contains an integer m. The following m lines contain the coefficients c_i for lines of type x = -y + c.

Output

Output a single integer: the number of intersections.

Constraints

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

Example

Input:

3
1 3 2
2
0 3

Output:

3