Crazy Town

From Codeforces. Two points $A = (x_1, y_1)$ and $B = (x_2, y_2)$ lie in a town crossed by $n$ straight roads. Each road is an infinite line given by the equation

$$a_i x + b_i y + c_i = 0$$

Neither point lies on any road. Count how many roads separate the two points, meaning the points lie on opposite sides of that line.

A point lies on the line when $a_i x + b_i y + c_i = 0$. The two points are on opposite sides exactly when the two substituted values have strictly opposite signs.

Input encoding

The callable receives one flat integer array:

[x1, y1, x2, y2, n, a1, b1, c1, a2, b2, c2, ..., an, bn, cn]

The first five entries are the two points and the number of roads. The remaining $3n$ entries are the road coefficients in order.

Examples
Input: [0,0,2,2,1,2,1,1]
Output: 0
Hints

Crazy Town

**From Codeforces.** Two points $A = (x_1, y_1)$ and $B = (x_2, y_2)$ lie in a town crossed by $n$ straight roads. Each road is an infinite line given by the equation