{"trustable":true,"sections":[{"title":"","value":{"format":"MD","content":"You are given an **m x n** grid containing an integer in each cell. You have a software that sends rays thorough each diagonal and calculates the sum of all the diagonals. The software sends the rays in two phases, in first phase; it sends **n + m - 1** rays as in fig 1, in second phase; it sends **n + m - 1** rays as in fig 2. When a ray completes its cells, it calculates the summation of the integers in the cells it has visited. For example, you are given a **7 x 6** grid. Then the rays are:\n\n\n\n| ![Scan 1][1] | ![Scan 2][2] |\n| :-----------------------------------------: | :---------------------: |\n| **Fig 1:** order of the rays in first phase | **Fig 2:** order of the rays in second phase |\n\n\n\nEach of the integers in the cells lies in the range **[1, 100]**. Now you are given the summation found by the rays in both phases, your task is to generate the grid.\n\n[1]: https://static.lightoj.com/images/problem-1263-diag_sum_1-1605689980555.png\n[2]: https://static.lightoj.com/images/problem-1263-diag_sum_2-1605690092847.png\n"}},{"title":"Input","value":{"format":"MD","content":"Input starts with an integer **T (\u0026le; 50)**, denoting the number of test cases.\n\nEach case starts with a line containing two integers: **m** and **n (1 \u0026le; m, n \u0026le; 50)**. The next line contains **n + m - 1** integers (space separated) denoting the summation found by the rays in phase 1. The next line contains **n + m - 1** integers (space separated) denoting the summation found by the rays in phase 2. You can assume that these values are generated from a board which follows the restrictions described above."}},{"title":"Output","value":{"format":"MD","content":"For each case, print the case number in a line. Then print the grid using the following format. Print **m** lines, each containing **n** integers, and two consecutive integers should be separated by a single space. Since there can be many solutions, print any valid one."}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e1\n2 3\n2 8 11 5\n9 12 4 1\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eCase 1:\n2 7 9\n1 2 5\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Note","value":{"format":"MD","content":"This is a special judge problem; wrong output format may cause \u0027wrong answer\u0027."}}]}