The first line contains three integers n, L, t (0≤n≤1000000, 2≤L≤1000000000, 0<=t<=1000000) − the number of stones on the line is n,the length of the line is L meter, and the magic circle will disappear after t seconds.
The following n lines contain description of magic stones on the line. Each i-th of these lines contains two space-separated integers x[i] and d[i] (0<x[i]<L, d[i]∈{1,2} for i<=n), which stand for initial position and direction of motion(1 means from 0 to L, 2 means from L to 0.).
Output a number indicating the amount of the magic stones that AFei will eventually be able to obtain.
The stones are A(1,1), B(5,2), C(6,1), D(9,2).
After 1s, they become A(2,1), B(4,2), C(7,1), D(8,2);
After 2s, they become A(3,2), B(3,1), C(7,2), D(8,1);
After 3s, they become A(2,2), B(4,1), C(6,2), D(9,1);
After 4s, they become A(1,2), B(5,2), C(5,1), D reach L and disappears;
After 5s, they become A reach 0 and disappears, B(4, 2), C(6,1), D disappeared;
After 6s, they become A disappeared, B(3, 2), C(7, 1), D disappeared.
AFei finially gets the first one, B and C.
1,Input guarantees that there will not be two magic stones in one location.
2,If stone A and stone B are located at 4 and 5, respectively, and A's direction is 1, B's direction is 2. Then next second, the position of the two stones have not changed, but they have gone in the opposite direction.