Medium Math > Basic Math

You probably heard of number pyramid. Its looks like this: ![enter image description here][1] Easy and cute, isn’t it? Now You have to find summation of a sub triangle. For example: ![enter image description here][2] Edge of this sub-triangle is - row 2, column 2 and value 3 - row 4, column 2 and value 8 - row 4, column 4 and value 10 And summation of this sub-triangle is 41. You can assume the sub-triangle to be equilateral triangle, Every side of the sub-triangle contains same amount of numbers. And the result should be a positive number. Input: ------ Input starts with an integer **T (1<= T <=3000)**, denoting the number of test cases. Each case contains 3 lines, denoting the **3** points of the triangle. Each Line will have **2** numbers: **X** and **Y** , denoting a point of the sub-triangle. You can safely assume that all point of triangle will be valid and **1** <= **Y** <= **X** <= **3000** . Point **X** , **Y** means number of **X** th row and **Y** th column. They are not necessarily ordered. Output: ------- For each case of input, output the summation of the sub-triangle modulo 1E9 + 7 ( 1000000007 ) Sample Input ------------ 2 2 2 4 2 4 4 1 1 2 1 2 2 Sample Output ------------- 41 6 [1]: https://s3-ap-southeast-1.amazonaws.com/devskillimagestorage/questionimages/d95dd904-ac1e-c7e1-2144-08d53bfa26ec_ebfcf2ea60ad4289b8e9723ef16407d2_W297xH160.png [2]: https://s3-ap-southeast-1.amazonaws.com/devskillimagestorage/questionimages/c2afb591-fa89-cd57-d820-08d53bfa31c0_375f978bfa5c454596ad3cbb031cca11_W263xH145.png

S. M. Riasat Ali