Ghosts live in harmony and peace, they travel the space without any purpose other than scare whoever stands in their way.

There are $n$ ghosts in the universe, they move in the $OXY$ plane, each one of them has its own velocity that does not change in time: $\overrightarrow{V} = V_{x}\overrightarrow{i} + V_{y}\overrightarrow{j}$ where $V_{x}$ is its speed on the $x$-axis and $V_{y}$ is on the $y$-axis.

A ghost $i$ has experience value $EX_i$, which represent how many ghosts tried to scare him in his past. Two ghosts scare each other if they were in the same cartesian point at a moment of time.

As the ghosts move with constant speed, after some moment of time there will be no further scaring (what a relief!) and the experience of ghost kind $GX = \sum_{i=1}^{n} EX_i$ will never increase.

Tameem is a red giant, he took a picture of the cartesian plane at a certain moment of time $T$, and magically all the ghosts were aligned on a line of the form $y = a \cdot x + b$. You have to compute what will be the experience index of the ghost kind $GX$ in the indefinite future, this is your task for today.

Note that when Tameem took the picture, $GX$ may already be greater than $0$, because many ghosts may have scared one another at any moment between $[-\infty, T]$.


-----Input-----

The first line contains three integers $n$, $a$ and $b$ ($1 \leq n \leq 200000$, $1 \leq |a| \leq 10^9$, $0 \le |b| \le 10^9$) — the number of ghosts in the universe and the parameters of the straight line.

Each of the next $n$ lines contains three integers $x_i$, $V_{xi}$, $V_{yi}$ ($-10^9 \leq x_i \leq 10^9$, $-10^9 \leq V_{x i}, V_{y i} \leq 10^9$), where $x_i$ is the current $x$-coordinate of the $i$-th ghost (and $y_i = a \cdot x_i + b$).

It is guaranteed that no two ghosts share the same initial position, in other words, it is guaranteed that for all $(i,j)$ $x_i \neq x_j$ for $i \ne j$.


-----Output-----

Output one line: experience index of the ghost kind $GX$ in the indefinite future.


-----Examples-----
Input
4 1 1
1 -1 -1
2 1 1
3 1 1
4 -1 -1

Output
8

Input
3 1 0
-1 1 0
0 0 -1
1 -1 -2

Output
6

Input
3 1 0
0 0 0
1 0 0
2 0 0

Output
0



-----Note-----

There are four collisions $(1,2,T-0.5)$, $(1,3,T-1)$, $(2,4,T+1)$, $(3,4,T+0.5)$, where $(u,v,t)$ means a collision happened between ghosts $u$ and $v$ at moment $t$. At each collision, each ghost gained one experience point, this means that $GX = 4 \cdot 2 = 8$.

In the second test, all points will collide when $t = T + 1$.  [Image] 

The red arrow represents the 1-st ghost velocity, orange represents the 2-nd ghost velocity, and blue represents the 3-rd ghost velocity.

Difficulty: interview

Starter code:

Solutions:
n, A, C = list(map(int, input().split()))

def Ro(x, y):
    return A * x - y + C
 
huh = []
 
for i in range(n):
    z, x, y = list(map(int, input().split()))
    huh.append((Ro(x + z, z * A + y), x))
huh = sorted(huh)
anss = 0
c1 = 0
c2 = 0
prev = (-9999999999999, -999999999999999)
g = []

huh.append((-9999999999999, -999999999999999))
#print(huh)
for huhh in huh:
    if huhh[0] != prev[0]:
        g.append(c1)
        #print(g)
        for j in g:
            anss += (c2 - j) * j
        g = []
        c1 = 1
        c2 = 1
        prev = (huhh[0], huhh[1])
        continue
    c2 += 1
    if huhh[1] != prev[1]:
        g.append(c1)
        c1 = 0
        prev = (huhh[0], huhh[1])
    c1 += 1
print(anss)


#!/usr/bin/env python3

[n, a, b] = list(map(int, input().strip().split()))
bis = [tuple(map(int, input().strip().split())) for _ in range(n)]
dis = [(a * Vx - Vy, Vx) for x, Vx, Vy in bis]

dis.sort()

res = 0
dprev = dis[0][0] - 1
vprev = 0
dcount = 0
vcount = 0
for di, vi in dis:
	if di != dprev:
		res += dcount * (dcount - 1)
		res -= vcount * (vcount - 1)
		dcount = 1
		vcount = 1
		dprev = di
		vprev = vi
	else:
		dcount += 1
		if vi != vprev:
			res -= vcount * (vcount - 1)
			vcount = 1
			vprev = vi
		else:
			vcount += 1
res += dcount * (dcount - 1)
res -= vcount * (vcount - 1)

print (res)


import atexit
import io
import sys

# Buffering IO
_INPUT_LINES = sys.stdin.read().splitlines()
input = iter(_INPUT_LINES).__next__
_OUTPUT_BUFFER = io.StringIO()
sys.stdout = _OUTPUT_BUFFER

@atexit.register
def write():
    sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
    

def main():
    n, a, b = [int(x) for x in input().split()]
    dc = {}
    for i in range(n):
        x, vx, vy = [int(x) for x in input().split()]
        nx = x + vx
        ny = a*x+b + vy
        dd = a*nx - ny + b
        if dd not in dc:
            dc[dd] = {}
        if (vx,vy) not in dc[dd]:
            dc[dd][(vx,vy)] = 0
        dc[dd][(vx,vy)] += 1
    
    tot = 0
    for v,k in list(dc.items()):
        tt = 0
        pp =0
        for _,cc in list(k.items()):
            tt -= cc * (cc+1) // 2
            pp += cc
        tt += pp * (pp+1) // 2
        tot += tt*2
    print(tot)
        

    
def __starting_point():
    main()

__starting_point()

n, a, b = map(int, input().split())
ghosts = [(vx, vy) for x, vx, vy in (map(int, input().split()) for i in range(n))]
speeds = {}
for vx, vy in ghosts:
    vl = a * vx - vy
    k = vx + a * vy
    ss = speeds.setdefault(vl, {})
    ss[k] = ss.get(k, 0) + 1

result = 0
for vl, ss in speeds.items():
    group_size = sum(ss.values())
    for sss in ss.values():
        result += sss * (group_size - sss)
print(result)

import atexit
import io
import sys

# Buffering IO
_INPUT_LINES = sys.stdin.read().splitlines()
input = iter(_INPUT_LINES).__next__
_OUTPUT_BUFFER = io.StringIO()
sys.stdout = _OUTPUT_BUFFER


@atexit.register
def write():
    sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())


def main():
    n, a, b = [int(x) for x in input().split()]
    dc = {}
    for i in range(n):
        x, vx, vy = [int(x) for x in input().split()]
        nx = x + vx
        ny = a * x + b + vy
        dd = a * nx - ny + b
        if dd not in dc:
            dc[dd] = {}
        if (vx, vy) not in dc[dd]:
            dc[dd][(vx, vy)] = 0
        dc[dd][(vx, vy)] += 1

    tot = 0
    for v, k in dc.items():
        tt = 0
        pp = 0
        for _, cc in k.items():
            tt -= cc * (cc + 1) // 2
            pp += cc
        tt += pp * (pp + 1) // 2
        tot += tt * 2
    print(tot)


def __starting_point():
    main()
__starting_point()

import atexit
import io
import sys

# Buffering IO
_INPUT_LINES = sys.stdin.read().splitlines()
input = iter(_INPUT_LINES).__next__

def main():
    n, a, b = [int(x) for x in input().split()]
    dc = {}
    for i in range(n):
        x, vx, vy = [int(x) for x in input().split()]
        nx = x + vx
        ny = a * x + b + vy
        dd = a * nx - ny + b
        if dd not in dc:
            dc[dd] = {}
        if (vx, vy) not in dc[dd]:
            dc[dd][(vx, vy)] = 0
        dc[dd][(vx, vy)] += 1

    tot = 0
    for v, k in dc.items():
        tt = 0
        pp = 0
        for _, cc in k.items():
            tt -= cc * (cc + 1) // 2
            pp += cc
        tt += pp * (pp + 1) // 2
        tot += tt * 2
    print(tot)


def __starting_point():
    main()
__starting_point()

from sys import stdin
rd = lambda: list(map(int, input().split()))
g = lambda x, i: x.get(i, 0)
n, a, b = rd()
c, d = {}, {}
r = 0
for z in range(n):
    _, x, y = rd()
    i, j = a * x - y, (x, y)
    r += g(c, i) - g(d, j)
    c[i] = g(c, i) + 1
    d[j] = g(d, j) + 1
print(2 * r)



def main():
    n, a, b = [int(part) for part in input().split()]
    ghosts = []
    for i in range(n):
        ghosts.append([int(part) for part in input().split()])

    cnt = dict()
    vcnt = dict()
    for (x, vx, vy) in ghosts:
        if (vx, vy) in vcnt:
            vcnt[(vx, vy)] += 1
        else:
            vcnt[(vx, vy)] = 1

        tmp = vy - a * vx
        if tmp in cnt:
            cnt[tmp] += 1
        else:
            cnt[tmp] = 1

    ans = 0
    for (x, vx, vy) in ghosts:
        tmp = vy - a * vx
        ans += cnt[tmp] - vcnt[(vx, vy)]

    print(ans)

def __starting_point():
    main()

__starting_point()

from collections import Counter
n,a,b=[int(_) for _ in input().split()]
s,s1=Counter(),Counter();ans=0
for i in range(n):
	x,vx,vy=[int(_) for _ in input().split()]
	tmp=vy-a*vx
	ans+=s[tmp]-s1[(vx,vy)]
	s[tmp]+=1
	s1[(vx,vy)]+=1
print(ans*2)

from collections import Counter
n,a,b=map(int,input().split())
s,s1=Counter(),Counter();ans=0
for i in range(n):
	x,vx,vy=map(int,input().split())
	tmp=vy-a*vx
	ans+=s[tmp]-s1[(vx,vy)]
	s[tmp]+=1
	s1[(vx,vy)]+=1
print(ans*2)

from collections import Counter
n,a,b=map(int,input().split())
s=Counter();ans=0
for i in range(n):
	x,vx,vy=map(int,input().split())
	tmp=vy-a*vx
	ans+=s[tmp]-s[(vx,vy)]
	s[tmp]+=1;s[(vx,vy)]+=1
print(ans*2)

from collections import defaultdict

n, a, b = map(int, input().split())

res = defaultdict(lambda :0)
t = defaultdict(lambda :0)

ans = 0

for _ in range(n):
    k, x, y = map(int, input().split())
    ans += res[a*x-y] - t[(x,y)]
    res[a*x-y]+=1
    t[(x,y)]+=1

print(ans*2)

from collections import Counter
from sys import stdin
n,a,b=map(int,stdin.readline().split())
s=Counter();ans=0
for i in range(n):
	x,vx,vy=map(int,stdin.readline().split())
	tmp=vy-a*vx
	ans+=s[tmp]-s[(vx,vy)]
	s[tmp]+=1;s[(vx,vy)]+=1
print(ans*2)

from collections import Counter
from sys import stdin
n,a,b=map(int,stdin.readline().split())
s=Counter();ans=0
for i in range(n):
	x,vx,vy=map(int,stdin.readline().split())
	tmp=vy-a*vx
	ans+=s[tmp]-s[(vx,vy)]
	s[tmp]+=1;s[(vx,vy)]+=1
print(ans*2)

# http://codeforces.com/contest/975/problem/D
n, a, b = (int(x) for x in input().split())

marks = 0
k = {}
v = {}
for i in range(0, n):
    x, v1, v2 = [int(x) for x in input().split()]
    ki = v2 - a * v1
    vi = (v1, v2)

    if ki in k:
        k[ki] += 1
    else:
        k[ki] = 1

    if vi in v:
        v[vi] += 1
    else:
        v[vi] = 1

    marks += k[ki] - v[vi]

print(marks * 2)

import bisect;
n, a, b = map(int, input().split(' '));
x=[0]*n;
vx=[0]*n;
vy=[0]*n;
for i in range(n):
    x[i], vx[i], vy[i]=map(int, input().split(' '));
#y=ax y-ax=0 (x, y)* (-a, 1)=0 (-a, 1) - вектор нормали
ntypes=dict();
for i in range(n):
    ntype=-a*vx[i]+1*vy[i];
    currSet=ntypes.get(ntype, set());
    currSet.add(i);
    ntypes[ntype]=currSet;
result=0;
for key in ntypes.keys():
    currSet=ntypes[key];
    currLen=len(currSet);
    vtypes=dict();
    for i in currSet:
        vtype=vx[i]*1+vy[i]*a;
        vtypes[vtype]=vtypes.get(vtype, 0)+1;
    for key in vtypes.keys():
        curr=vtypes[key];
        result+=curr*(currLen-curr)
print(result);

#!/usr/bin/env python3

from collections import Counter

[n, a, b] = list(map(int, input().strip().split()))
bis = [tuple(map(int, input().strip().split())) for _ in range(n)]
dis = [(a * Vx - Vy, Vx) for x, Vx, Vy in bis]

dis.sort()

def count(d):
	return sum((v * k * (k - 1) for k, v in d))

def filt(it):
	return list(Counter(list(Counter(it).values())).items())

c_plus = count(filt((x for x, y in dis)))
c_minus = count(filt(dis))

print(c_plus - c_minus)


import sys
import math
import bisect
import itertools
from collections import Counter

d = {}
s = {}
n, a, b = list(map(int,sys.stdin.readline().strip().split(' ')))
for n0 in range(n):
	x,vxi,vyi = list(map(int,sys.stdin.readline().strip().split(' ')))
	curr = a*vxi - vyi
	if curr in d:
		if (vxi,vyi) in d[curr]:
			d[curr][(vxi,vyi)] += 1
		else:
			d[curr][(vxi,vyi)] = 1
		s[curr] += 1
	else:
		d[curr] = {(vxi,vyi):1}
		s[curr] = 1

ans = 0
for k,v in list(d.items()):
	for vxy,q in list(v.items()):
		ans += (s[k] - q)*q
print(ans)


	


3

from sys import stdin
from itertools import groupby


def f(line):
    t = line.split()
    return tuple(int(x) for x in t[1:])


n, a, b = [int(x) for x in stdin.readline().split()]
points = sorted(f(line) for line in stdin.readlines()[:n])
groups = [[k, len(tuple(g))] for k, g in groupby(points)]
total = {}
for (x, y), cnt in groups:
    if y - x * a not in total:
        total[y - x * a] = 0
    total[y - x * a] += cnt
ans = 0
for (x, y), cnt in groups:
    if y - x * a not in total:
        continue
    ans += cnt * (total[y - x * a] - cnt)
print(ans)