#include <bits/stdc++.h>
using namespace std;

vector<vector<int>> G;
vector<vector<int>> RG;
vector<bool> visited;
vector<int> A,Aa,Ans;
int jun=0;

void dfs(int pos){
    //cout<<pos<<endl;
    visited[pos]=true;
    for(auto i:G[pos]){
        if(visited[i]){
            continue;
        }
        else{
            dfs(i);
        }
    }
    A[pos]=jun;
    Aa[jun]=pos;
    ++jun;
}

void dfs2(int pos,int t){
    //cout<<pos<<endl;
    visited[pos]=true;
    Ans[pos]=t;
    for(auto i:RG[pos]){
        if(visited[i]){
            continue;
        }
        else{
            dfs2(i,t);
        }
    }
}

int main(){
    //ifstream input("ctestin.in");
    int n,m;
    cin>>n>>m;
    //input>>n>>m;
    G.resize(n);
    RG.resize(n);
    visited.assign(n,false);
    A.assign(n,-1);
    Aa.assign(n,-1);
    Ans.assign(n,-1);
    for (int i = 0; i < m; ++i) {
        int a,b;
        cin>>a>>b;
        //input>>a>>b;
        --a;--b;
        G[a].emplace_back(b);
        RG[b].emplace_back(a);
    }

    for (int i = 0; i < n; ++i) {
        if(visited[i])continue;
        dfs(i);
    }

    visited.assign(n,false);
    int d=0;
    for (int i = Aa.size()-1; i >= 0; --i) {
        if(visited[Aa[i]])continue;
        dfs2(Aa[i],d);
        ++d;
    }


    for (int i = 0; i < n; ++i) {
        vector<int> ans;
        for (int j = 0; j < n; ++j) {
            if(Ans[i]==Ans[j])ans.emplace_back(j);
        }
        sort(ans.begin(),ans.end());
        for (int k = 0; k < ans.size(); ++k) {
            cout<<ans[k]+1;
            if(k==ans.size()-1)cout<<endl;
            else cout<<" ";
        }
    }

    return 0;
}


### Prompt

Your challenge is to write a cpp solution to the following problem:

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 <bits/stdc++.h>
using namespace std;

vector<vector<int>> G;
vector<vector<int>> RG;
vector<bool> visited;
vector<int> A,Aa,Ans;
int jun=0;

void dfs(int pos){
    //cout<<pos<<endl;
    visited[pos]=true;
    for(auto i:G[pos]){
        if(visited[i]){
            continue;
        }
        else{
            dfs(i);
        }
    }
    A[pos]=jun;
    Aa[jun]=pos;
    ++jun;
}

void dfs2(int pos,int t){
    //cout<<pos<<endl;
    visited[pos]=true;
    Ans[pos]=t;
    for(auto i:RG[pos]){
        if(visited[i]){
            continue;
        }
        else{
            dfs2(i,t);
        }
    }
}

int main(){
    //ifstream input("ctestin.in");
    int n,m;
    cin>>n>>m;
    //input>>n>>m;
    G.resize(n);
    RG.resize(n);
    visited.assign(n,false);
    A.assign(n,-1);
    Aa.assign(n,-1);
    Ans.assign(n,-1);
    for (int i = 0; i < m; ++i) {
        int a,b;
        cin>>a>>b;
        //input>>a>>b;
        --a;--b;
        G[a].emplace_back(b);
        RG[b].emplace_back(a);
    }

    for (int i = 0; i < n; ++i) {
        if(visited[i])continue;
        dfs(i);
    }

    visited.assign(n,false);
    int d=0;
    for (int i = Aa.size()-1; i >= 0; --i) {
        if(visited[Aa[i]])continue;
        dfs2(Aa[i],d);
        ++d;
    }


    for (int i = 0; i < n; ++i) {
        vector<int> ans;
        for (int j = 0; j < n; ++j) {
            if(Ans[i]==Ans[j])ans.emplace_back(j);
        }
        sort(ans.begin(),ans.end());
        for (int k = 0; k < ans.size(); ++k) {
            cout<<ans[k]+1;
            if(k==ans.size()-1)cout<<endl;
            else cout<<" ";
        }
    }

    return 0;
}


```