{"trustable":false,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003e\r\n\t\u003cspan style\u003d\"color: windowtext; text-align: justify;\"\u003eHmm! Here you are asked to do a simple sorting. You will be given N numbers and a positive integer M. You will have to sort the N numbers in ascending order of \u003c/span\u003e\u003cspan class\u003d\"GramE\" style\u003d\"color: windowtext; text-align: justify;\"\u003etheir modulo\u003c/span\u003e\u003cspan style\u003d\"color: windowtext; text-align: justify;\"\u003e M value. If there is a tie between an odd number and an even number (that is \u003c/span\u003e\u003cspan class\u003d\"GramE\" style\u003d\"color: windowtext; text-align: justify;\"\u003etheir modulo\u003c/span\u003e\u003cspan style\u003d\"color: windowtext; text-align: justify;\"\u003e M value is the same) then the odd number will precede the even number. If there is a tie between two odd numbers (that is \u003c/span\u003e\u003cspan class\u003d\"GramE\" style\u003d\"color: windowtext; text-align: justify;\"\u003etheir modulo\u003c/span\u003e\u003cspan style\u003d\"color: windowtext; text-align: justify;\"\u003e M value is the same) then the larger odd number will precede the smaller odd number and if there is a tie between two even numbers (that is their modulo M value is the same) then the smaller even number will precede the larger even number. For remainder value of negative numbers follow the rule of C programming language: A negative number can never have modulus greater than zero. \u003c/span\u003e\u003cspan class\u003d\"GramE\" style\u003d\"color: windowtext; text-align: justify;\"\u003eE.g. \u003cspan style\u003d\"font-family:\u0026quot;Courier New\u0026quot;\"\u003e-100 MOD 3 \u003d -1\u003c/span\u003e, \u003cspan style\u003d\"font-family:\u0026quot;Courier New\u0026quot;\"\u003e-100 MOD 4 \u003d 0\u003c/span\u003e etc.\u003c/span\u003e\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003e\r\n\t\u003cspan style\u003d\"text-align: justify;\"\u003eThe input file contains 20 sets of inputs. Each set starts with two integers N (0\u0026lt;N\u0026lt;\u003d10000) and M (0\u0026lt;M\u0026lt;\u003d10000) which denotes how many numbers are within this set. Each of the next N lines contains one number each. These numbers should all fit in 32-bit signed integer. Input is terminated by a line containing two zeroes.\u003c/span\u003e\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003e\r\n\t\u003cspan style\u003d\"text-align: justify;\"\u003eFor each set of input produce N+1 lines of outputs. The first line of each set contains the value of N and M. The next N lines contain N numbers, sorted according to the rules mentioned above. Print the last two zeroes of the input file in the output file also.\u003c/span\u003e\u003c/p\u003e"}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cpre\u003e\r\n\u003c/pre\u003e\r\n\u003cpre\u003e\r\n15 3\r\n1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\r\n10\r\n11\r\n12\r\n13\r\n14\r\n15\r\n0 0\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cpre\u003e\r\n15 3\r\n15\r\n9\r\n3\r\n6\r\n12\r\n13\r\n7\r\n1\r\n4\r\n10\r\n11\r\n5\r\n2\r\n8\r\n14\r\n0 0\u003c/pre\u003e"}}]}