RT 求调,TLE一页了
#include <bits/extc++.h>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
inline long long read()
{
long long x = 0, f = 1;
char ch = getchar();
while (!isdigit(ch))
{
if (ch == '-')
{
f = -1;
}
ch = getchar();
}
while (isdigit(ch))
{
x = (x << 1) + (x << 3) + (ch ^ 48);
ch = getchar();
}
return x * f;
}
inline void write(long long x)
{
if (x < 0)
putchar('-'), x = -x;
if (x > 9)
write(x / 10);
putchar(x % 10 + 48);
}
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
ll n, m;
vector<set<ll>> G;
void init()
{
n = 0, m = 0;
G.resize(0);
}
void solution()
{
init();
// n = read();
// m = read();
scanf("%lld",&n);
scanf("%lld",&m);
G.resize(n + 1);
for (ll i = 1; i <= m; i++)
{
// ll u = read();
// ll v = read();
ll u=0,v=0;
scanf("%lld",&u);
scanf("%lld",&v);
G[u].insert(v);
}
for (ll i = 1; i <= m; i++)
{
if (G[i].empty())
{
// cout<<endl;
// cout<<'\n';
// puts("");
putchar('\n');
continue;
}
for (auto j : G[i])
{
// cout<<j<<" ";
// printf("%lld ", j);
write(j);
putchar(' ');
}
// cout<<endl;
// cout << '\n';
putchar('\n');
}
}
int main()
{
ll T = 0;
// T = read();
scanf("%lld",&T);
for (ll i = 0; i < T; i++)
{
solution();
}
// Debug
// int Debuger=0;
// cin>>Debuger;
return 0;
}