{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eOne traveler travels among cities. He has to pay for this while he can get some incomes.\u003c/p\u003e\u003cp\u003eNow there are n cities, and the traveler has m days for traveling. Everyday he may go to another city or stay there and pay some money. When he come to a city ,he can get some money. Even when he stays in the city, he can also get the next day\u0027s income. All the incomes may change everyday. The traveler always starts from city 1.\u003c/p\u003e\u003cp\u003eNow is your turn to find the best way for traveling to maximize the total income. \u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThere are multiple cases.\u003c/p\u003e\u003cp\u003eThe first line of one case is two positive integers, n and m .n is the number of cities, and m is the number of traveling days. There follows n lines, one line n integers. The j integer in the i line is the expense of traveling from city i to city j. If i equals to j it means the expense of staying in the city.\u003c/p\u003e\u003cp\u003eAfter an empty line there are m lines, one line has n integers. The j integer in the i line means the income from city j in the i day.\u003c/p\u003e\u003cp\u003eThe input is finished with two zeros.\u003cbr\u003en,m\u0026lt;100.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"You must print one line for each case. It is the max income."}},{"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\u003e3 3\r\n3 1 2\r\n2 3 1\r\n1 3 2\r\n\r\n2 4 3\r\n4 3 2\r\n3 4 2\r\n\r\n0 0\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e8\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Hint","value":{"format":"HTML","content":"In the Sample, the traveler can first go to city 2, then city 1, and finish his travel in city 1. The total income is:\u003cbr\u003e-1+4-2+4-1+4\u003d8;"}}]}