Soldiers and Castles
题号:NC245410
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

First of all, you are given a positive integer k(k ≤ 105 ). There are n(1 ≤ n ≤ 200) soldiers on the plane, whose coordinates (a1, b1), . . . ,(an, bn) satisfy −k ≤ ai , bi ≤ 0 and ai + bi = −k. Moreover, n castles, whose coordinates (c1, d1), . . . ,(cn, dn) satisfy 0 ≤ ci , di ≤ k and ci + di = k, are on the plane.
Now, every soldier needs to choose a castle and leave for it. For every step, the soldier located at (x, y) can go to (x+ 1, y) or (x, y+ 1). In order to avoid stampedes, we require that the paths of any two soldiers should not intersect, including the starting and ending points. Furthermore, any soldier cannot go above y −x = k or beneath y −x = −k. Calculate how many ways the can walk, and output the answer modulo 109 + 7.

输入描述:

The fifirst line contains two integers n and k.
Each of the next n lines contains four integers ai , bi , ci , di .

输出描述:

Output one line with an integer, indicating the answer modulo 109 + 7.
示例1

输入

复制
2 2
-1 -1 0 2
0 -2 2 0

输出

复制
3
示例2

输入

复制
2 2
-1 -1 1 1
-2 0 1 1

输出

复制
0