#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N (5000)
//n<=500

int n, m;
vector<int> e[N];
vector<int>ne[N];
set<int>nn[N];
vector<int>ree[N];
vector<int>vs;
bool used[N];
int tpord[N];
vector<int>rtpord[N];


void dfs(int v) {
	used[v] = true;
	f(i, e[v].size()) {
		if (!used[e[v][i]])dfs(e[v][i]);
	}
	vs.push_back(v);
	return;
}

void redfs(int v, int k) {
	used[v] = true;
	tpord[v] = k;
	rtpord[k].push_back(v);
	f(i, ree[v].size()) {
		if (!used[ree[v][i]])redfs(ree[v][i], k);
	}
}

int scc(void) {
	memset(used, 0, sizeof(used));
	vs.clear();
	f(i, n) {
		if (!used[i])dfs(i);
	}
	memset(used, 0, sizeof(used));
	int k = -1;
	for (int i = vs.size() - 1; i >= 0; i--) {
		if (!used[vs[i]]) {
			k++;
			redfs(vs[i], k);
		}
	}
	f(i, n) {
		f(j, e[i].size()) {
			if (nn[tpord[i]].count(tpord[e[i][j]]) == 0 && tpord[e[i][j]] != tpord[i]) {
				ne[tpord[i]].push_back(tpord[e[i][j]]);
				nn[tpord[i]].insert(tpord[e[i][j]]);
			}
		}
	}
	k++;
	return k;
}


int main(void) {
	int x, y;
	long long z;
	int q;
	int asd;
	scanf("%d %d", &n, &m);
	f(i, m) {
		scanf("%d %d", &x, &y);
		x--;
		y--;
		e[x].push_back(y);
		ree[y].push_back(x);
	}
	q = scc();
  f(i,q)sort(rtpord[i].begin(),rtpord[i].end());
	f(i, n) {
		asd = tpord[i];
		f(j, rtpord[asd].size()) {
			printf("%d", rtpord[asd][j]+1);
			if ((j + 1) < rtpord[asd].size())printf(" ");
		}
		printf("\n");
	}
	

	return 0;
}

### Prompt

Please provide a cpp coded solution to the problem described below:

problem

There are $ N $ propositions, named $ 1, 2, \ cdots, N $, respectively. Also, $ M $ information about the propositions is given. The $ i $ th information is "$ a_i $$". Given in the form "b_i $", which means that $ a_i $ is $ b_i $. ("If" is a logical conditional and the transition law holds.) $ For each proposition $ i $ Output all propositions that have the same value as i $ in ascending order. However, proposition $ i $ and proposition $ i $ are always the same value. Proposition $ X $ and proposition $ Y $ have the same value as "$ if $ X $". It means "Y $" and "$ X $ if $ Y $".



output

On the $ i $ line, output all propositions that have the same value as the proposition $ i $, separated by blanks in ascending order. Also, output a line break at the end of each line.

Example

Input

5 2
1 2
2 1


Output

1 2
1 2
3
4
5

### Response

```cpp
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N (5000)
//n<=500

int n, m;
vector<int> e[N];
vector<int>ne[N];
set<int>nn[N];
vector<int>ree[N];
vector<int>vs;
bool used[N];
int tpord[N];
vector<int>rtpord[N];


void dfs(int v) {
	used[v] = true;
	f(i, e[v].size()) {
		if (!used[e[v][i]])dfs(e[v][i]);
	}
	vs.push_back(v);
	return;
}

void redfs(int v, int k) {
	used[v] = true;
	tpord[v] = k;
	rtpord[k].push_back(v);
	f(i, ree[v].size()) {
		if (!used[ree[v][i]])redfs(ree[v][i], k);
	}
}

int scc(void) {
	memset(used, 0, sizeof(used));
	vs.clear();
	f(i, n) {
		if (!used[i])dfs(i);
	}
	memset(used, 0, sizeof(used));
	int k = -1;
	for (int i = vs.size() - 1; i >= 0; i--) {
		if (!used[vs[i]]) {
			k++;
			redfs(vs[i], k);
		}
	}
	f(i, n) {
		f(j, e[i].size()) {
			if (nn[tpord[i]].count(tpord[e[i][j]]) == 0 && tpord[e[i][j]] != tpord[i]) {
				ne[tpord[i]].push_back(tpord[e[i][j]]);
				nn[tpord[i]].insert(tpord[e[i][j]]);
			}
		}
	}
	k++;
	return k;
}


int main(void) {
	int x, y;
	long long z;
	int q;
	int asd;
	scanf("%d %d", &n, &m);
	f(i, m) {
		scanf("%d %d", &x, &y);
		x--;
		y--;
		e[x].push_back(y);
		ree[y].push_back(x);
	}
	q = scc();
  f(i,q)sort(rtpord[i].begin(),rtpord[i].end());
	f(i, n) {
		asd = tpord[i];
		f(j, rtpord[asd].size()) {
			printf("%d", rtpord[asd][j]+1);
			if ((j + 1) < rtpord[asd].size())printf(" ");
		}
		printf("\n");
	}
	

	return 0;
}

```