{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"One measure of ``unsortedness\u0027\u0027 in a sequence is the number of pairs of entries that are out of order with respect to each other. For instance, in the letter sequence ``DAABEC\u0027\u0027, this measure is 5, since D is greater than four letters to its right and E is greater than one letter to its right. This measure is called the number of inversions in the sequence. The sequence ``AACEDGG\u0027\u0027 has only one inversion (E and D)---it is nearly sorted---while the sequence ``ZWQM\u0027\u0027 has 6 inversions (it is as unsorted as can be---exactly the reverse of sorted).\r\u003cbr\u003e\r\u003cbr\u003eYou are responsible for cataloguing a sequence of DNA strings (sequences containing only the four letters A, C, G, and T). However, you want to catalog them, not in alphabetical order, but rather in order of ``sortedness\u0027\u0027, from ``most sorted\u0027\u0027 to ``least sorted\u0027\u0027. All the strings are of the same length.\r\u003cbr\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line contains two integers: a positive integer n (0 \u0026lt; n \u0026lt;\u003d 50) giving the length of the strings; and a positive integer m (0 \u0026lt; m \u0026lt;\u003d 100) giving the number of strings. These are followed by m lines, each containing a string of length n."}},{"title":"Output","value":{"format":"HTML","content":"Output the list of input strings, arranged from ``most sorted\u0027\u0027 to ``least sorted\u0027\u0027. Since two strings can be equally sorted, then output them according to the orginal order."}},{"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\u003e10 6\r\nAACATGAAGG\r\nTTTTGGCCAA\r\nTTTGGCCAAA\r\nGATCAGATTT\r\nCCCGGGGGGA\r\nATCGATGCAT\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eCCCGGGGGGA\r\nAACATGAAGG\r\nGATCAGATTT\r\nATCGATGCAT\r\nTTTTGGCCAA\r\nTTTGGCCAAA\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}