{"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":"A 和 B 正在为编程比赛做准备。\n\n他们所在的大学是由走廊连接的一组房间。总的来说,大学有 $n$ 个房间,由 $n-1$ 条走廊连接,这样你可以通过沿着走廊移动从任何一个房间到达任何其他一个房间。房间的编号从 $1$ 到 $n$。\n\n每天,A 和 B 都会在他们大学的一些房间里写比赛,每场比赛后,他们会在同一个房间里聚在一起讨论问题。A 和 B 希望讨论问题的房间到写比赛的房间的距离是相等的。两个房间之间的距离是它们之间最短路径上的边的数量。\n\n由于他们每天都在新的房间里写比赛,所以他们请你帮助他们找出接下来的 $m$ 天每天可以讨论问题的房间数量。\n"}},{"title":"输入格式","value":{"format":"MD","content":"第一行包含一个整数 $n (1 \\le n \\le 10^5)$ — 大学里的房间数量。\n\n接下来的 $n-1$ 行描述了走廊。这些行中的第 $i$ 行 $(1 \\le i \\le n-1)$ 包含两个整数 $a_i$ 和 $b_i (1 \\le a_i, b_i \\le n)$,表示第i条走廊连接了房间 $a_i$ 和 $b_i$。\n\n下一行包含一个整数 $m (1 \\le m \\le 10^5)$ — 查询的数量。\n\n接下来的 $m$ 行描述了查询。这些行中的第 $j$ 行 $(1 \\le j \\le m)$ 包含两个整数 $x_j$ 和 $y_j (1 \\le x_j, y_j \\le n)$,表示在第 $j$ 天,A 将在房间 $x_j$ 写比赛,B 将在房间 $y_j$ 写比赛。"}},{"title":"输出格式","value":{"format":"MD","content":"在第 $i$ 行 $(1 \\le i \\le m)$ 打印出在第 $i$ 天,A 和 B 写比赛的房间距离相等的房间数量。"}},{"title":"样例 #1","value":{"format":"MD","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003e输入\u003c/th\u003e\n \u003cth\u003e输出\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e4\n1 2\n1 3\n2 4\n1\n2 3\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e1\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"样例 #2","value":{"format":"MD","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003e输入\u003c/th\u003e\n \u003cth\u003e输出\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e4\n1 2\n2 3\n2 4\n2\n1 2\n1 3\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e0\n2\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"样例解释","value":{"format":"MD","content":"在第一个样本中,只有一个房间与房间 $2$ 和 $3$ 的距离相同 —— 房间 $1$。\n"}}]}