{"trustable":false,"prependHtml":"\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003e有 $n$ 连的军队以及 $m$ 个任务,$m\\ge n$\u003c/p\u003e\n\u003cp\u003e每个连的军队只能完成一项任务,每个任务也只能由一个连的军队来完成\u003c/p\u003e\n\u003cp\u003e如果 $i$ 连的军队选择第 $j$ 项任务,那么完成的效率为 $E_{i,j}$\u003c/p\u003e\n\u003cp\u003e现在已经有了每连军队的分配方案,而现在我们想要更改某些军队的任务,以使得效率总和最大化,同时还要保证被修改任务的军队数量尽可能少\u003c/p\u003e\n\u003cp\u003e输出改变任务的军队的最少数量,以及改变后总效率的最大增量\u003c/p\u003e\n\u003cp\u003e注意处理多组数据\u003c/p\u003e\n\n----------\n\u003cbr\u003e\n\n\u003cscript type\u003d\u0027text/x-mathjax-config\u0027\u003eMathJax.Hub.Config({tex2jax: { inlineMath: [[\u0027$\u0027,\u0027$\u0027]] } }); \u003c/script\u003e\n\u003cscript type\u003d\u0027text/javascript\u0027 src\u003d\u0027https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\u0027\u003e\u003c/script\u003e\n\u003cscript type\u003d\u0027text/javascript\u0027\u003esetTimeout(function(){MathJax.Hub.Queue([\u0027Typeset\u0027, MathJax.Hub, \u0027left_view\u0027]);}, 2000);\u003c/script\u003e\n\u003cdiv class\u003d\"panel_content\"\u003e\n Last year a terrible earthquake attacked Sichuan province. About 300,000 PLA soldiers attended the rescue, also ALPCs. Our mission is to solve difficulty problems to optimization the assignment of troops. The assignment is measure by efficiency, which is an integer, and the larger the better.\n \u003cbr\u003eWe have N companies of troops and M missions, M\u0026gt;\u003dN. One company can get only one mission. One mission can be assigned to only one company. If company i takes mission j, we can get efficiency Eij. \n \u003cbr\u003eWe have a assignment plan already, and now we want to change some companies’ missions to make the total efficiency larger. And also we want to change as less companies as possible.\n\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"For each test case, the first line contains two numbers N and M. N lines follow. Each contains M integers, representing Eij. The next line contains N integers. The first one represents the mission number that company 1 takes, and so on.\n\u003cbr\u003e1\u0026lt;\u003dN\u0026lt;\u003dM\u0026lt;\u003d50, 1\u0026lt;Eij\u0026lt;\u003d10000.\n\u003cbr\u003eYour program should process to the end of file."}},{"title":"Output","value":{"format":"HTML","content":"For each the case print two integers X and Y. X represents the number of companies whose mission had been changed. Y represents the maximum total efficiency can be increased after changing."}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cpre\u003e3 3\n2 1 3\n3 2 4\n1 26 2\n2 1 3\n2 3\n1 2 3\n1 2 3\n1 2\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cpre\u003e2 26\n1 2\u003c/pre\u003e"}}]}