{"trustable":true,"sections":[{"title":"Description","value":{"format":"MD","content":"如题,现在有一个并查集,你需要完成合并和查询操作。\n"}},{"title":"Input","value":{"format":"MD","content":"第一行包含两个整数 $N,M$ ,表示共有 $N$ 个元素和 $M$ 个操作。\n\n接下来 $M$ 行,每行包含三个整数 $Z_i,X_i,Y_i$ 。\n\n当 $Z_i\u003d1$ 时,将 $X_i$ 与 $Y_i$ 所在的集合合并。\n\n当 $Z_i\u003d2$ 时,输出 $X_i$ 与 $Y_i$ 是否在同一集合内,是的输出 \n `Y` ;否则输出 `N` 。"}},{"title":"Output","value":{"format":"MD","content":"对于每一个 $Z_i\u003d2$ 的操作,都有一行输出,每行包含一个大写字母,为 `Y` 或者 `N` 。 "}},{"title":"Sample 1","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 7\n2 1 2\n1 1 2\n2 1 2\n1 3 4\n2 1 4\n1 2 3\n2 1 4\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eN\nY\nN\nY\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Hint","value":{"format":"MD","content":"对于 $30\\%$ 的数据,$N \\le 10$,$M \\le 20$。\n\n对于 $70\\%$ 的数据,$N \\le 100$,$M \\le 10^3$。\n\n对于 $100\\%$ 的数据,$1\\le N \\le 10^4$,$1\\le M \\le 2\\times 10^5$,$1 \\le X_i, Y_i \\le N$,$Z_i \\in \\{ 1, 2 \\}$。"}}]}