{"raw_statement":[{"iden":"statement","content":"Copying large hexadecimal (base 16) strings by hand can be error prone, but that doesn't stop people from doing it. You've discovered a bug in the code that was likely caused by someone making a mistake when copying such a string. You suspect that whoever copied the string did not change any of the digits in the string, nor the length of the string, but may have permuted the digits arbitrarily. For example, if the original string was 0_abc_ they may have changed it to _a_0_cb_ or 0_bca_, but not _abc_ or 0_abb_.\n\nUnfortunately you don't have access to the original string nor the copied string, but you do know the length of the strings and their numerical absolute difference. You will be given this difference as a hexadecimal string _S_, which has been zero-extended to be equal in length to the original and copied strings. Determine the smallest possible numerical value of the original string."},{"iden":"input","content":"Input will contain a hexadecimal string _S_ consisting only of digits 0 to 9 and lowercase English letters from _a_ to _f_, with length at most 14. At least one of the characters is non-zero."},{"iden":"output","content":"If it is not possible, print \"_NO_\" (without quotes).\n\nOtherwise, print the lowercase hexadecimal string corresponding to the smallest possible numerical value, including any necessary leading zeros for the length to be correct."},{"iden":"examples","content":"Input\n\nf1e\n\nOutput\n\nNO\n\nInput\n\n0f1e\n\nOutput\n\n00f1\n\nInput\n\n12d2c\n\nOutput\n\n00314"},{"iden":"note","content":"The numerical value of a hexadecimal string is computed by multiplying each digit by successive powers of 16, starting with the rightmost digit, which is multiplied by 160. Hexadecimal digits representing values greater than 9 are represented by letters: _a_ = 10, _b_ = 11, _c_ = 12, _d_ = 13, _e_ = 14, _f_ = 15.\n\nFor example, the numerical value of 0_f_1_e_ is 0·163 + 15·162 + 1·161 + 14·160 = 3870, the numerical value of 00_f_1 is 0·163 + 0·162 + 15·161 + 1·160 = 241, and the numerical value of 100_f_ is 1·163 + 0·162 + 0·161 + 15·160 = 4111. Since 3870 + 241 = 4111 and 00_f_1 is a permutation of 100_f_, 00_f_1 is a valid answer to the second test case."}],"translated_statement":[{"iden":"statement","content":"手工复制大型十六进制（基数为16）字符串容易出错，但这并不能阻止人们这样做。你发现了一个很可能由某人在复制此类字符串时出错而导致的程序漏洞。你怀疑复制字符串的人没有更改字符串中的任何数字，也没有改变字符串的长度，但可能对数字进行了任意排列。例如，如果原始字符串是 #cf_span[0abc]，他们可能将其改为 #cf_span[a0cb] 或 #cf_span[0bca]，但不会改为 #cf_span[abc] 或 #cf_span[0abb]。\n\n不幸的是，你无法访问原始字符串或复制后的字符串，但你知道字符串的长度以及它们的数值绝对差值。你将获得这个差值作为十六进制字符串 #cf_span[S]，该字符串已通过补零扩展至与原始字符串和复制字符串长度相等。请确定原始字符串可能的最小数值。\n\n输入将包含一个仅由数字 #cf_span[0] 到 #cf_span[9] 和小写英文字母 #cf_span[a] 到 #cf_span[f] 组成的十六进制字符串 #cf_span[S]，长度最多为 #cf_span[14]。至少有一个字符是非零的。\n\n如果不可能，请输出 \"_NO_\"（不含引号）。\n\n否则，请输出对应于可能的最小数值的十六进制字符串（小写），包括为保证长度正确所需的任何前导零。\n\n十六进制字符串的数值通过将每个数字乘以连续的 16 的幂次计算得出，从最右边的数字开始，该数字乘以 #cf_span[160]。表示大于 #cf_span[9] 的值的十六进制数字用字母表示：#cf_span[a = 10, b = 11, c = 12, d = 13, e = 14, f = 15]。\n\n例如，#cf_span[0f1e] 的数值是 #cf_span[0·163 + 15·162 + 1·161 + 14·160 = 3870]，#cf_span[00f1] 的数值是 #cf_span[0·163 + 0·162 + 15·161 + 1·160 = 241]，而 #cf_span[100f] 的数值是 #cf_span[1·163 + 0·162 + 0·161 + 15·160 = 4111]。由于 #cf_span[3870 + 241 = 4111] 且 #cf_span[00f1] 是 #cf_span[100f] 的一个排列，因此 #cf_span[00f1] 是第二个测试用例的有效答案。"},{"iden":"input","content":"输入将包含一个仅由数字 #cf_span[0] 到 #cf_span[9] 和小写英文字母 #cf_span[a] 到 #cf_span[f] 组成的十六进制字符串 #cf_span[S]，长度最多为 #cf_span[14]。至少有一个字符是非零的。"},{"iden":"output","content":"如果不可能，请输出 \"_NO_\"（不含引号）。否则，请输出对应于可能的最小数值的十六进制字符串（小写），包括为保证长度正确所需的任何前导零。"},{"iden":"examples","content":"输入\nf1e\n输出\nNO\n\n输入\n0f1e\n输出\n00f1\n\n输入\n12d2c\n输出\n00314"},{"iden":"note","content":"十六进制字符串的数值通过将每个数字乘以连续的 16 的幂次计算得出，从最右边的数字开始，该数字乘以 #cf_span[160]。表示大于 #cf_span[9] 的值的十六进制数字用字母表示：#cf_span[a = 10, b = 11, c = 12, d = 13, e = 14, f = 15]。\n\n例如，#cf_span[0f1e] 的数值是 #cf_span[0·163 + 15·162 + 1·161 + 14·160 = 3870]，#cf_span[00f1] 的数值是 #cf_span[0·163 + 0·162 + 15·161 + 1·160 = 241]，而 #cf_span[100f] 的数值是 #cf_span[1·163 + 0·162 + 0·161 + 15·160 = 4111]。由于 #cf_span[3870 + 241 = 4111] 且 #cf_span[00f1] 是 #cf_span[100f] 的一个排列，因此 #cf_span[00f1] 是第二个测试用例的有效答案。"}],"sample_group":[],"show_order":[],"formal_statement":null,"simple_statement":null,"has_page_source":false}