{"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":"给一棵 n 个节点为红蓝两色的树,节点标号从 1 开始,其中 1 号节点为红色,其它节点为蓝色,要求支持如下操作:\n1. 选择一个节点变为红色\n2. 查询一个节点到最近红色节点的距离"}},{"title":"输入格式","value":{"format":"MD","content":"第一行两个整数n,m表示树的节点个数和操作数,\n2 ≤ n ≤ 100 000,1 ≤ m ≤ 100 000。\n\n下接n-1行,每行两个整数u,v表示一条边,\n最后接m行,每行两个整数op, nd 表示为对nd标号的节点做第op种操作,\n1 ≤ op ≤ 2,1 ≤ u, v, nd ≤ n。\n"}},{"title":"输出格式","value":{"format":"MD","content":"对于所有第二类操作输出一个整数表示最近距离,每个操作的输出用空行隔开。"}},{"title":"样例","value":{"format":"MD","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\u003e5 4\u003cbr\u003e1 2\u003cbr\u003e2 3\u003cbr\u003e2 4\u003cbr\u003e4 5\u003cbr\u003e2 1\u003cbr\u003e2 5\u003cbr\u003e1 2\u003cbr\u003e2 5\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\u003e0\u003cbr\u003e3\u003cbr\u003e2\u003cbr\u003e\u003c/pre\u003e\n \u003c/div\u003e\n\u003c/div\u003e"}}]}