|
||||||||||
Unversity RankingsTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 277 Accepted Submission(s): 97 Problem Description At present, the university rankings are very popublar.They help senior high school students to choose universities for study.For example,you can find the CHINESE UNIVERSITY RANGKINGS at http://www.netbig.com/. As we know ,a university ususally has many different departments,such as department of Language(FLS).some of them are quit good when comparing to other universities,but others are not.So,most of universities'rangkings are are composed of several ranking lists, each list for one department. But here comes a problem that sometimes it's hard to determine which universities is better,when comparing two universities with each othe.Fortunately,Doctor Bob has advanced a new concept named "absolutely better",with which the problem above can be solved. Now,here is a an example to explain the concept "absolutely better": Assum that there are three universities (X,Y,Z)and every university has three department:CS,EE and FLS.And the rangkings of the departments are as the followed: The rankings of the CS:X>Y>Z(X>Y means X has a better CS department than Y) The rankings of the EE:X>Z>Y The rankings of the FLS:Z>X>y Obviously,each each department of University X is better than that of University Y. Then,it's called that X is absolutely better than Y.Using the "absolutely better"concept, it becomes better to compare some paires of Universities. Now Bob has the complete rangkings of different departments of many universities,and he wants to find k universities(U1,u2,....Uk)such that Ui is absolutely better that Uj(for any i<j). Input The first line of the input is a positive integer C.C is the number of test cases followed. The first line of each test case is two positive integers N,M(0<N,M<=100),N is the number of the universities and M is the number of departments.And then M lines follow.The i(th)(1<=i<=M)line contains N numbers Ui(1<=i<=N,1<=Ui<=N),indicating the ranking of the i(th)department.If Universitites Ui preceds to University Uj in line k(th department, then the k(th)department do Ui is better than k(th) department of Uj. Output The output should consist fo C lines, one lines for each test case.Each line only constains one integer- the maximum values fo k as descriped above.No redundant spaces are needed. Sample Input
Sample Output
Source | ||||||||||
|