{"trustable":true,"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":"\u003cdiv class\u003d\"panel_content\"\u003e bobo has a tree, whose vertices are conveniently labeled by 1,2,…,n. At the very begining, the i-th vertex is assigned with weight w\u003csub\u003ei\u003c/sub\u003e.\u003cbr\u003e\u003cbr\u003e There are q operations. Each operations are of the following 2 types:\u003cbr\u003e\u003cbr\u003e Change the weight of vertex v into x (denoted as \"! v x\"),\u003cbr\u003e Ask the total weight of vertices whose distance are no more than d away from vertex v (denoted as \"? v d\").\u003cbr\u003e\u003cbr\u003e Note that the distance between vertex u and v is the number of edges on the shortest path between them.\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":" The input consists of several tests. For each tests:\u003cbr\u003e\u003cbr\u003e The first line contains n,q (1≤n,q≤10\u003csup\u003e5\u003c/sup\u003e). The second line contains n integers w\u003csub\u003e1\u003c/sub\u003e,w\u003csub\u003e2\u003c/sub\u003e,…,w\u003csub\u003en\u003c/sub\u003e (0≤w\u003csub\u003ei\u003c/sub\u003e≤10\u003csup\u003e4\u003c/sup\u003e). Each of the following (n - 1) lines contain 2 integers a\u003csub\u003ei\u003c/sub\u003e,b\u003csub\u003ei\u003c/sub\u003e denoting an edge between vertices a\u003csub\u003ei\u003c/sub\u003e and b\u003csub\u003ei\u003c/sub\u003e (1≤a\u003csub\u003ei\u003c/sub\u003e,b\u003csub\u003ei\u003c/sub\u003e≤n). Each of the following q lines contain the operations (1≤v≤n,0≤x≤10\u003csup\u003e4\u003c/sup\u003e,0≤d≤n).\u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":" For each tests:\u003cbr\u003e\u003cbr\u003e For each queries, a single number denotes the total weight."}},{"title":"Sample","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\u003e4 3\r\n1 1 1 1\r\n1 2\r\n2 3\r\n3 4\r\n? 2 1\r\n! 1 0\r\n? 2 1\r\n3 3\r\n1 2 3\r\n1 2\r\n1 3\r\n? 1 0\r\n? 1 1\r\n? 1 2\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e3\r\n2\r\n1\r\n6\r\n6\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}