{"trustable":false,"prependHtml":"\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 async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cscript type\u003d\u0027text/x-mathjax-config\u0027\u003eMathJax.Hub.Config({tex2jax: { inlineMath: [[\u0027$\u0027,\u0027$\u0027]] } }); \u003c/script\u003e\n\u003cscript type\u003d\u0027text/javascript\u0027 src\u003d\u0027https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\u0027\u003e\u003c/script\u003e\n\u003cscript type\u003d\u0027text/javascript\u0027\u003esetTimeout(function(){MathJax.Hub.Queue([\u0027Typeset\u0027, MathJax.Hub, \u0027left_view\u0027]);}, 2000);\u003c/script\u003e\n\u003cdiv class\u003d\"panel_content\"\u003e\n Here is the question: \n \u003cbr\u003eLYD has n numbers, a \n \u003csub\u003e1\u003c/sub\u003e, a \n \u003csub\u003e2\u003c/sub\u003e, …, a \n \u003csub\u003en\u003c/sub\u003e. At first, their values are 0.\n \u003cbr\u003eHe can implements one of the four following operations at once: \n \u003cbr\u003e(1) Add x to each number between a \n \u003csub\u003el\u003c/sub\u003e and a \n \u003csub\u003er\u003c/sub\u003e inclusive.\n \u003cbr\u003e(2) Multiply x to each number between a \n \u003csub\u003el\u003c/sub\u003e and a \n \u003csub\u003er\u003c/sub\u003e inclusive.\n \u003cbr\u003e(3) Modify numbers between a \n \u003csub\u003el\u003c/sub\u003e and a \n \u003csub\u003er\u003c/sub\u003e inclusive to x.\n \u003cbr\u003e(4) Get the sum of p power among the numbers between a \n \u003csub\u003el\u003c/sub\u003e and a \n \u003csub\u003er\u003c/sub\u003e inclusive. That is, calculate a \n \u003csub\u003el\u003c/sub\u003e \n \u003csup\u003ep\u003c/sup\u003e+a \n \u003csub\u003el+1\u003c/sub\u003e \n \u003csup\u003ep\u003c/sup\u003e+…+a \n \u003csub\u003er\u003c/sub\u003e \n \u003csup\u003ep\u003c/sup\u003e. \n \u003cbr\u003eLYD wants to ask you to help him. \n \u003cbr\u003e \n\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"There are no more than 10 test cases. \n\u003cbr\u003eFor each case, the first line contains two numbers n and m, meaning that there are n integers and m operations. 1 \u0026lt;\u003d n, m \u0026lt;\u003d 100,000. \n\u003cbr\u003eFollowing m lines contains an operation. Each line has four integers o, l, r, x/p. o means the kind of operation. The meaning of l, r, x and p are as mentioned above. (1 \u0026lt;\u003d o \u0026lt;\u003d 4, 1 \u0026lt;\u003d l \u0026lt;\u003d r \u0026lt;\u003d n, 1 \u0026lt;\u003d x \u0026lt;\u003d 10,000, 1 \u0026lt;\u003d p \u0026lt;\u003d 3) \n\u003cbr\u003eThe input ends with 0 0. \n\u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"For each operation 4, output a single integer in one line representing the result. The answer may be quite large. You just need to calculate the remainder of the answer when divided by 10007."}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cpre\u003e5 5\n3 3 5 7\n1 2 4 4\n4 1 5 2\n2 2 5 8\n4 3 5 3\n0 0\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cpre\u003e307\n7489\u003c/pre\u003e"}}]}