这个做法为啥不对
#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <cstring>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <list>
#include <bitset>
#include <cmath>
#include <numeric>
#define endl '\n'
#define ft first
#define sd second
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<string, ll> psl;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pss> vpss;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef queue <int> qi;
typedef queue <ll> ql;
typedef queue <pii> qpii;
typedef queue <pll> qpll;
typedef queue <psi> qpsi;
typedef queue <psl> qpsl;
typedef priority_queue<int> pqi;
typedef priority_queue<ll> pql;
typedef priority_queue<string> pqs;
typedef priority_queue<pii> pqpii;
typedef priority_queue<psi> pqpsi;
typedef priority_queue<pll> pqpl;
typedef priority_queue<psi> pqpsl;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
typedef map<char, int> mci;
typedef map<char, ll> mcl;
typedef map<string, int> msi;
typedef map<string, ll> msl;
typedef unordered_map<int, int> umii;
typedef unordered_map<ll, ll> uml;
typedef unordered_map<char, int> umci;
typedef unordered_map<char, ll> umcl;
typedef unordered_map<string, int> umsi;
typedef unordered_map<string, ll> umsl;
const int N = 1e5 + 5;
pii d[N];
vi h[N];
bool vis[N];
int n;
void ini()
{
memset(d, 0, sizeof(d));
memset(h, 0, sizeof(h));
memset(vis, 0, sizeof(vis));
n = 0;
}
void dfs(int u)
{
for (auto& v: h[u])
{
if (!v)
continue;
if (!vis[v])
{
vis[v] = 1;
cout << v << " ";
dfs(v);
}
}
}
void solve()
{
ini();
cin >> n;
int a, b, c;
map<pii,int> mp;
for (int i = 1; i <= n - 2; i++)
{
cin >> a >> b >> c;
d[a].ft++;
d[b].ft++;
d[c].ft++;
d[a].sd = a;
d[b].sd = b;
d[c].sd = c;
if (!mp[{a, b}])
{
h[a].push_back(b);
h[b].push_back(a);
mp[{a, b}]++;
mp[{b, a}]++;
}
else
{
for (auto& i : h[a])
{
if (i == b)
{
i = 0;
break;
}
}
for (auto& i : h[b])
{
if (i == a)
{
i = 0;
break;
}
}
}
if (!mp[{a, c}])
{
h[a].push_back(c);
h[c].push_back(a);
mp[{a, c}]++;
mp[{c, a}]++;
}
else
{
for (auto& i : h[a])
{
if (i == c)
{
i = 0;
break;
}
}
for (auto& i : h[c])
{
if (i == a)
{
i = 0;
break;
}
}
}
if (!mp[{b, c}])
{
h[b].push_back(c);
h[c].push_back(b);
mp[{b, c}]++;
mp[{c, b}]++;
}
else
{
for (auto& i : h[b])
{
if (i == c)
{
i = 0;
break;
}
}
for (auto& i : h[c])
{
if (i == b)
{
i = 0;
break;
}
}
}
}
cout << 1 << " ";
vis[1] = 1;
dfs(1);
cout << endl;
sort(d + 1, d + n);
for (int i = 1; i <= n - 2; i++)
{
cout << d[i].sd << " ";
}
cout << endl;
}
int main()
{
ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
int _ = 1;
cin >> _;
while (_--)
{
solve();
}
return 0;
}