{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eDo you think that being eccentric is easy? This is not the case when you\u0027re a number.\u003c/p\u003e\n\n\u003cp\u003eThe degree of eccentricity of a \u003cstrong\u003e2N\u003c/strong\u003e-digit integer \u003cstrong\u003eX\u003c/strong\u003e (possibly with leading zeroes) is defined as the smallest possible value of |\u003cstrong\u003ea\u003c/strong\u003e + \u003cstrong\u003eb\u003c/strong\u003e - \u003cstrong\u003e10^N\u003c/strong\u003e| for some \u003cstrong\u003eN\u003c/strong\u003e-digit integers \u003cstrong\u003ea\u003c/strong\u003e and \u003cstrong\u003eb \u003c/strong\u003e(again, possibly with leading zeroes) such that \u003cstrong\u003eS_d\u003c/strong\u003e(\u003cstrong\u003eX\u003c/strong\u003e) \u003d \u003cstrong\u003eS_d\u003c/strong\u003e(\u003cstrong\u003ea\u003c/strong\u003e) + \u003cstrong\u003eS_d\u003c/strong\u003e(\u003cstrong\u003eb\u003c/strong\u003e) holds for every digit \u003cstrong\u003ed\u003c/strong\u003e, where \u003cstrong\u003eS_d\u003c/strong\u003e(\u003cstrong\u003eP\u003c/strong\u003e) (\u003cstrong\u003e0\u003c/strong\u003e ≤ \u003cstrong\u003ed\u003c/strong\u003e ≤ \u003cstrong\u003e9\u003c/strong\u003e) is the number of occurrences of digit \u003cstrong\u003ed\u003c/strong\u003e in the decimal representation of \u003cstrong\u003eP\u003c/strong\u003e. For example, the degree of eccentricity of amusing numbers (see problem \u003ca href\u003d\"/problems/6439\"\u003eCounting Amusing Numbers\u003c/a\u003e) is equal to \u003cstrong\u003e0\u003c/strong\u003e, while the degree of eccentricity of \u003cstrong\u003e192747\u003c/strong\u003e equals to \u003cstrong\u003e7\u003c/strong\u003e (|\u003cstrong\u003e274\u003c/strong\u003e + \u003cstrong\u003e719\u003c/strong\u003e - \u003cstrong\u003e1000\u003c/strong\u003e| \u003d \u003cstrong\u003e7\u003c/strong\u003e).\u003c/p\u003e\n\n\u003cp\u003eYou are given a bunch of numbers of even lengths. Find the degree of eccentricity of each of them.\u003c/p\u003e\n\n\u003cp\u003e\u003ch2\u003eInput\u003c/h2\u003e\u003c/p\u003e\n\n\u003cp\u003eThe first line contains the number of test cases \u003cstrong\u003eT\u003c/strong\u003e (\u003cstrong\u003e1\u003c/strong\u003e ≤ \u003cstrong\u003eT\u003c/strong\u003e ≤ \u003cstrong\u003e1000\u003c/strong\u003e). Each of the next \u003cstrong\u003eT\u003c/strong\u003e lines contains an integer number of an even length (possibly with leading zeroes). The total length of all numbers (except \u003cstrong\u003eT\u003c/strong\u003e) doesn\u0027t exceed \u003cstrong\u003e10^6\u003c/strong\u003e.\u003c/p\u003e\n\n\u003cp\u003e\u003ch2\u003eOutput\u003c/h2\u003e\u003c/p\u003e\n\n\u003cp\u003eFor each test case print one line containing the degree of eccentricity of the corresponding number.\u003c/p\u003e\n\n"}},{"title":"Example","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\u003e3\n9820\n192747\n000001\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e0\n7\n900\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}