LearnToCP
Sign in
Navigation
HomeRoadmapProblemsAbout Us
Theory
Contest Knowledge
Selecting an IDEInteractive TasksOutput-Only Tasks
Basics
Your First ProgramData types and IOC++ syntaxModuloFunctionsVectorsMatricesTime Complexity
Sorting
SortingCounting sortRadix Sort
Optimization Techniques
Two PointersSum of numbers 1 to nPrefix sumBinary SearchGreedyBinary Search FunctionsBinary Search by AnswerDivide and Conquer
Binary Numbers
Binary NumbersNumbers in codeBitwise OperationsBitmasks
Math
Binary ExponentiationPrime NumbersPrime FactorizationGCD and LCMSieve of EratosthenesModified Sieve
Data Structures
StringsStackQueueMapsSetsPriority QueueCustom Criteria for FunctionsSegment TreesFenwick TreesSparse TablesUnion FindSqrt Decomposition
Combinatorics
Addition PrincipleMultiplication PrincipleCombinatoric ObjectsInclusion Exclusion Principle
Geometry
Geometry BasicsVectorsCross and Dot ProductLinesPolygonsConvex Hull
Recursion
PointersRecursionGenerating Combinatoric Objects
Dynamic Programming
About DPDP problemsTree DPBitmask DP
Graph Theory
GraphsDFS and BFSShortest PathsTreesTopological SortingDijkstra's AlgorithmMinimum Spanning TreesShortest Path Algorithms
Advanced Graph Theory
BiconnectivityStrongly Connected ComponentsBipartite GraphGraph FlowAugmenting PathsFlow - Minimum Cut DualityHeavy-Light DecompositionCentroid Decomposition
Advanced Data Structures
2D and 3D Segment TreesLazy PropagationImplicit Segment TreesPersistent Segment TreesLowest Common AncestorTrieBalanced Binary Search TreesMo's Algorithm

Two Banks

Super EasyProblem #42
Time LimitMemoryInputOutput
1 s64 MBstdinstdout

There are three answers, not two - a house can stand on the river itself.

A river runs through a town in a perfectly straight line. On the map the river is given by two different points A and B that it passes through, and it continues forever in both directions.

The town wants to know how its houses are split between the two banks. A house is on the left bank if it lies to the left of somebody standing at A and looking towards B, and on the right bank if it lies to their right. Some houses were built right on top of the river and belong to neither bank.

Your task is to count the houses on each bank.

Input

The first line contains a single integer t - the number of testcases.

  • The first line of each testcase contains a single integer n - the number of houses.
  • The second line contains four integers Ax​, Ay​, Bx​, By​ - the two points that define the river. The points are different.
  • Each of the next n lines contains two integers xi​ and yi​ - the position of one house.

Output

For every testcase print a single line with three integers: the number of houses on the left bank, the number on the right bank, and the number standing on the river.

Example

Input
2
5
0 0 4 4
0 4
1 4
4 0
2 2
5 1
3
0 0 1000000000 1000000000
1000000000 -1000000000
-1000000000 1000000000
5 5
Output
2 2 1
1 1 1

In the first testcase the river goes diagonally through the origin. The houses at (0,4) and (1,4) are above it, the houses at (4,0) and (5,1) are below it, and the house at (2,2) is standing in the water.

Constraints

1≤t≤10
1≤n≤105
−109≤Ax​,Ay​,Bx​,By​≤109
−109≤xi​,yi​≤109
A=B
n1​+n2​+…+nt​≤2⋅105

Submit your solution

Sign in to submit your solution and track your progress.

Sign in to submit