F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Faraway

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 829    Accepted Submission(s): 436


Problem Description
$n$ soldiers are dispatched to somewhere in Byteland. These soldiers are going to set off now, but the target location is not so clear.

Assume the target location is at $(x_e,y_e)$, it is clear that $x_e,y_e$ are both non-negative integers within $[0,m]$. For the $i$-th soldier, the only thing he knows is that $(|x_i-x_e|+|y_i-y_e|)\bmod k_i=t_i$.

To find the correct target location, these soldiers are working on the information they have now. Please write a program to figure out the number of possible target locations.
 

Input
The first line of the input contains an integer $T(1\leq T\leq 10)$, denoting the number of test cases.

In each test case, there are two integers $n,m(1\leq n\leq 10,1\leq m\leq 10^9)$ in the first line, denoting the number of soldiers and the upper bound of $x_e,y_e$.

For the next $n$ lines, each line contains four integers $x_i,y_i,k_i,t_i(0\leq x_i,y_i\leq m,2\leq k_i\leq 5,0\leq t_i<k_i)$, denoting what each soldier knows.
 

Output
For each test case, print a single line containing an integer, denoting the number of possible target locations.
 

Sample Input
2 2 5 1 2 4 2 3 1 2 1 2 5 1 2 4 2 1 2 4 3
 

Sample Output
10 0
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-03-29 19:07:55, Gzip enabled