{"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\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027$$$$$$\u0027, right: \u0027$$$$$$\u0027, display: true},\n {left: \u0027$$$\u0027, right: \u0027$$$\u0027, display: false},\n {left: \u0027$$\u0027, right: \u0027$$\u0027, display: true},\n {left: \u0027$\u0027, right: \u0027$\u0027, display: false}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"从前"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe first line of the input contains two integers \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003en\u003c/i\u003e\u003c/span\u003e and \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003eq\u003c/i\u003e\u003c/span\u003e (\u003cspan class\u003d\"tex-span\"\u003e4 ≤ \u003ci\u003en\u003c/i\u003e ≤ 200 000\u003c/span\u003e, \u003cspan class\u003d\"tex-span\"\u003e1 ≤ \u003ci\u003eq\u003c/i\u003e ≤ 200 000\u003c/span\u003e)\u0026nbsp;— the length of the string \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003es\u003c/i\u003e\u003c/span\u003e and the number of queries respectively.\u003c/p\u003e\n\u003cp\u003eThe second line contains a string \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003es\u003c/i\u003e\u003c/span\u003e of length \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003en\u003c/i\u003e\u003c/span\u003e. Every character is one of digits \u0027\u003cspan class\u003d\"tex-font-style-tt\"\u003e0\u003c/span\u003e\u0027–\u0027\u003cspan class\u003d\"tex-font-style-tt\"\u003e9\u003c/span\u003e\u0027.\u003c/p\u003e\n\u003cp\u003eThe \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003ei\u003c/i\u003e\u003c/span\u003e-th of next \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003eq\u003c/i\u003e\u003c/span\u003e lines contains two integers \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003ea\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e\u003ci\u003ei\u003c/i\u003e\u003c/sub\u003e\u003c/span\u003e and \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003eb\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e\u003ci\u003ei\u003c/i\u003e\u003c/sub\u003e\u003c/span\u003e (\u003cspan class\u003d\"tex-span\"\u003e1 ≤ \u003ci\u003ea\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e\u003ci\u003ei\u003c/i\u003e\u003c/sub\u003e ≤ \u003ci\u003eb\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e\u003ci\u003ei\u003c/i\u003e\u003c/sub\u003e ≤ \u003ci\u003en\u003c/i\u003e\u003c/span\u003e), describing a substring in the \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003ei\u003c/i\u003e\u003c/span\u003e-th query.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003eFor each query print the ugliness of the given substring.\u003c/p\u003e"}},{"title":"Examples","value":{"format":"HTML","content":"\u003cdiv class\u003d\"sample-test\"\u003e\n \u003cdiv class\u003d\"input\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Input\n \u003c/div\u003e\n \u003cpre\u003e8 3\u003cbr\u003e20166766\u003cbr\u003e1 8\u003cbr\u003e1 7\u003cbr\u003e2 8\u003cbr\u003e\u003c/pre\u003e\n \u003c/div\u003e\n \u003cdiv class\u003d\"output\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Output\n \u003c/div\u003e\n \u003cpre\u003e4\u003cbr\u003e3\u003cbr\u003e-1\u003cbr\u003e\u003c/pre\u003e\n \u003c/div\u003e\n \u003cdiv class\u003d\"input\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Input\n \u003c/div\u003e\n \u003cpre\u003e15 5\u003cbr\u003e012016662091670\u003cbr\u003e3 4\u003cbr\u003e1 14\u003cbr\u003e4 15\u003cbr\u003e1 13\u003cbr\u003e10 15\u003cbr\u003e\u003c/pre\u003e\n \u003c/div\u003e\n \u003cdiv class\u003d\"output\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Output\n \u003c/div\u003e\n \u003cpre\u003e-1\u003cbr\u003e2\u003cbr\u003e1\u003cbr\u003e-1\u003cbr\u003e-1\u003cbr\u003e\u003c/pre\u003e\n \u003c/div\u003e\n \u003cdiv class\u003d\"input\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Input\n \u003c/div\u003e\n \u003cpre\u003e4 2\u003cbr\u003e1234\u003cbr\u003e2 4\u003cbr\u003e1 2\u003cbr\u003e\u003c/pre\u003e\n \u003c/div\u003e\n \u003cdiv class\u003d\"output\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Output\n \u003c/div\u003e\n \u003cpre\u003e-1\u003cbr\u003e-1\u003cbr\u003e\u003c/pre\u003e\n \u003c/div\u003e\n\u003c/div\u003e"}},{"title":"Note","value":{"format":"HTML","content":"\u003cp\u003eIn the first sample:\u003c/p\u003e\n\u003cul\u003e \n \u003cli\u003e In the first query, \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003eugliness\u003c/i\u003e(\u003c/span\u003e\"\u003cspan class\u003d\"tex-font-style-tt\"\u003e20166766\u003c/span\u003e\"\u003cspan class\u003d\"tex-span\"\u003e) \u003d 4\u003c/span\u003e because all four sixes must be removed. \u003c/li\u003e\n \u003cli\u003e In the second query, \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003eugliness\u003c/i\u003e(\u003c/span\u003e\"\u003cspan class\u003d\"tex-font-style-tt\"\u003e2016676\u003c/span\u003e\"\u003cspan class\u003d\"tex-span\"\u003e) \u003d 3\u003c/span\u003e because all three sixes must be removed. \u003c/li\u003e\n \u003cli\u003e In the third query, \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003eugliness\u003c/i\u003e(\u003c/span\u003e\"\u003cspan class\u003d\"tex-font-style-tt\"\u003e0166766\u003c/span\u003e\"\u003cspan class\u003d\"tex-span\"\u003e) \u003d - 1\u003c/span\u003e because it\u0027s impossible to remove some digits to get a nice string. \u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eIn the second sample:\u003c/p\u003e\n\u003cul\u003e \n \u003cli\u003e In the second query, \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003eugliness\u003c/i\u003e(\u003c/span\u003e\"\u003cspan class\u003d\"tex-font-style-tt\"\u003e01201666209167\u003c/span\u003e\"\u003cspan class\u003d\"tex-span\"\u003e) \u003d 2\u003c/span\u003e. It\u0027s optimal to remove the first digit \u0027\u003cspan class\u003d\"tex-font-style-tt\"\u003e2\u003c/span\u003e\u0027 and the last digit \u0027\u003cspan class\u003d\"tex-font-style-tt\"\u003e6\u003c/span\u003e\u0027, what gives a string \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e010166620917\u003c/span\u003e\", which is nice. \u003c/li\u003e\n \u003cli\u003e In the third query, \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003eugliness\u003c/i\u003e(\u003c/span\u003e\"\u003cspan class\u003d\"tex-font-style-tt\"\u003e016662091670\u003c/span\u003e\"\u003cspan class\u003d\"tex-span\"\u003e) \u003d 1\u003c/span\u003e. It\u0027s optimal to remove the last digit \u0027\u003cspan class\u003d\"tex-font-style-tt\"\u003e6\u003c/span\u003e\u0027, what gives a nice string \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e01666209170\u003c/span\u003e\". \u003c/li\u003e\n\u003c/ul\u003e"}}]}