perpendicular-lines

Foo gave Bar N lines in the 2D plane, of the form ax+by+c=0. He decided to ask Q questions to Bar. In every question, he would select a line, and Bar will have to find out how many lines are perpendicular to the line selected by Foo. Help Bar in answering the questions.

Input:
First line contains a single integer N - the total number of lines given by Foo to Bar.
N lines follow - each line contains 3 space separated integers: a, b and c, representing the line ax+by+c=0.
Next line contains a single integer Q - the number of questions asked by Foo to Bar.
Q lines follow - each line contains an index between 1 and N (inclusive) - denoting the line selected by Foo.

Output:
Print the number of lines perpendicular to the line selected by Foo.
Print the answer to each question asked by Foo on a new line.

Constraints:
1 ≤ N ≤ 10^5
10^-9 ≤ a, b, c ≤ 10^9
1 ≤ Q ≤ 10^5

Note: All triplets (a, b, c) in the input denote valid straight lines.

SAMPLE INPUT
4
1 1 1
-1 1 1
1 2 3
3 4 5
4
1
2
3
4

SAMPLE OUTPUT
1
1
0
0

Explanation

Lines 1 and 2 are perpendicular to each other.

Source: hackerearth | Difficulty: EASY
Tags: Geometry

Data structures

Mathematics


Solutions: