编程介的小学生 2017-02-06 15:35 采纳率: 20.5%
浏览 830
已采纳

Escape

Description

Hamilton, the famous thief, plans a bank robbery in L.A. When searching for the escape route, he takes two main factors into consideration. First, he cannot pass through any intersection twice since the police will set up force at any intersection after he passes it for the first time. Second, as, in America, vehicles are driven on the right side, it is too risk for Hamilton to take a left turn at intersections when escaping. So he will always drive straight ahead or turn right when he comes to a intersection.

Hamilton is planning his escape route. He pays you, his partner, to calculate the number of different ways which leads him to his shelter. He gives you the map of the city, which looks like grids, with only streets leading in East-West direction and South-North direction. His starting position is (0, 0) which is the South-West corner of the city and his shelter is located at (x, y) which stands for the intersection of the (x+1)th South-North direction street and the (y+1)th East-West direction street. Moreover, when he starts at (0, 0), he is heading north, and of course, he can make a right turn there as well.

As the total number of different ways might be very large, you are asked to give the number's residue modulo 100000007.

Input

The first line of input contains N(N<=100), the number of test cases. Each of the following lines describes one test case. Each line consists of four integers, X, Y, x, y(0<X,Y≤2000, 0≤x≤X, 0≤y≤Y), which (X, Y) is the North-East corner of the city and (x, y) is the location of Hamilton's shelter. The famous thief, of course, cannot driver out of the city.

Output

For each test case, print one line with a single integer which is the corresponding answer.

Sample Input

3
3 4 0 0
3 4 1 0
3 4 1 1
Sample Output

1
13
16

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-02-13 15:38
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度