#include<iostream>
#include<vector>
#include<algorithm>
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll n,m;
  cin >> n >> m;
  ll a[m],b[m],d[300][300];
  fill(d[0],d[300],INF);
  for(int i=0;i<n;i++){
    d[i][i]=0;
  }
  for(int i=0;i<m;i++){
    cin >> a[i]>>b[i];
    a[i]--;
    b[i]--;
    d[a[i]][b[i]]=1;
  }
  for(ll k=0;k<n;k++){
    for(ll i=0;i<n;i++){
      for(ll j=0;j<n;j++){
        d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
      }
    }
  }
  /*
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++) cout << d[i][j]<<" ";
    cout << endl;
  }
  */
  bool fi;
  for(int i=0;i<n;i++){
    fi=true;
    for(int j=0;j<n;j++){
      if(d[j][i]!=INF&&d[i][j]!=INF){
        if(!fi){
          cout <<" ";
        }else{
          fi=false;
        }
        cout << j+1;
      }
    }
    cout << endl;
  }
}


### 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<iostream>
#include<vector>
#include<algorithm>
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll n,m;
  cin >> n >> m;
  ll a[m],b[m],d[300][300];
  fill(d[0],d[300],INF);
  for(int i=0;i<n;i++){
    d[i][i]=0;
  }
  for(int i=0;i<m;i++){
    cin >> a[i]>>b[i];
    a[i]--;
    b[i]--;
    d[a[i]][b[i]]=1;
  }
  for(ll k=0;k<n;k++){
    for(ll i=0;i<n;i++){
      for(ll j=0;j<n;j++){
        d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
      }
    }
  }
  /*
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++) cout << d[i][j]<<" ";
    cout << endl;
  }
  */
  bool fi;
  for(int i=0;i<n;i++){
    fi=true;
    for(int j=0;j<n;j++){
      if(d[j][i]!=INF&&d[i][j]!=INF){
        if(!fi){
          cout <<" ";
        }else{
          fi=false;
        }
        cout << j+1;
      }
    }
    cout << endl;
  }
}


```