CF15B.Laser

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Petya is the most responsible worker in the Research Institute. So he was asked to make a very important experiment: to melt the chocolate bar with a new laser device. The device consists of a rectangular field of n×mn×m cells and a robotic arm. Each cell of the field is a 1×11×1 square. The robotic arm has two lasers pointed at the field perpendicularly to its surface. At any one time lasers are pointed at the centres of some two cells. Since the lasers are on the robotic hand, their movements are synchronized — if you move one of the lasers by a vector, another one moves by the same vector.

The following facts about the experiment are known:

  • initially the whole field is covered with a chocolate bar of the size n×mn×m , both lasers are located above the field and are active;
  • the chocolate melts within one cell of the field at which the laser is pointed;
  • all moves of the robotic arm should be parallel to the sides of the field, after each move the lasers should be pointed at the centres of some two cells;
  • at any one time both lasers should be pointed at the field. Petya doesn't want to become a second Gordon Freeman.

You are given nn , mm and the cells (x1,y1)(x_{1},y_{1}) and (x2,y2)(x_{2},y_{2}) , where the lasers are initially pointed at ( xix_{i} is a column number, yiy_{i} is a row number). Rows are numbered from 11 to mm from top to bottom and columns are numbered from 11 to nn from left to right. You are to find the amount of cells of the field on which the chocolate can't be melted in the given conditions.

输入格式

The first line contains one integer number tt (1<=t<=10000)(1<=t<=10000) — the number of test sets. Each of the following tt lines describes one test set. Each line contains integer numbers nn , mm , x1x_{1} , y1y_{1} , x2x_{2} , y2y_{2} , separated by a space ( 2<=n,m<=1092<=n,m<=10^{9} , 1<=x1,x2<=n1<=x_{1},x_{2}<=n , 1<=y1,y2<=m1<=y_{1},y_{2}<=m ). Cells (x1,y1)(x_{1},y_{1}) and (x2,y2)(x_{2},y_{2}) are distinct.

输出格式

Each of the tt lines of the output should contain the answer to the corresponding input test set.

输入输出样例

  • 输入#1

    2
    4 4 1 1 3 3
    4 3 1 1 2 2
    

    输出#1

    8
    2
    
首页