{"trustable":false,"sections":[{"title":"","value":{"format":"HTML","content":"辉神到了头条以后如鱼得水,甚至做起了自己的小生意。他请了n个人开了n个商店,卖k种物品,有m个供应商,不同的供货商存货不同,不同商店对不同需求量也不同,运输的费用也不同,求满足所有店主要求的最小运输费用,如果不能满足输出“-1”。"}},{"title":"Input","value":{"format":"HTML","content":"\n \u003cdiv class\u003d\"ptx\" lang\u003d\"en-US\"\u003e\n The input consists of multiple test cases. The first line of each test case contains three integers N, M, K (0 \u0026lt; N, M, K \u0026lt; 50), which are described above. The next N lines give the shopkeepers\u0027 orders, with each line containing K integers (there integers are belong to [0, 3]), which represents the amount of goods each shopkeeper needs. The next M lines give the supply places\u0027 storage, with each line containing K integers (there integers are also belong to [0, 3]), which represents the amount of goods stored in that supply place. \n \u003cbr\u003e \n \u003cbr\u003eThen come K integer matrices (each with the size N * M), the integer (this integer is belong to (0, 100)) at the i-th row, j-th column in the k-th matrix represents the cost to transport one unit of k-th goods from the j-th supply place to the i-th shopkeeper. \n \u003cbr\u003e \n \u003cbr\u003eThe input is terminated with three \"0\"s. This test case should not be processed. \n \u003c/div\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\n \u003cdiv class\u003d\"ptx\" lang\u003d\"en-US\"\u003e\n For each test case, if Dearboy can satisfy all the needs of all the shopkeepers, print in one line an integer, which is the minimum cost; otherwise just output \"-1\".\n \u003c/div\u003e"}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cpre class\u003d\"sio\"\u003e1 3 3 \n1 1 1\n0 1 1\n1 2 2\n1 0 1\n1 2 3\n1 1 1\n2 1 1\n\n1 1 1\n3\n2\n20\n\n0 0 0\n\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cpre class\u003d\"sio\"\u003e4\n-1\n\u003c/pre\u003e"}}]}