{"trustable":false,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript type\u003d\"text/javascript\" async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS_HTML-full\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"MD","content":"Why all the problem statements are so big and unnecessary, you ask. Well, then take this one - as straight as a bamboo.\n\nYou are given **N** integers. All of them will have the same number of digits. You can rearrange the digits in the integers (the same digit rearrange should be done on all the integers). Leading zeroes are allowed both in the initial integers and the integers resulting from the rearranging of digits. You want to minimize the difference between the largest and the smallest integer."}},{"title":"Input","value":{"format":"MD","content":"The first line contains integers **N (1 ≤ N ≤ 8)** and **M (1 ≤ M ≤ 8)**, denoting the number of integers and the number of digits in the integers, respectively. Next **N** lines each contain an **M**-digit positive integer."}},{"title":"Output","value":{"format":"MD","content":"Print a single number the minimally possible difference between the largest and the smallest number after the digits are rearranged in all integers by the same rule."}},{"title":"Sample Input","value":{"format":"MD","content":"```\n3 3\n010\n909\n012\n```"}},{"title":"Sample Output","value":{"format":"MD","content":"```\n3\n```"}}]}