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

#define pb push_back
#define mp make_pair
#define s second
#define f first
#define MOD 998244353
#define lp(i,n) for(int i = 0;i < n;++i)
#define sz(x) ((int)(x).size())

typedef  unsigned long long ll;
typedef pair<ll , ll> pii;
typedef  double ld;
typedef unsigned long long ull ;
static const int OO = 0x3f3f3f3f , N =2*1e5+10 ;
static const unsigned long long OOL = 0xffffffffffffffff ;

int dx[] = {1 , 1 , 2 , 2 , 3 , 3 };
int dy[] = {2 , 3 , 1 , 3 , 1 , 2 };

int n,x,arr[N][4],firstt=-1, secondd=-1,lastt=-1,before_lastt=-1,visited[N];
vector<int>answer,vec[N];

int main(){
    cin >> n;
    lp(i,n-2){
        lp(j,3)
            cin >> arr[i][j];

            lp(j,3){
                lp(k,3){
                    if(k!=j && find(vec[arr[i][j]].begin() , vec[arr[i][j]].end(),arr[i][k]) == vec[arr[i][j]].end())vec[arr[i][j]].pb(arr[i][k]);
                }
            }
    }
    lp(i,n)visited[i+1]=sz(vec[i+1]);
    lp(i,n){
        if(visited[i+1]==2 && firstt == -1){firstt=i+1;}
        else if(firstt!=-1 && visited[i+1] == 2)lastt = i+1;
        }
    lp(i,2)if(visited[vec[firstt][i]] == 3){secondd= vec[firstt][i];break;}
    lp(i,2)if(visited[vec[lastt][i]] == 3 && vec[lastt][i]!=secondd){before_lastt= vec[lastt][i];break;}
    visited[firstt]=0;visited[secondd]=0;
 //   visited[lastt]=0;visited[before_lastt]=0;
    queue<int>q;
   q.push(firstt);
   q.push(secondd);
    while(!q.empty()){
        int v = q.front();
        q.pop();
        answer.pb(v);
        lp(i,sz(vec[v])){
            if(visited[vec[v][i]]!=0)q.push(vec[v][i]),visited[vec[v][i]]=0;
        }

    }
    lp(i,sz(answer))cout << answer[i] << " ";

}


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

#define pb push_back
#define mp make_pair
#define s second
#define f first
#define MOD 998244353
#define lp(i,n) for(int i = 0;i < n;++i)
#define sz(x) ((int)(x).size())

typedef  unsigned long long ll;
typedef pair<ll , ll> pii;
typedef  double ld;
typedef unsigned long long ull ;
static const int OO = 0x3f3f3f3f , N =2*1e5+10 ;
static const unsigned long long OOL = 0xffffffffffffffff ;

int dx[] = {1 , 1 , 2 , 2 , 3 , 3 };
int dy[] = {2 , 3 , 1 , 3 , 1 , 2 };

int n,x,arr[N][4],firstt=-1, secondd=-1,lastt=-1,before_lastt=-1,visited[N];
vector<int>answer,vec[N];

int main(){
    cin >> n;
    lp(i,n-2){
        lp(j,3)
            cin >> arr[i][j];

            lp(j,3){
                lp(k,3){
                    if(k!=j && find(vec[arr[i][j]].begin() , vec[arr[i][j]].end(),arr[i][k]) == vec[arr[i][j]].end())vec[arr[i][j]].pb(arr[i][k]);
                }
            }
    }
    lp(i,n)visited[i+1]=sz(vec[i+1]);
    lp(i,n){
        if(visited[i+1]==2 && firstt == -1){firstt=i+1;}
        else if(firstt!=-1 && visited[i+1] == 2)lastt = i+1;
        }
    lp(i,2)if(visited[vec[firstt][i]] == 3){secondd= vec[firstt][i];break;}
    lp(i,2)if(visited[vec[lastt][i]] == 3 && vec[lastt][i]!=secondd){before_lastt= vec[lastt][i];break;}
    answer.pb(firstt);answer.pb(secondd);
    visited[firstt]=0;visited[secondd]=0;
    visited[lastt]=0;visited[before_lastt]=0;
    queue<int>q;
   q.push(firstt);
    while(!q.empty()){
        int v = q.front();
        q.pop();
        if(v!=firstt)answer.pb(v);
        lp(i,sz(vec[v])){
            if(visited[vec[v][i]]!=0 )q.push(vec[v][i]),visited[vec[v][i]]=0;
        }

    }
answer.pb(before_lastt);
answer.pb(lastt);
    lp(i,sz(answer))cout << answer[i] << " ";

}


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

#define pb push_back
#define mp make_pair
#define s second
#define f first
#define MOD 998244353
#define lp(i,n) for(int i = 0;i < n;++i)
#define sz(x) ((int)(x).size())

typedef  unsigned long long ll;
typedef pair<ll , ll> pii;
typedef  double ld;
typedef unsigned long long ull ;
static const int OO = 0x3f3f3f3f , N =2*1e5+10 ;
static const unsigned long long OOL = 0xffffffffffffffff ;

int dx[] = {1 , 1 , 2 , 2 , 3 , 3 };
int dy[] = {2 , 3 , 1 , 3 , 1 , 2 };

int n,x,arr[N][4],firstt,secondd,visited[N];
vector<int>answer,vec[N];

int main(){
    cin >> n;
    lp(i,n-2){
        lp(j,3)
            cin >> arr[i][j];

            lp(j,3)lp(k,3)if(k!=j && find(vec[arr[i][j]].begin() , vec[arr[i][j]].end(),arr[i][k]) == vec[arr[i][j]].end())vec[arr[i][j]].pb(arr[i][k]);

    }
    lp(i,n)visited[i+1]=sz(vec[i+1]);
    lp(i,n)if(visited[i+1]==2 )firstt=i+1;

    lp(i,2)if(visited[vec[firstt][i]] == 3){secondd= vec[firstt][i];break;}
    visited[firstt]=0;visited[secondd]=0;

    queue<int>q;
   q.push(firstt);
   q.push(secondd);
    while(!q.empty()){
        int v = q.front();
        q.pop();
        answer.pb(v);
        lp(i,sz(vec[v])){
            if(visited[vec[v][i]]!=0)q.push(vec[v][i]),visited[vec[v][i]]=0;
        }

    }
    lp(i,sz(answer))cout << answer[i] << " ";

}


/*
   3 din lagche submit aro 15-20 bar hobe -_-
*/

#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
   ll n;
   cin>>n;
   vector<ll> v(3),ans;
   vector<vector<ll>> ind(n+1,vector<ll>());
   map<ll,ll> fre,pos;
   ll i=0;
   for(ll j=0;j<n-2;j++)
   {
       cin>>v[i]>>v[i+1]>>v[i+2];
       ind[v[i]].push_back(i);
       ind[v[i+1]].push_back(i+1);
       ind[v[i+2]].push_back(i+2);
       fre[v[i]]++;
       fre[v[i+1]]++;
       fre[v[i+2]]++;
       pos[i]=1;
       pos[i+1]=2;
       pos[i+2]=3;
       i+=3;
       if(j!=n-3) v.resize(v.size()+3);
   }

   ll pf,pl,rec;
   for( i=0;i<v.size();i++)
   {
       if(fre[v[i]]==1)
       {
           ans.push_back(v[i]);
           rec=v[i];
           if(pos[i]==1)
           {
               if(fre[v[i+1]]==2)
               {
                   pf=i+1;
                   pl=i+2;
               }
               else
               {
                   pf=i+2;
                   pl=i+1;
               }

           }
           else if(pos[i]==2)
           {
               if(fre[v[i-1]]==2)
               {
                   pf=i-1;
                   pl=i+1;
               }
               else
               {
                   pf=i+1;
                   pl=i-1;
               }

           }
           else
           {
               if(fre[v[i-2]]==2)
               {
                   pf=i-2;
                   pl=i-1;
               }
               else
               {
                   pf=i-1;
                   pl=i-2;
               }
           }
           break;
       }
   }

   for(ll j=0;j<n-3;j++)
   {
      ll tem;
      for(i=0;i<fre[v[pl]];i++)
      {
          if(pos[ind[v[pl]][i]]==1)
          {

               if((v[ind[v[pl]][i]+1]!=rec && v[ind[v[pl]][i]+2]==v[pf] )||(v[ind[v[pl]][i]+2]!=rec && v[ind[v[pl]][i]+1]==v[pf] ))
               {
                   rec=v[pf];
                   tem=pl;
                   ans.push_back(v[pf]);
                  if( v[ind[v[pl]][i]+1]!=v[pf])
                  {
                      pl=ind[v[pl]][i]+1;

                  }
                  else
                  {
                      pl=ind[v[pl]][i]+2;

                  }
                  pf=tem;
                  break;
               }
          }
          else if(pos[ind[v[pl]][i]]==2)
          {

               if((v[ind[v[pl]][i]+1]!=rec && v[ind[v[pl]][i]-1]==v[pf] )||(v[ind[v[pl]][i]-1]!=rec && v[ind[v[pl]][i]+1]==v[pf] ))
               {

                   rec=v[pf];
                   tem=pl;
                   ans.push_back(v[pf]);
                  if( v[ind[v[pl]][i]+1]!=v[pf]) pl=ind[v[pl]][i]+1;
                  else pl=ind[v[pl]][i]-1;
                    pf=tem;
                  break;
               }
          }
          else
          {

              if((v[ind[v[pl]][i]-2]!=rec && v[ind[v[pl]][i]-1]==v[pf] )||(v[ind[v[pl]][i]-1]!=rec && v[ind[v[pl]][i]-2]==v[pf] ))
               {
                  rec=v[pf];
                  tem=pl;
                  ans.push_back(v[pf]);
                  if( v[ind[v[pl]][i]-1]!=v[pf]) {
                        pl=ind[v[pl]][i]-1;
                    }
                  else
                  {
                      pl=ind[v[pl]][i]-2;

                  }
                  pf=tem;
                  break;
               }
          }
      }
           if(j==n-4)
           {
              if(fre[v[pf]]>fre[v[pl]])
              {
                  ans.push_back(v[pf]);
                  ans.push_back(v[pl]);
              }
              else
              {

                  ans.push_back(v[pl]);
                  ans.push_back(v[pf]);
              }
           }
   }
   //return 0;
           for(auto out: ans) cout<<out<<" ";cout<<endl;

}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
   ll n;
   cin>>n;
   vector<ll> v(3),ans;
   vector<vector<ll>> ind(n+1,vector<ll>());
   map<ll,ll> fre,pos;
   ll i=0;
   for(ll j=0;j<n-2;j++)
   {
       cin>>v[i]>>v[i+1]>>v[i+2];
       ind[v[i]].push_back(i);
       ind[v[i+1]].push_back(i+1);
       ind[v[i+2]].push_back(i+2);
       fre[v[i]]++;
       fre[v[i+1]]++;
       fre[v[i+2]]++;
       pos[i]=1;
       pos[i+1]=2;
       pos[i+2]=3;
       i+=3;
       if(j!=n-3) v.resize(v.size()+3);
   }

   ll pf,pl,rec;
   for( i=0;i<v.size();i++)
   {
       if(fre[v[i]]==1)
       {
           ans.push_back(v[i]);
           rec=v[i];
           if(pos[i]==1)
           {
               if(fre[v[i+1]]==2)
               {
                   pf=i+1;
                   pl=i+2;
               }
               else
               {
                   pf=i+2;
                   pl=i+1;
               }

           }
           else if(pos[i]==2)
           {
               if(fre[v[i-1]]==2)
               {
                   pf=i-1;
                   pl=i+1;
               }
               else
               {
                   pf=i+1;
                   pl=i-1;
               }

           }
           else
           {
               if(fre[v[i-2]]==2)
               {
                   pf=i-2;
                   pl=i-1;
               }
               else
               {
                   pf=i-1;
                   pl=i-2;
               }
           }
           break;
       }
   }

   for(ll j=0;j<n-3;j++)
   {
      ll tem;
      for(i=0;i<fre[v[pl]];i++)
      {
          if(pos[ind[v[pl]][i]]==1)
          {

               if((v[ind[v[pl]][i]+1]!=rec && v[ind[v[pl]][i]+2]==v[pf] )||(v[ind[v[pl]][i]+2]!=rec && v[ind[v[pl]][i]+1]==v[pf] ))
               {
                   rec=v[pf];
                   tem=pl;
                   ans.push_back(v[pf]);
                  if( v[ind[v[pl]][i]+1]!=v[pf])
                  {
                      pl=ind[v[pl]][i]+1;

                  }
                  else
                  {
                      pl=ind[v[pl]][i]+2;

                  }
                  pf=tem;
                  break;
               }
          }
          else if(pos[ind[v[pl]][i]]==2)
          {

               if((v[ind[v[pl]][i]+1]!=rec && v[ind[v[pl]][i]-1]==v[pf] )||(v[ind[v[pl]][i]-1]!=rec && v[ind[v[pl]][i]+1]==v[pf] ))
               {

                   rec=v[pf];
                   tem=pl;
                   ans.push_back(v[pf]);
                  if( v[ind[v[pl]][i]+1]!=v[pf]) pl=ind[v[pl]][i]+1;
                  else pl=ind[v[pl]][i]-1;
                    pf=tem;
                  break;
               }
          }
          else
          {

              if((v[ind[v[pl]][i]-2]!=rec && v[ind[v[pl]][i]-1]==v[pf] )||(v[ind[v[pl]][i]-1]!=rec && v[ind[v[pl]][i]-2]==v[pf] ))
               {
                  rec=v[pf];
                  tem=pl;
                  ans.push_back(v[pf]);
                  if( v[ind[v[pl]][i]-1]!=v[pf]) {
                        pl=ind[v[pl]][i]-1;
                    }
                  else
                  {
                      pl=ind[v[pl]][i]-2;

                  }
                  pf=tem;
                  break;
               }
          }
      }
           if(j==n-4)
           {
              if(fre[v[pf]]>fre[v[pl]])
              {
                  ans.push_back(v[pf]);
                  ans.push_back(v[pl]);
              }
              else
              {

                  ans.push_back(v[pl]);
                  ans.push_back(v[pf]);
              }
           }
   }
   //return 0;
           for(auto out: ans) cout<<out<<" ";cout<<endl;

}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
   ll n;
   cin>>n;
   vector<ll> v(3),ans;
   vector<vector<ll>> ind(n+1,vector<ll>());
   map<ll,ll> fre,pos;
   ll i=0;
   for(ll j=0;j<n-2;j++)
   {
       cin>>v[i]>>v[i+1]>>v[i+2];
       ind[v[i]].push_back(i);
       ind[v[i+1]].push_back(i+1);
       ind[v[i+2]].push_back(i+2);
       fre[v[i]]++;
       fre[v[i+1]]++;
       fre[v[i+2]]++;
       pos[v[i]]=1;
       pos[v[i+1]]=2;
       pos[v[i+2]]=3;
       i+=3;
       if(j!=n-3) v.resize(v.size()+3);
   }

   ll pf,pl,rec;
   for( i=0;i<v.size();i++)
   {
       if(fre[v[i]]==1)
       {
           ans.push_back(v[i]);
           rec=v[i];
           if(pos[v[i]]==1)
           {
               if(fre[v[i+1]]==2)
               {
                   pf=i+1;
                   pl=i+2;
               }
               else
               {
                   pf=i+2;
                   pl=i+1;
               }

           }
           else if(pos[v[i]]==2)
           {
               if(fre[v[i-1]]==2)
               {
                   pf=i-1;
                   pl=i+1;
               }
               else
               {
                   pf=i+1;
                   pl=i-1;
               }

           }
           else
           {
               if(fre[v[i-2]]==2)
               {
                   pf=i-2;
                   pl=i-1;
               }
               else
               {
                   pf=i-1;
                   pl=i-2;
               }
           }
           break;
       }
   }

   for(ll j=0;j<n-3;j++)
   {
      ll tem;
      for(i=0;i<fre[v[pl]];i++)
      {
          if(pos[v[ind[v[pl]][i]]]==1)
          {
               if((v[ind[v[pl]][i]+1]!=rec && v[ind[v[pl]][i]+2]==v[pf] )||(v[ind[v[pl]][i]+2]!=rec && v[ind[v[pl]][i]+1]==v[pf] ))
               {
                   rec=v[pf];
                   tem=pl;
                   ans.push_back(v[pf]);
                  if( v[ind[v[pl]][i]+1]!=v[pf]) pl=ind[v[pl]][i]+1;
                  else pl=ind[v[pl]][i]+2;
                  pf=tem;
                  break;
               }
          }
          else if(pos[v[ind[v[pl]][i]]]==2)
          {
               if((v[ind[v[pl]][i]+1]!=rec && v[ind[v[pl]][i]-1]==v[pf] )||(v[ind[v[pl]][i]-1]!=rec && v[ind[v[pl]][i]+1]==v[pf] ))
               {
                   rec=v[pf];
                   tem=pl;
                   ans.push_back(v[pf]);
                  if( v[ind[v[pl]][i]+1]!=v[pf]) pl=ind[v[pl]][i]+1;
                  else pl=ind[v[pl]][i]-1;
                    pf=tem;
                  break;
               }
          }
          else
          {
              if((v[ind[v[pl]][i]-2]!=rec && v[ind[v[pl]][i]-1]==pf )||(v[ind[v[pl]][i]-1]!=rec && v[ind[v[pl]][i]-2]==pf ))
               {
                  rec=v[pf];
                  tem=pl;
                  ans.push_back(v[pf]);
                  if( v[ind[v[pl]][i]-1]!=v[pf]) {
                        pl=ind[v[pl]][i]-1;
                    }
                  else
                  {
                      pl=ind[v[pl]][i]-2;

                  }
                  pf=tem;
                  break;
               }
          }
      }
           if(j==n-4)
           {
              if(fre[v[pf]]>fre[v[pl]])
              {
                  ans.push_back(v[pf]);
                  ans.push_back(v[pl]);
              }
              else
              {

                  ans.push_back(v[pl]);
                  ans.push_back(v[pf]);
              }
           }
   }
   //return 0;
           for(auto out: ans) cout<<out<<" ";cout<<endl;

}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{

   ll n;
   cin>>n;
   vector<ll> v((n-2)*3),ans;
   vector<vector<ll>> ar(n+1);
   map<ll,ll> pos,fre,mp;
   ll i=0;
   for(ll j=0;j<(n-2);j++)
   {
       cin>>v[i]>>v[i+1]>>v[i+2];
       fre[v[i]]++;fre[v[i+1]]++;fre[v[i+2]]++;
       pos[i]=1;pos[i+1]=2;pos[i+2]=3;
       mp[v[i]]=i;mp[v[i+1]]=i+1;mp[v[i+2]]=i+2;
       ar[v[i]].push_back(i); ar[v[i+1]].push_back(i+1); ar[v[i+2]].push_back(i+2);
       i+=3;

   }
   ll fpos;
   for(auto it=fre.begin();it!=fre.end();it++)
   {
       if(it->second ==1)
       {
           ans.push_back(it->second);
           fpos=mp[it->second];
           break;
       }
   }
   ll f,l;
   for(i=0;i<n-3;i++)
   {

       if(i==0)
       {
           ll fp=pos[fpos];
           if(fp==1)
           {
              f= v[fpos+1];
              l= v[fpos+2];
           }
           else if(fp==2)
           {
              f= v[fpos-1];
              l= v[fpos+1];
           }
           else
           {
              f= v[fpos-2];
              l= v[fpos-1];
           }
           ans.push_back(f);
           ans.push_back(l);
        }
       else{

          ll fp,mn=n;
          for(ll j=0;j<ar[f].size();j++)
          {
              if(v[ar[f][j]]==f) continue;
              for(ll k=0;k<ar[l].size();k++)
              {
                  if(v[ar[l][k]]==l) continue;
                  if(mn>fabs(ar[f][j]-ar[l][k])) mn=fabs(ar[f][j]-ar[l][k]),fp=ar[f][j];
              }
          }

          if(pos[fp]==1)
           {
              f= v[fp+1];
              l= v[fp+2];
           }
           else if(pos[fp]==2)
           {
              f= v[fp-1];
              l= v[fp+1];
           }
           else
           {
              f= v[fp-2];
              l= v[fp-1];
           }
           ans.push_back(f);
       }

    }
   ans.push_back(l);
   for(auto &out:ans) cout<<out<<" ";cout<<endl;

}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
   ll n;
   cin>>n;
   vector<ll> v(3),ans;
   vector<vector<ll>> ind(n+1,vector<ll>());
   map<ll,ll> fre,pos;
   ll i=0;
   for(ll j=0;j<n-2;j++)
   {
       cin>>v[i]>>v[i+1]>>v[i+2];
       ind[v[i]].push_back(i);
       ind[v[i+1]].push_back(i+1);
       ind[v[i+2]].push_back(i+2);
       fre[v[i]]++;
       fre[v[i+1]]++;
       fre[v[i+2]]++;
       pos[v[i]]=1;
       pos[v[i+1]]=2;
       pos[v[i+2]]=3;
       i+=3;
       if(j!=n-3) v.resize(v.size()+3);
   }

   ll pf,pl,rec;
   for( i=0;i<v.size();i++)
   {
       if(fre[v[i]]==1)
       {
           ans.push_back(v[i]);
           rec=v[i];
           if(pos[v[i]]==1)
           {
               if(fre[v[i+1]]==2)
               {
                   pf=i+1;
                   pl=i+2;
               }
               else
               {
                   pf=i+2;
                   pl=i+1;
               }

           }
           else if(pos[v[i]]==2)
           {
               if(fre[v[i-1]]==2)
               {
                   pf=i-1;
                   pl=i+1;
               }
               else
               {
                   pf=i+1;
                   pl=i-1;
               }

           }
           else
           {
               if(fre[v[i-2]]==2)
               {
                   pf=i-2;
                   pl=i-1;
               }
               else
               {
                   pf=i-1;
                   pl=i-2;
               }
           }
           break;
       }
   }

   for(ll j=0;j<n-3;j++)
   {
      ll tem;
      for(i=0;i<fre[v[pl]];i++)
      {
          if(pos[v[ind[v[pl]][i]]]==1)
          {
               if((v[ind[v[pl]][i]+1]!=rec && v[ind[v[pl]][i]+2]==v[pf] )||(v[ind[v[pl]][i]+2]!=rec && v[ind[v[pl]][i]+1]==v[pf] ))
               {
                   rec=v[pf];
                   tem=pl;
                   ans.push_back(v[pf]);
                  if( v[ind[v[pl]][i]+1]!=v[pf]) pl=ind[v[pl]][i]+1;
                  else pl=ind[v[pl]][i]+2;
                  pf=tem;
                  break;
               }
          }
          else if(pos[v[ind[v[pl]][i]]]==2)
          {
               if((v[ind[v[pl]][i]+1]!=rec && v[ind[v[pl]][i]-1]==v[pf] )||(v[ind[v[pl]][i]-1]!=rec && v[ind[v[pl]][i]+1]==v[pf] ))
               {
                   rec=v[pf];
                   tem=pl;
                   ans.push_back(v[pf]);
                  if( v[ind[v[pl]][i]+1]!=v[pf]) pl=ind[v[pl]][i]+1;
                  else pl=ind[v[pl]][i]-1;
                    pf=tem;
                  break;
               }
          }
          else
          {
              if((v[ind[v[pl]][i]-2]!=rec && v[ind[v[pl]][i]-1]==pf )||(v[ind[v[pl]][i]-1]!=rec && v[ind[v[pl]][i]-2]==pf ))
               {
                  rec=v[pf];
                  tem=pl;
                  ans.push_back(v[pf]);
                  if( v[ind[v[pl]][i]-1]!=v[pf]) {
                        pl=ind[v[pl]][i]-1;
                    }
                  else
                  {
                      pl=ind[v[pl]][i]-2;

                  }
                  pf=tem;
                  break;
               }
          }
      }
           if(j==n-4)
           {
               ans.push_back(v[pf]);
               ans.push_back(v[pl]);
           }
   }
   //return 0;
           for(auto out: ans) cout<<out<<" ";cout<<endl;

}


#include <bits/stdc++.h>
using namespace std;
const int MAX_N=1e5+10;
set<int> s[MAX_N];
int n,a,b,c,ans[MAX_N],ind=1;
bool used[MAX_N];
void dfs(int x){
    ans[ind++]=x;
    used[x]=true;
    for(auto y:s[x]){
        s[y].erase(x);
        if(s[y].size()==2&&!used[y]){
            dfs(y);
        }
    }
}
int main(){
    cin>>n;
    for(int i=0;i<n-2;i++){
        cin>>a>>b>>c;
        s[a].insert(b),s[a].insert(c);
        s[b].insert(a),s[b].insert(c);
        s[c].insert(a),s[c].insert(b);
    }
    for(int i=1;i<=n;i++){
        if(s[i].size()==2){
            used[i]=true;
            ans[0]=i;
            int se=0;
            for(auto x:s[i]){
                if(s[x].size()==3){
                    se=x;
                    break;
                }
            }
            for(int j=i+1;j<=n;j++){
                if(s[j].size()==2){
                    used[j]=true;
                    ans[n-1]=j;
                    for(auto x:s[j]){
                        s[x].erase(j);
                        if(s[x].size()==2){
                            used[x]=true;
                            ans[n-2]=x;
                            break;
                        }
                    }
                    break;
                }
            }
            dfs(se);
            break;
        }
    }
    for(int i=0;i<n;i++){
        cout<<ans[i]<<" ";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int MAX_N=1e5+10;
set<int> s[MAX_N];
int n,a,b,c,ans[MAX_N],ind;
bool used[MAX_N];
void dfs(int x){
    ans[ind++]=x;
    used[x]=true;
    for(auto y:s[x]){
        s[y].erase(x);
        if(s[y].size()<=2&&!used[y]){
            dfs(y);
        }
    }
}
int main(){
    cin>>n;
    for(int i=0;i<n-2;i++){
        cin>>a>>b>>c;
        s[a].insert(b),s[a].insert(c);
        s[b].insert(a),s[b].insert(c);
        s[c].insert(a),s[c].insert(b);
    }
    for(int i=1;i<=n;i++){
        if(s[i].size()==2){
            for(int j=i+1;j<=n;j++){
                if(s[j].size()==2){
                    used[j]=true;
                    ans[n-1]=j;
                    break;
                }
            }
            dfs(i);
            break;
        }
    }
    for(int i=0;i<n;i++){
        cout<<ans[i]<<" ";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int MAX_N=1e5+10;
set<int> s[MAX_N],t[MAX_N];
int n,a,b,c,ans[MAX_N],ind=1;
bool used[MAX_N];
void dfs(int x){
    ans[ind++]=x;
    used[x]=true;
    for(auto y:t[x]){
        t[y].erase(x);
        if(t[y].size()==2&&!used[y]){
            dfs(y);
        }
    }
}
int main(){
    cin>>n;
    for(int i=0;i<n-2;i++){
        cin>>a>>b>>c;
        s[a].insert(b),s[a].insert(c);
        s[b].insert(a),s[b].insert(c);
        s[c].insert(a),s[c].insert(b);
    }
    for(int i=1;i<=n;i++){
        t[i]=s[i];
    }
    for(int i=1;i<=n;i++){
        if(s[i].size()==2){
            used[i]=true;
            ans[0]=i;
            int se=0;
            for(auto x:s[i]){
                s[x].erase(i);
                if(s[x].size()==2&&se==0){
                    se=x;
                }
            }
            for(int j=1;j<=n;j++){
                s[j]=t[j];
            }
            for(int j=i+1;j<=n;j++){
                if(s[j].size()==2){
                    used[j]=true;
                    ans[n-1]=j;
                    for(auto x:s[j]){
                        s[x].erase(j);
                        if(s[x].size()==2&&ans[n-2]==0){
                            used[x]=true;
                            ans[n-2]=x;
                        }
                    }
                    break;
                }
            }
            for(auto x:s[ans[0]]){
                t[x].erase(ans[0]);
            }
            dfs(se);
            break;
        }
    }
    for(int i=0;i<n;i++){
        cout<<ans[i]<<" ";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int MAX_N=1e5+10;
set<int> s[MAX_N];
int n,a,b,c,ans[MAX_N],ind;
bool used[MAX_N];
void dfs(int x){
    ans[ind++]=x;
    used[x]=true;
    for(auto y:s[x]){
        s[y].erase(x);
        if(s[y].size()<=2&&!used[y]){
            dfs(y);
        }
    }
}
int main(){
    cin>>n;
    for(int i=0;i<n-2;i++){
        cin>>a>>b>>c;
        s[a].insert(b),s[a].insert(c);
        s[b].insert(a),s[b].insert(c);
        s[c].insert(a),s[c].insert(b);
    }
    for(int i=1;i<=n;i++){
        if(s[i].size()==2){
            dfs(i);
            break;
        }
    }
    for(int i=0;i<n;i++){
        cout<<ans[i]<<" ";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int MAX_N=1e5+10;
set<int> s[MAX_N];
int n,a,b,c,ans[MAX_N],ind;
bool used[MAX_N];
void dfs(int x){
    ans[ind++]=x;
    used[x]=true;
    for(auto y:s[x]){
        s[y].erase(x);
        if(s[y].size()==2&&!used[y]){
            dfs(y);
        }
    }
}
int main(){
    cin>>n;
    for(int i=0;i<n-2;i++){
        cin>>a>>b>>c;
        s[a].insert(b),s[a].insert(c);
        s[b].insert(a),s[b].insert(c);
        s[c].insert(a),s[c].insert(b);
    }
    for(int i=1;i<=n;i++){
        if(s[i].size()==2){
            for(int j=i+1;j<=n;j++){
                if(s[j].size()==2){
                    used[j]=true;
                    ans[n-1]=j;
                    for(auto x:s[j]){
                        s[x].erase(j);
                        if(s[x].size()==2){
                            used[x]=true;
                            ans[n-2]=x;
                            break;
                        }
                    }
                    break;
                }
            }
            dfs(i);
            break;
        }
    }
    for(int i=0;i<n;i++){
        cout<<ans[i]<<" ";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
const int MX = 3e5 + 1, MOD = 1e9 + 7;
int a[MX], b[MX], n, p;

void solve(){
    cin>>n;
    vector<vector<int>> c(n+1);
    for(int i = 1; i <= n; i++) a[i] = 0;
    for(int i = 0; i < n - 2; i++){
        int x, y, z;
        cin>>x>>y>>z;
        a[x]++, a[y]++, a[z]++;
        c[x].push_back(y);
        c[x].push_back(z);
        c[y].push_back(x);
        c[y].push_back(z);
        c[z].push_back(x);
        c[z].push_back(y);
    }
    for(int i = 1; i <= n; i++) b[i] = -1;
    for(int i = 1; i <= n; i++) if(a[i] == 1){
        b[1] = i;
        break;
    }
    for(auto x: c[b[1]])
    if(a[x] == 2){
        b[2] = x;
        break;
    }
    int cur = b[2], prev1 = b[1], prev2 = 0;
    for(int i = 3; i <= n - 2; i++){
        //cout<<i<<" "<<cur<<" "<<mx<<"\n";
        for(auto x: c[cur]){
            if(x == prev1 || x == prev2) continue;
            for(auto y: c[x]){
                if(y == prev){
                    b[i] = x;
                    prev2 = prev1;
                    prev1 = cur;
                    cur = x;
                    break;
                }
            }
            if(b[i] != -1) break;
        }
    }
    for(int i = n; i >= 0; i--) if(a[i] == 1){
        b[n] = i;
        break;
    }
    for(auto x: c[b[n]])
    if(a[x] == 2){
        b[n - 1] = x;
        break;
    }
    for(int i = 1; i <= n; i++) cout<<b[i]<<" ";
}
int main()
{
//    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);
    /*
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    */
    int tc = 1;
    //cin>>tc;
    while(tc--){
        solve();
    }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
const int MX = 3e5 + 1, MOD = 1e9 + 7;
int a[MX], b[MX], n, p;

void solve(){
    cin>>n;
    vector<vector<int>> c(n+1);
    for(int i = 1; i <= n; i++) a[i] = 0;
    for(int i = 0; i < n - 2; i++){
        int x, y, z;
        cin>>x>>y>>z;
        a[x]++, a[y]++, a[z]++;
        c[x].push_back(y);
        c[x].push_back(z);
        c[y].push_back(x);
        c[y].push_back(z);
        c[z].push_back(x);
        c[z].push_back(y);
    }
    for(int i = 1; i <= n; i++) b[i] = -1;
    for(int i = 1; i <= n; i++) if(a[i] == 1){
        b[1] = i;
        break;
    }
    int cur = b[1];
    for(int i = 2; i <= n; i++){
        int mx = min(a[cur] + 1, 3);
        //cout<<i<<" "<<cur<<" "<<mx<<"\n";
        for(auto x: c[cur]){
            if(a[x] == mx){
                b[i] = x;
                cur = b[i];
                break;
            }
        }
    }
    for(int i = n; i >= 0; i--) if(a[i] == 1){
        b[n] = i;
        break;
    }
    cur = b[n];
    for(int i = n - 1; i >= 2; i--){
        if(b[i] != -1) break;
        int mx = min(a[cur] + 1, 3);
        for(auto x: c[cur]){
            if(a[x] == mx){
                b[i] = x;
                cur = b[i];
                break;
            }
        }
    }
    for(int i = 1; i <= n; i++) cout<<b[i]<<" ";
}
int main()
{
//    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);
    /*
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    */
    int tc = 1;
    //cin>>tc;
    while(tc--){
        solve();
    }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
const int MX = 3e5 + 1, MOD = 1e9 + 7;
int a[MX], b[MX], n, p;

void solve(){
    cin>>n;
    vector<vector<int>> c(n+1);
    for(int i = 1; i <= n; i++) a[i] = 0;
    for(int i = 0; i < n - 2; i++){
        int x, y, z;
        cin>>x>>y>>z;
        a[x]++, a[y]++, a[z]++;
        c[x].push_back(y);
        c[x].push_back(z);
        c[y].push_back(x);
        c[y].push_back(z);
        c[z].push_back(x);
        c[z].push_back(y);
    }
    for(int i = 1; i <= n; i++) b[i] = -1;
    for(int i = 1; i <= n; i++) if(a[i] == 1){
        b[1] = i;
        break;
    }
    int cur = b[1];
    for(int i = 2; i <= n/2; i++){
        int mx = min(a[cur] + 1, 3);
        //cout<<i<<" "<<cur<<" "<<mx<<"\n";
        for(auto x: c[cur]){
            if(a[x] == mx){
                b[i] = x;
                cur = b[i];
                break;
            }
        }
    }
    for(int i = n; i >= 0; i--) if(a[i] == 1){
        b[n] = i;
        break;
    }
    cur = b[n];
    for(int i = n - 1; i >= n/2; i--){
        if(b[i] != -1) break;
        int mx = min(a[cur] + 1, 3);
        for(auto x: c[cur]){
            if(a[x] == mx){
                b[i] = x;
                cur = b[i];
                break;
            }
        }
    }
    for(int i = 1; i <= n; i++) cout<<b[i]<<" ";
}
int main()
{
//    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);
    /*
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    */
    int tc = 1;
    //cin>>tc;
    while(tc--){
        solve();
    }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
const int MX = 3e5 + 1, MOD = 1e9 + 7;
int a[MX], b[MX], n, p;

void solve(){
    cin>>n;
    vector<vector<int>> c(n+1);
    for(int i = 1; i <= n; i++) a[i] = 0;
    for(int i = 0; i < n - 2; i++){
        int x, y, z;
        cin>>x>>y>>z;
        a[x]++, a[y]++, a[z]++;
        c[x].push_back(y);
        c[x].push_back(z);
        c[y].push_back(x);
        c[y].push_back(z);
        c[z].push_back(x);
        c[z].push_back(y);
    }
    for(int i = 1; i <= n; i++) b[i] = -1;
    for(int i = 1; i <= n; i++) if(a[i] == 1){
        b[1] = i;
        break;
    }
    for(auto x: c[b[1]])
    if(a[x] == 2){
        b[2] = x;
        break;
    }
    int cur = b[2], prev = b[1];
    for(int i = 3; i <= n; i++){
        //cout<<i<<" "<<cur<<" "<<mx<<"\n";
        for(auto x: c[cur]){
            if(a[x] < 3) continue;
            for(auto y: c[x]){
                if(y == prev){
                    b[i] = x;
                    prev = cur;
                    cur = x;
                    break;
                }
            }
        }
    }
    for(int i = n; i >= 1; i--) if(a[i] == 1){
        b[n] = i;
        break;
    }
    for(auto x: c[b[n]])
    if(a[x] == 2){
        b[n - 1] = x;
        break;
    }
    cur = b[n - 1], prev = b[n];
    for(int i = n - 2; i >= n/2; i++){
        if(b[i] != -1) break;
        //cout<<i<<" "<<cur<<" "<<mx<<"\n";
        for(auto x: c[cur]){
            if(a[x] < 3) continue;
            for(auto y: c[x]){
                if(y == prev){
                    b[i] = x;
                    prev = cur;
                    cur = x;
                    break;
                }
            }
        }
    }
    for(int i = 1; i <= n; i++) cout<<b[i]<<" ";
}
int main()
{
//    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);
    /*
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    */
    int tc = 1;
    //cin>>tc;
    while(tc--){
        solve();
    }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
const int MX = 3e5 + 1, MOD = 1e9 + 7;
int a[MX], b[MX], n, p;

void solve(){
    cin>>n;
    vector<vector<int>> c(n+1);
    for(int i = 1; i <= n; i++) a[i] = 0;
    for(int i = 0; i < n - 2; i++){
        int x, y, z;
        cin>>x>>y>>z;
        a[x]++, a[y]++, a[z]++;
        c[x].push_back(y);
        c[x].push_back(z);
        c[y].push_back(x);
        c[y].push_back(z);
        c[z].push_back(x);
        c[z].push_back(y);
    }
    for(int i = 1; i <= n; i++) b[i] = -1;
    for(int i = 1; i <= n; i++) if(a[i] == 1){
        b[1] = i;
        break;
    }
    for(auto x: c[b[1]])
    if(a[x] == 2){
        b[2] = x;
        break;
    }
    int cur = b[2], prev = b[1];
    for(int i = 3; i <= n - 2; i++){
        //cout<<i<<" "<<cur<<" "<<mx<<"\n";
        for(auto x: c[cur]){
            if(x == prev) continue;
            for(auto y: c[x]){
                if(y == prev){
                    b[i] = x;
                    prev = cur;
                    cur = x;
                    break;
                }
            }
            if(b[i] != -1) break;
        }
    }
    for(int i = n; i >= 0; i--) if(a[i] == 1){
        b[n] = i;
        break;
    }
    for(auto x: c[b[n]])
    if(a[x] == 2){
        b[n - 1] = x;
        break;
    }
    for(int i = 1; i <= n; i++) cout<<b[i]<<" ";
}
int main()
{
//    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);
    /*
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    */
    int tc = 1;
    //cin>>tc;
    while(tc--){
        solve();
    }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
const int MX = 3e5 + 1, MOD = 1e9 + 7;
int a[MX], b[MX], n, p;

void solve(){
    cin>>n;
    vector<vector<int>> c(n+1);
    for(int i = 1; i <= n; i++) a[i] = 0;
    for(int i = 0; i < n - 2; i++){
        int x, y, z;
        cin>>x>>y>>z;
        a[x]++, a[y]++, a[z]++;
        c[x].push_back(y);
        c[x].push_back(z);
        c[y].push_back(x);
        c[y].push_back(z);
        c[z].push_back(x);
        c[z].push_back(y);
    }
    for(int i = 1; i <= n; i++) b[i] = -1;
    for(int i = 1; i <= n; i++) if(a[i] == 1){
        b[1] = i;
        break;
    }
    for(auto x: c[b[1]])
    if(a[x] == 2){
        b[2] = x;
        break;
    }
    int cur = b[2], prev = b[1];
    for(int i = 3; i <= n - 2; i++){
        //cout<<i<<" "<<cur<<" "<<mx<<"\n";
        for(auto x: c[cur]){
            if(x == prev || x == cur) continue;
            for(auto y: c[x]){
                if(y == prev){
                    b[i] = x;
                    prev = cur;
                    cur = x;
                    break;
                }
            }
            if(b[i] != -1) break;
        }
    }
    for(int i = n; i >= 0; i--) if(a[i] == 1){
        b[n] = i;
        break;
    }
    for(auto x: c[b[n]])
    if(a[x] == 2){
        b[n - 1] = x;
        break;
    }
    for(int i = 1; i <= n; i++) cout<<b[i]<<" ";
}
int main()
{
//    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);
    /*
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    */
    int tc = 1;
    //cin>>tc;
    while(tc--){
        solve();
    }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
const int MX = 3e5 + 1, MOD = 1e9 + 7;
int a[MX], b[MX], n, p;

void solve(){
    cin>>n;
    vector<vector<int>> c(n+1);
    for(int i = 1; i <= n; i++) a[i] = 0;
    for(int i = 0; i < n - 2; i++){
        int x, y, z;
        cin>>x>>y>>z;
        a[x]++, a[y]++, a[z]++;
        c[x].push_back(y);
        c[x].push_back(z);
        c[y].push_back(x);
        c[y].push_back(z);
        c[z].push_back(x);
        c[z].push_back(y);
    }
    for(int i = 1; i <= n; i++) b[i] = -1;
    for(int i = 1; i <= n; i++) if(a[i] == 1){
        b[1] = i;
        break;
    }
    for(auto x: c[b[1]])
    if(a[x] == 2){
        b[2] = x;
        break;
    }
    int cur = b[2], prev1 = b[1], prev2 = 0;
    for(int i = 3; i <= n - 2; i++){
        //cout<<i<<" "<<cur<<" "<<mx<<"\n";
        for(auto x: c[cur]){
            if(x == prev1 || x == prev2) continue;
            for(auto y: c[x]){
                if(y == prev1){
                    b[i] = x;
                    prev2 = prev1;
                    prev1 = cur;
                    cur = x;
                    break;
                }
            }
            if(b[i] != -1) break;
        }
    }
    for(int i = n; i >= 0; i--) if(a[i] == 1){
        b[n] = i;
        break;
    }
    for(auto x: c[b[n]])
    if(a[x] == 2){
        b[n - 1] = x;
        break;
    }
    for(int i = 1; i <= n; i++) cout<<b[i]<<" ";
}
int main()
{
//    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);
    /*
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    */
    int tc = 1;
    //cin>>tc;
    while(tc--){
        solve();
    }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
const int MX = 3e5 + 1, MOD = 1e9 + 7;
int a[MX], b[MX], n, p;

void solve(){
    cin>>n;
    vector<vector<int>> c(n+1);
    for(int i = 1; i <= n; i++) a[i] = 0;
    for(int i = 0; i < n - 2; i++){
        int x, y, z;
        cin>>x>>y>>z;
        a[x]++, a[y]++, a[z]++;
        c[x].push_back(y);
        c[x].push_back(z);
        c[y].push_back(x);
        c[y].push_back(z);
        c[z].push_back(x);
        c[z].push_back(y);
    }
    for(int i = 1; i <= n; i++) b[i] = -1;
    for(int i = 1; i <= n; i++) if(a[i] == 1){
        b[1] = i;
        break;
    }
    for(auto x: c[b[1]])
    if(a[x] == 2){
        b[2] = x;
        break;
    }
    int cur = b[2], prev = b[1];
    for(int i = 3; i <= n; i++){
        //cout<<i<<" "<<cur<<" "<<mx<<"\n";
        for(auto x: c[cur]){
            if(x == prev) continue;
            for(auto y: c[x]){
                if(y == prev){
                    b[i] = x;
                    prev = cur;
                    cur = x;
                    break;
                }
            }
            if(b[i] != -1) break;
        }
    }
    for(int i = 1; i <= n; i++) cout<<b[i]<<" ";
}
int main()
{
//    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);
    /*
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    */
    int tc = 1;
    //cin>>tc;
    while(tc--){
        solve();
    }
}


// And Then the GOD Entered..
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define endl "\n"
#define fi first
#define sec second
#define pb push_back
#define test cout<<"debuged\n";
#define INF ll(1e18)
#define MOD 1000000007
#define debug(x) cout<<x<<"\n";
#define pll pair<ll,ll>
#define Minato_Namikaze ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define all(v) v.begin(),v.end()
#define MAX 200005

int main()
{
    Minato_Namikaze
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    ll T = 1;
    // cin >> T;
    while (T--)
    {

         ll n,x,y,z;
         cin >> n;
         map<pll,vector<ll>> ma;
         vector<ll> p(n + 1,0);
         for(ll i = 0; i < n - 2; ++i)
         {
              cin >> x >> y >> z;
              p[x]++;
              p[y]++;
              p[z]++;
              if(ma.count({x,y}) >= 1)
                 ma[{x,y}].pb(z);
              else if(ma.count({y,x}) >= 1)
                 ma[{y,x}].pb(z);
              else
                  ma[{x,y}].pb(z);
              if(ma.count({y,z}) >= 1)
                 ma[{y,z}].pb(x);
              else if(ma.count({z,y}) >= 1)
                 ma[{z,y}].pb(x);
              else
                  ma[{y,z}].pb(x);

              if(ma.count({x,z}) >= 1)
                 ma[{x,z}].pb(y);
              else if(ma.count({z,x}) >= 1)
                 ma[{z,x}].pb(y);
              else
                  ma[{x,z}].pb(y);
         }
         vector<ll> one,two;
         for(ll i = 1; i <= n; ++i)
         {
            if(p[i] == 1)
              one.pb(i);
            if(p[i] == 2)
              two.pb(i);
         }
         vector<ll> ans(n + 1,0);
         x = one[0];
         for(ll i = 0; i < 2; ++i)
         {
            if(ma.count({x,two[i]}) >= 1 or ma.count({two[i],x}) >= 1)
            {
              y = two[i];
              break;
            }
         }

         ans[1] = x;
         ans[2] = y;
         vector<ll> vis(n + 1,0);
         ll a = 1,b = 2;
         vis[x] = 1;
         vis[y] = 1;
         for(ll i = 0; i < n - 2; ++i)
         {
              if(ma.count({ans[a],ans[b]}) >= 1)
              {
                  ll f = ma[{ans[a],ans[b]}][0];
                  if(vis[f] == 0)
                  {
                      ans[b + 1] = ma[{ans[a],ans[b]}][0];
                      vis[f] = 1;
                  }
                  else
                  {
                    ans[b + 1] = ma[{ans[a],ans[b]}][1];
                    vis[f] = 1;
                  }
                  a++;
                  b++;
              }
              else if(ma.count({ans[b],ans[a]}) >= 1)
              {
                  ll f = ma[{ans[b],ans[a]}][0];
                  if(vis[f] == 0)
                  {
                      ans[b + 1] = ma[{ans[b],ans[a]}][0];
                      vis[f] = 1;
                  }
                  else
                  {
                    ans[b + 1] = ma[{ans[b],ans[a]}][1];
                    vis[f] = 1;
                  }
                  a++;
                  b++;
              }
         }
         for(ll i = 1; i <= n; ++i)
          cout << ans[i] << " ";

    }
}


// And Then the GOD Entered..
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define endl "\n"
#define fi first
#define sec second
#define pb push_back
#define test cout<<"debuged\n";
#define INF ll(1e18)
#define MOD 1000000007
#define debug(x) cout<<x<<"\n";
#define pll pair<ll,ll>
#define Minato_Namikaze ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define all(v) v.begin(),v.end()
#define MAX 200005

int main()
{
    Minato_Namikaze
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    ll T = 1;
    // cin >> T;
    while (T--)
    {

         ll n,x,y,z;
         cin >> n;
         map<pll,vector<ll>> ma;
         vector<ll> p(n + 1,0);
         for(ll i = 0; i < n - 2; ++i)
         {
              cin >> x >> y >> z;
              p[x]++;
              p[y]++;
              p[z]++;
              if(ma.count({x,y}) >= 1)
                 ma[{x,y}].pb(z);
              else if(ma.count({y,x}) >= 1)
                 ma[{y,x}].pb(z);
              else
                  ma[{x,y}].pb(z);

              if(ma.count({y,z}) >= 1)
                 ma[{y,z}].pb(x);
              else if(ma.count({z,y}) >= 1)
                 ma[{z,y}].pb(x);
              else
                  ma[{y,z}].pb(x);

              if(ma.count({x,z}) >= 1)
                 ma[{x,z}].pb(y);
              else if(ma.count({z,x}) >= 1)
                 ma[{z,x}].pb(y);
              else
                  ma[{x,z}].pb(y);
         }
         vector<ll> one,two;
         for(ll i = 1; i <= n; ++i)
         {
            if(p[i] == 1)
              one.pb(i);
            if(p[i] == 2)
              two.pb(i);
         }
         vector<ll> ans(n + 1,0);
         x = one[0];
         for(ll i = 0; i < 2; ++i)
         {
            if(ma.count({x,two[i]}) >= 1 or ma.count({two[i],x}) >= 1)
            {
              y = two[i];
              break;
            }
         }
          // for(auto x : ma)
          // {
          //     cout << x.fi.fi << " " << x.fi.sec << " :";
          //     for(auto y : x.sec)
          //       cout << y << " ";
          //     cout << endl;
          // }
         ans[1] = x;
         ans[2] = y;
         vector<ll> vis(n + 1,0);
         ll a = 1,b = 2;
         vis[x] = 1;
         vis[y] = 1;
         for(ll i = 0; i < n - 2; ++i)
         {
              if(ma.count({ans[a],ans[b]}) >= 1)
              {
                  ll f = ma[{ans[a],ans[b]}][0];
                  if(vis[f] == 0)
                  {
                      ans[b + 1] = ma[{ans[a],ans[b]}][0];
                      vis[f] = 1;
                  }
                  else
                  {
                     ll f = ma[{ans[a],ans[b]}][1];
                    ans[b + 1] = ma[{ans[a],ans[b]}][1];
                    vis[f] = 1;
                  }
                  a++;
                  b++;
              }
              else if(ma.count({ans[b],ans[a]}) >= 1)
              {
                  ll f = ma[{ans[b],ans[a]}][0];
                  if(vis[f] == 0)
                  {
                      ans[b + 1] = ma[{ans[b],ans[a]}][0];
                      vis[f] = 1;
                  }
                  else
                  {
                     ll f = ma[{ans[b],ans[a]}][1];
                    ans[b + 1] = ma[{ans[b],ans[a]}][1];
                    vis[f] = 1;
                  }
                  a++;
                  b++;
              }
         }
         for(ll i = 1; i <= n; ++i)
          cout << ans[i] << " ";

    }
}


// And Then the GOD Entered..
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define endl "\n"
#define fi first
#define sec second
#define pb push_back
#define test cout<<"debuged\n";
#define INF ll(1e18)
#define MOD 1000000007
#define debug(x) cout<<x<<"\n";
#define pll pair<ll,ll>
#define Minato_Namikaze ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define all(v) v.begin(),v.end()
#define MAX 200005

int main()
{
    Minato_Namikaze
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    ll T = 1;
    // cin >> T;
    while (T--)
    {

         ll n,x,y,z;
         cin >> n;
         map<pll,vector<ll>> ma;
         vector<ll> p(n + 1,0);
         for(ll i = 0; i < n - 2; ++i)
         {
              cin >> x >> y >> z;
              p[x]++;
              p[y]++;
              p[z]++;
              if(ma.count({x,y}) >= 1)
                 ma[{x,y}].pb(z);
              else if(ma.count({x,y}) >= 1)
                 ma[{y,x}].pb(z);
              else
                  ma[{x,y}].pb(z);
              if(ma.count({y,z}) >= 1)
                 ma[{y,z}].pb(x);
              else if(ma.count({z,y}) >= 1)
                 ma[{z,y}].pb(x);
              else
                  ma[{y,z}].pb(x);

              if(ma.count({x,z}) >= 1)
                 ma[{x,z}].pb(y);
              else if(ma.count({z,x}) >= 1)
                 ma[{z,x}].pb(y);
              else
                  ma[{x,z}].pb(y);
         }
         vector<ll> one,two;
         for(ll i = 1; i <= n; ++i)
         {
            if(p[i] == 1)
              one.pb(i);
            if(p[i] == 2)
              two.pb(i);
         }
         vector<ll> ans(n + 1,0);
         x = one[0];
         for(ll i = 0; i < 2; ++i)
         {
            if(ma.count({x,two[i]}) >= 1 or ma.count({two[i],x}) >= 1)
            {
              y = two[i];
              break;
            }
         }

         ans[1] = x;
         ans[2] = y;
         vector<ll> vis(n + 1,0);
         ll a = 1,b = 2;
         vis[x] = 1;
         vis[y] = 1;
         for(ll i = 0; i < n - 2; ++i)
         {
              if(ma.count({ans[a],ans[b]}) >= 1)
              {
                  ll f = ma[{ans[a],ans[b]}][0];
                  if(vis[f] == 0)
                  {
                      ans[b + 1] = ma[{ans[a],ans[b]}][0];
                      vis[f] = 1;
                  }
                  else
                  {
                    ans[b + 1] = ma[{ans[a],ans[b]}][1];
                    vis[f] = 1;
                  }
                  a++;
                  b++;
              }
              else if(ma.count({ans[b],ans[a]}) >= 1)
              {
                  ll f = ma[{ans[b],ans[a]}][0];
                  if(vis[f] == 0)
                  {
                      ans[b + 1] = ma[{ans[b],ans[a]}][0];
                      vis[f] = 1;
                  }
                  else
                  {
                    ans[b + 1] = ma[{ans[b],ans[a]}][1];
                    vis[f] = 1;
                  }
                  a++;
                  b++;
              }
         }
         for(ll i = 1; i <= n; ++i)
          cout << ans[i] << " ";

    }
}


// And Then the GOD Entered..
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define endl "\n"
#define fi first
#define sec second
#define pb push_back
#define test cout<<"debuged\n";
#define INF ll(1e18)
#define MOD 1000000007
#define debug(x) cout<<x<<"\n";
#define pll pair<ll,ll>
#define Minato_Namikaze ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define all(v) v.begin(),v.end()
#define MAX 200005

int main()
{
    Minato_Namikaze
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    ll T = 1;
    // cin >> T;
    while (T--)
    {

         ll n,x,y,z;
         cin >> n;
         map<pll,vector<ll>> ma;
         vector<ll> p(n + 1,0);
         for(ll i = 0; i < n - 2; ++i)
         {
              cin >> x >> y >> z;
              p[x]++;
              p[y]++;
              p[z]++;
              ma[{x,y}].pb(z);
              ma[{x,z}].pb(y);
              ma[{y,z}].pb(x);
         }
         vector<ll> one,two;
         for(ll i = 1; i <= n; ++i)
         {
            if(p[i] == 1)
              one.pb(i);
            if(p[i] == 2)
              two.pb(i);
         }
         vector<ll> ans(n + 1,0);
         x = one[0];
         for(ll i = 0; i < 2; ++i)
         {
            if(ma.count({x,two[i]}) >= 1 or ma.count({two[i],x}) >= 1)
            {
              y = two[i];
              break;
            }
         }
         ans[1] = x;
         ans[2] = y;
         vector<ll> vis(n + 1,0);
         ll a = 1,b = 2;
         vis[x] = 1;
         vis[y] = 1;
         for(ll i = 0; i < n - 2; ++i)
         {
              if(ma.count({ans[a],ans[b]}) >= 1)
              {
                  ll f = ma[{ans[a],ans[b]}][0];
                  if(vis[f] == 0)
                  {
                      ans[b + 1] = ma[{ans[a],ans[b]}][0];
                      vis[f] = 1;
                  }
                  else
                  {
                    ans[b + 1] = ma[{ans[a],ans[b]}][1];
                  }

                  a++;
                  b++;
              }
              else if(ma.count({ans[b],ans[a]}) >= 1)
              {
                  ll f = ma[{ans[b],ans[a]}][0];
                  if(vis[f] == 0)
                  {
                      ans[b + 1] = ma[{ans[b],ans[a]}][0];
                      vis[f] = 1;
                  }
                  else
                  {
                    ans[b + 1] = ma[{ans[b],ans[a]}][1];
                  }
                  a++;
                  b++;
              }
         }
         for(ll i = 1; i <= n; ++i)
          cout << ans[i] << " ";

    }
}


// And Then the GOD Entered..
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define endl "\n"
#define fi first
#define sec second
#define pb push_back
#define test cout<<"debuged\n";
#define INF ll(1e18)
#define MOD 1000000007
#define debug(x) cout<<x<<"\n";
#define pll pair<ll,ll>
#define Minato_Namikaze ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define all(v) v.begin(),v.end()
#define MAX 200005

int main()
{
    Minato_Namikaze
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    ll T = 1;
    // cin >> T;
    while (T--)
    {

         ll n,x,y,z;
         cin >> n;
         map<pll,vector<ll>> ma;
         vector<ll> p(n + 1,0);
         for(ll i = 0; i < n - 2; ++i)
         {
              cin >> x >> y >> z;
              p[x]++;
              p[y]++;
              p[z]++;
              ma[{x,y}].pb(z);
              ma[{x,z}].pb(y);
              ma[{y,z}].pb(x);
         }
         vector<ll> one,two;
         for(ll i = 1; i <= n; ++i)
         {
            if(p[i] == 1)
              one.pb(i);
            if(p[i] == 2)
              two.pb(i);
         }
         vector<ll> ans(n + 1,0);
         x = one[0];
         for(ll i = 0; i < 2; ++i)
         {
            if(ma.count({x,two[i]}) >= 1 or ma.count({two[i],x}) >= 1)
            {
              y = two[i];
              break;
            }
         }
         ans[1] = x;
         ans[2] = y;
         vector<ll> vis(n + 1,0);
         ll a = 1,b = 2;
         vis[x] = 1;
         vis[y] = 1;
         for(ll i = 0; i < n - 2; ++i)
         {
              if(ma.count({ans[a],ans[b]}) >= 1)
              {
                  ll f = ma[{ans[a],ans[b]}][0];
                  if(vis[f] == 0)
                  {
                      ans[b + 1] = ma[{ans[a],ans[b]}][0];
                      vis[f] = 1;
                  }
                  else
                  {
                    ans[b + 1] = ma[{ans[a],ans[b]}][1];
                    vis[f] = 1;
                  }
                  a++;
                  b++;
              }
              else if(ma.count({ans[b],ans[a]}) >= 1)
              {
                  ll f = ma[{ans[b],ans[a]}][0];
                  if(vis[f] == 0)
                  {
                      ans[b + 1] = ma[{ans[b],ans[a]}]  [0];
                      vis[f] = 1;
                  }
                  else
                  {
                    ans[b + 1] = ma[{ans[b],ans[a]}][1];
                    vis[f] = 1;
                  }
                  a++;
                  b++;
              }
         }
         for(ll i = 1; i <= n; ++i)
          cout << ans[i] << " ";

    }
}


// And Then the GOD Entered..
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define endl "\n"
#define fi first
#define sec second
#define pb push_back
#define test cout<<"debuged\n";
#define INF ll(1e18)
#define MOD 1000000007
#define debug(x) cout<<x<<"\n";
#define pll pair<ll,ll>
#define Minato_Namikaze ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define all(v) v.begin(),v.end()
#define MAX 200005

int main()
{
    Minato_Namikaze
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    ll T = 1;
    // cin >> T;
    while (T--)
    {

         ll n,x,y,z;
         cin >> n;
         map<pll,vector<ll>> ma;
         vector<ll> p(n + 1,0);
         for(ll i = 0; i < n - 2; ++i)
         {
              cin >> x >> y >> z;
              p[x]++;
              p[y]++;
              p[z]++;
              ma[{x,y}].pb(z);
              ma[{x,z}].pb(y);
              ma[{y,z}].pb(x);
         }
         vector<ll> one,two;
         for(ll i = 1; i <= n; ++i)
         {
            if(p[i] == 1)
              one.pb(i);
            if(p[i] == 2)
              two.pb(i);
         }
         vector<ll> ans(n + 1,0);
         x = one[0];
         for(ll i = 0; i < 2; ++i)
         {
            if(ma.count({x,two[i]}) >= 1 or ma.count({two[i],x}) >= 1)
            {
              y = two[i];
              break;
            }
         }
         ans[1] = x;
         ans[2] = y;
         vector<ll> vis(n + 1,0);
         ll a = 1,b = 2;
         vis[x] = 1;
         vis[y] = 1;
         for(ll i = 0; i < n - 2; ++i)
         {
              if(ma.count({ans[a],ans[b]}) >= 1)
              {
                  ll f = ma[{ans[a],ans[b]}][0];
                  if(vis[f] == 0)
                  {
                      ans[b + 1] = ma[{ans[a],ans[b]}][0];
                      vis[f] = 1;
                  }
                  else
                  {
                    ll f = ma[{ans[a],ans[b]}][1];
                    if(vis[f] == 0)
                    {
                        ans[b + 1] = ma[{ans[a],ans[b]}][1];
                        vis[f] = 1;
                    }
                    else
                    {
                        ll f = ma[{ans[a],ans[b]}][2];
                        ans[b + 1] = ma[{ans[a],ans[b]}][2];
                        vis[f] = 1;
                    }
                  }
                  a++;
                  b++;
              }
              else if(ma.count({ans[b],ans[a]}) >= 1)
              {
                  ll f = ma[{ans[b],ans[a]}][0];
                  if(vis[f] == 0)
                  {
                      ans[b + 1] = ma[{ans[b],ans[a]}][0];
                      vis[f] = 1;
                  }
                  else
                  {
                    ll f = ma[{ans[b],ans[a]}][1];
                    if(vis[f] == 0)
                    {

                        ans[b + 1] = ma[{ans[b],ans[a]}][1];
                        vis[f] = 1;
                    }
                    else
                    {
                        ll f = ma[{ans[b],ans[a]}][2];
                        ans[b + 1] = ma[{ans[b],ans[a]}][2];
                        vis[f] = 1;
                    }
                  }
                  a++;
                  b++;
              }
         }
         for(ll i = 1; i <= n; ++i)
          cout << ans[i] << " ";

    }
}


#include <iostream>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>

#define forr(i,x,n) for(int i=(x); i<int(n); i++)
#define forn(i,n) forr(i,0,n)
#define fst first
#define snd second
#define pb push_back

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int MAXN = 1e5 + 5;
const ll INF = 1e16 + 5;
const ll MOD = 1e9 + 7;

vector<int> G[MAXN];

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);

    ll N;
    cin >> N;
    vector<pll> cnt(N);
    forn(i,N) cnt[i] = {0,i};

    forn(i,N-2){
        ll a, b, c;
        cin >> a >> b >> c;
        a--, b--, c--;

        G[a].pb(b);
        G[a].pb(c);
        G[b].pb(a);
        G[b].pb(c);
        G[c].pb(a);
        G[c].pb(b);

        cnt[a].fst++;
        cnt[b].fst++;
        cnt[c].fst++;
    }

    set<pll> S;
    for(auto c : cnt) S.insert(c);

    while(S.size()){
        auto e = *S.begin();
        S.erase(S.begin());

        auto k = e.snd;
        for(auto v : G[k]){
            auto it = S.lower_bound({-1, v});
            if(it != S.end()){
                auto _e = *it;
                S.erase(_e);
                S.insert({_e.fst + 1, _e.snd});
            }
        }

        cout << k + 1 << ' ';
    }

    return 0;
}


#include <iostream>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <cassert>

#define forr(i,x,n) for(int i=(x); i<int(n); i++)
#define forn(i,n) forr(i,0,n)
#define fst first
#define snd second
#define pb push_back

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int MAXN = 1e5 + 5;
const ll INF = 1e16 + 5;
const ll MOD = 1e9 + 7;

vector<int> G[MAXN];

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);

    ll N;
    cin >> N;
    vector<pll> cnt(N);

    struct tri : public vector<int> {
        tri() : vector<int>(3) {
            sort(this->begin(), this->end());
        }

        bool operator < (const tri& t) {
            auto p1 = make_pair((*this)[0], (*this)[1]);
            auto p2 = make_pair((*this)[1], (*this)[2]);

            auto t1 = make_pair(t[0], t[1]);
            auto t2 = make_pair(t[1], t[2]);

            if(p1 == t1) return p2 < t2;
            return p1 < t1;
        }
    };
    vector<tri> V(N-2);
    map<int, int> M1;
    map<pii, int> M2;

    forn(i,N) cnt[i] = {0,i};

    forn(i, N-2){
        tri x;
        forn(j,3){ cin >> x[j]; x[j]--; }
        forn(j,3) cnt[x[j]].fst++;

        V[i] = x;
        sort(V[i].begin(), V[i].end());
        M1[V[i][0]] = i;
        M1[V[i][1]] = i;
        M1[V[i][2]] = i;
        M2[{V[i][0], V[i][1]}] = i;
        M2[{V[i][0], V[i][2]}] = i;
        M2[{V[i][1], V[i][2]}] = i;
    }
    sort(cnt.begin(), cnt.end());

    vector<int> ans;

    auto rekt = [&](int i, int e1, int e2){
        auto& t = V[i];
        forn(j, 3) if(t[j] != e1 and t[j] != e2) return t[j];
        assert(false);
    };

    ans.push_back(cnt[0].snd);
    auto x = M1[ans[0]];
    for(auto e : V[x]) if(cnt[e].fst == 2){ ans.push_back(e); break; }

    for(int i = 2; i < N - 2; i++){
        auto ind = M2[{min(ans[i-2], ans[i-1]), max(ans[i-2], ans[i-1])}];
        auto e = rekt(ind, ans[i-2], ans[i-1]);
        ans.push_back(e);
    }

    bool check = false;
    for(auto x : ans) if(x == cnt[2].snd){ check = true; break; }

    if(check) ans.pb(cnt[3].snd);
    else      ans.pb(cnt[2].snd);
    ans.pb(cnt[1].snd);

    forn(i,ans.size()){
        cout << ans[i] + 1 << " \n"[i == int(ans.size()) - 1];
    }

    return 0;
}


#include <iostream>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <cassert>

#define forr(i,x,n) for(int i=(x); i<int(n); i++)
#define forn(i,n) forr(i,0,n)
#define fst first
#define snd second
#define pb push_back

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int MAXN = 1e5 + 5;
const ll INF = 1e16 + 5;
const ll MOD = 1e9 + 7;

vector<int> G[MAXN];

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);

    ll N;
    cin >> N;
    vector<pll> cnt(N);

    struct tri : public vector<int> {
        tri() : vector<int>(3) {
            sort(this->begin(), this->end());
        }

        bool operator < (const tri& t) {
            auto p1 = make_pair((*this)[0], (*this)[1]);
            auto p2 = make_pair((*this)[1], (*this)[2]);

            auto t1 = make_pair(t[0], t[1]);
            auto t2 = make_pair(t[1], t[2]);

            if(p1 == t1) return p2 < t2;
            return p1 < t1;
        }
    };
    vector<tri> V(N-2);
    map<int, int> M1;
    map<pii, set<int>> M2;
    map<int,int> C;

    forn(i,N) cnt[i] = {0,i};

    forn(i, N-2){
        tri x;
        forn(j,3){ cin >> x[j]; x[j]--; }
        forn(j,3) cnt[x[j]].fst++;
        forn(j,3) C[x[j]]++;

        V[i] = x;
        sort(V[i].begin(), V[i].end());
        M1[V[i][0]] = i;
        M1[V[i][1]] = i;
        M1[V[i][2]] = i;
        M2[{V[i][0], V[i][1]}].insert(i);
        M2[{V[i][0], V[i][2]}].insert(i);
        M2[{V[i][1], V[i][2]}].insert(i);
    }
    sort(cnt.begin(), cnt.end());

    vector<int> ans;

    auto rekt = [&](int i, int e1, int e2){
        auto& t = V[i];
        forn(j, 3) if(t[j] != e1 and t[j] != e2) return t[j];
        assert(false);
    };

    ans.push_back(cnt[0].snd);
    auto x = M1[ans[0]];
    for(auto e : V[x]) if(C[e] == 2){ ans.push_back(e); break; }

    for(int i = 2; i < N - 2; i++){
        auto it = M2[{min(ans[i-2], ans[i-1]), max(ans[i-2], ans[i-1])}].begin();
        auto ind = *it;
        M2[{min(ans[i-2], ans[i-1]), max(ans[i-2], ans[i-1])}].erase(it);
        auto e = rekt(ind, ans[i-2], ans[i-1]);
        ans.push_back(e);
    }

    bool check = false;
    for(auto x : ans) if(x == cnt[2].snd){ check = true; break; }

    if(check) ans.pb(cnt[3].snd);
    else      ans.pb(cnt[2].snd);
    ans.pb(cnt[1].snd);

    forn(i,ans.size()){
        cout << ans[i] + 1 << " \n"[i == int(ans.size()) - 1];
    }

    return 0;
}


#include <iostream>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <cassert>

#define forr(i,x,n) for(int i=(x); i<int(n); i++)
#define forn(i,n) forr(i,0,n)
#define fst first
#define snd second
#define pb push_back

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int MAXN = 1e5 + 5;
const ll INF = 1e16 + 5;
const ll MOD = 1e9 + 7;

vector<int> G[MAXN];

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);

    ll N;
    cin >> N;
    vector<pll> cnt(N);

    struct tri : public vector<int> {
        tri() : vector<int>(3) {
            sort(this->begin(), this->end());
        }

        bool operator < (const tri& t) {
            auto p1 = make_pair((*this)[0], (*this)[1]);
            auto p2 = make_pair((*this)[1], (*this)[2]);

            auto t1 = make_pair(t[0], t[1]);
            auto t2 = make_pair(t[1], t[2]);

            if(p1 == t1) return p2 < t2;
            return p1 < t1;
        }
    };
    vector<tri> V(N-2);
    map<int, int> M1;
    map<pii, set<int>> M2;
    map<int,int> C;

    forn(i,N) cnt[i] = {0,i};

    forn(i, N-2){
        tri x;
        forn(j,3){ cin >> x[j]; x[j]--; }
        forn(j,3) cnt[x[j]].fst++;
        forn(j,3) C[x[j]]++;

        V[i] = x;
        sort(V[i].begin(), V[i].end());
        M1[V[i][0]] = i;
        M1[V[i][1]] = i;
        M1[V[i][2]] = i;
        M2[{V[i][0], V[i][1]}].insert(i);
        M2[{V[i][0], V[i][2]}].insert(i);
        M2[{V[i][1], V[i][2]}].insert(i);
    }
    sort(cnt.begin(), cnt.end());

    vector<int> ans;

    auto rekt = [&](int i, int e1, int e2){
        auto& t = V[i];
        forn(j, 3) if(t[j] != e1 and t[j] != e2) return t[j];
        assert(false);
    };

    ans.push_back(cnt[0].snd);
    auto x = M1[ans[0]];
    for(auto e : V[x]) if(C[e] == 2){ ans.push_back(e); break; }

    for(int i = 2; i < N - 2; i++){
        auto it = M2[{min(ans[i-2], ans[i-1]), max(ans[i-2], ans[i-1])}].begin();
        auto ind = *it;
        M2[{V[ind][0], V[ind][1]}].erase(ind);
        M2[{V[ind][0], V[ind][2]}].erase(ind);
        M2[{V[ind][1], V[ind][2]}].erase(ind);
        auto e = rekt(ind, ans[i-2], ans[i-1]);
        ans.push_back(e);
    }

    bool check = false;
    for(auto x : ans) if(x == cnt[2].snd){ check = true; break; }

    if(check) ans.pb(cnt[3].snd);
    else      ans.pb(cnt[2].snd);
    ans.pb(cnt[1].snd);

    forn(i,ans.size()){
        cout << ans[i] + 1 << " \n"[i == int(ans.size()) - 1];
    }

    return 0;
}


#include <iostream>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>

#define forr(i,x,n) for(int i=(x); i<int(n); i++)
#define forn(i,n) forr(i,0,n)
#define fst first
#define snd second
#define pb push_back

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int MAXN = 1e5 + 5;
const ll INF = 1e16 + 5;
const ll MOD = 1e9 + 7;

vector<int> G[MAXN];

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);

    ll N;
    cin >> N;
    vector<pll> cnt(N);
    forn(i,N) cnt[i] = {0,i};

    forn(i, N-2){
        ll x[3];
        forn(j,3) cin >> x[j], x[j]--;
        forn(j,3) cnt[x[j]].fst++;
    }
    sort(cnt.begin(), cnt.end());

    int l = 0, r = N-1;
    vector<ll> ans(N);
    for(int i = 0; i < N; i += 2){
        ans[l++] = cnt[i].snd;
        if(r > l) ans[r--] = cnt[i+1].snd;
    }

    forn(i, N) cout << ans[i] + 1 << " \n"[i == N-1];

    return 0;
}


#include <iostream>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <cassert>

#define forr(i,x,n) for(int i=(x); i<int(n); i++)
#define forn(i,n) forr(i,0,n)
#define fst first
#define snd second
#define pb push_back

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int MAXN = 1e5 + 5;
const ll INF = 1e16 + 5;
const ll MOD = 1e9 + 7;

vector<int> G[MAXN];

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);

    ll N;
    cin >> N;
    vector<pll> cnt(N);

    struct tri : public vector<int> {
        tri() : vector<int>(3) {
            sort(this->begin(), this->end());
        }

        bool operator < (const tri& t) {
            auto p1 = make_pair((*this)[0], (*this)[1]);
            auto p2 = make_pair((*this)[1], (*this)[2]);

            auto t1 = make_pair(t[0], t[1]);
            auto t2 = make_pair(t[1], t[2]);

            if(p1 == t1) return p2 < t2;
            return p1 < t1;
        }
    };
    vector<tri> V(N-2);
    map<int, int> M1;
    map<pii, int> M2;
    map<int,int> C;

    forn(i,N) cnt[i] = {0,i};

    forn(i, N-2){
        tri x;
        forn(j,3){ cin >> x[j]; x[j]--; }
        forn(j,3) cnt[x[j]].fst++;
        forn(j,3) C[x[j]]++;

        V[i] = x;
        sort(V[i].begin(), V[i].end());
        M1[V[i][0]] = i;
        M1[V[i][1]] = i;
        M1[V[i][2]] = i;
        M2[{V[i][0], V[i][1]}] = i;
        M2[{V[i][0], V[i][2]}] = i;
        M2[{V[i][1], V[i][2]}] = i;
    }
    sort(cnt.begin(), cnt.end());

    vector<int> ans;

    auto rekt = [&](int i, int e1, int e2){
        auto& t = V[i];
        forn(j, 3) if(t[j] != e1 and t[j] != e2) return t[j];
        assert(false);
    };

    ans.push_back(cnt[0].snd);
    auto x = M1[ans[0]];
    for(auto e : V[x]) if(C[e] == 2){ ans.push_back(e); break; }

    for(int i = 2; i < N - 2; i++){
        auto ind = M2[{min(ans[i-2], ans[i-1]), max(ans[i-2], ans[i-1])}];
        auto e = rekt(ind, ans[i-2], ans[i-1]);
        ans.push_back(e);
    }

    bool check = false;
    for(auto x : ans) if(x == cnt[2].snd){ check = true; break; }

    if(check) ans.pb(cnt[3].snd);
    else      ans.pb(cnt[2].snd);
    ans.pb(cnt[1].snd);

    forn(i,ans.size()){
        cout << ans[i] + 1 << " \n"[i == int(ans.size()) - 1];
    }

    return 0;
}


/**
* F
*/
#include<iostream>
#include<set>
#include<map>
#include<vector>
using namespace std;

int main(){
    int n;scanf(" %d",&n);
    map<int,int> freq;
    vector<set<int>> rela(n+1);
    for(int i = 0; i < n-2;++i){
        int a,b,c;scanf(" %d %d %d",&a,&b,&c);
        if(freq.count(a))++freq[a];
        else freq[a] = 1;
        if(freq.count(b)) ++freq[b];
        else freq[b] = 1;
        if(freq.count(c)) ++freq[c];
        else freq[c] = 1;
        rela[a].insert(b);rela[a].insert(c);
        rela[b].insert(a);rela[b].insert(c);
        rela[c].insert(a);rela[c].insert(b);
    }
    int va1 = -1;
    for(auto &va:freq){
        if(va.second == 1 && va1 == -1){
        	va1 = va.second;break;
        }
    }
    int ans[n];
    ans[0] = va1;
    printf("%d ",va1);
    int a = *rela[va1].begin(), b = *rela[va1].rbegin();
    rela[a].erase(va1);rela[a].erase(b); rela[b].erase(a);
    rela[b].erase(va1);
    if(freq[b] == 2){ ans[1] = b;ans[2] = a;}
    else{ ans[1] = a; ans[2] = b;}
    for(int i = 1; i < n-2;++i){
    	printf("%d ",ans[i]);
    	ans[i+2] = *(rela[ans[i]].begin());
    	rela[ans[i+1]].erase(ans[i+2]);
    }
    printf("%d %d\n",ans[n-2],ans[n-1]);
    return 0;
}


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

int main(){
    int n;scanf(" %d",&n);
    map<int,int> freq;
    vector<set<int>> rela(n+1);
    for(int i = 0; i < n-2;++i){
        int a,b,c;scanf(" %d %d %d",&a,&b,&c);
        if(freq.count(a))++freq[a];
        else freq[a] = 1;
        if(freq.count(b)) ++freq[b];
        else freq[b] = 1;
        if(freq.count(c)) ++freq[c];
        else freq[c] = 1;
        rela[a].insert(b);rela[a].insert(c);
        rela[b].insert(a);rela[b].insert(c);
        rela[c].insert(a);rela[c].insert(b);
    }
    vector<pair<int,int>> lel;
    for(auto &va:freq)
        lel.push_back({va.second,va.first});
    sort(lel.begin(),lel.end());
    vector<int> ans(n);
    for(int i = 0, j = n-1,k = 0; i < n;i+=2,--j,++k){
        if(i == n-1)
            ans[k] = lel[i].second;
        else if(i == 0){
            ans[k] = lel[i].second;
            ans[j] = lel[i+1].second;
        }
        else{
            if(rela[lel[i].second].count(ans[k-1])){
                ans[k] = lel[i].second;
                ans[j] = lel[i+1].second;
            }
            else{
                ans[j] = lel[i].second;
                ans[k] = lel[i+1].second;
            }
        }
    }
    for(int i = 0; i < n;++i)printf("%d ",ans[i]);
    puts("");
    return 0;
}


/**
* F
*/
#include<iostream>
#include<set>
#include<map>
#include<vector>
using namespace std;

int main(){
    int n;scanf(" %d",&n);
    map<int,int> freq;
    vector<set<int>> rela(n+1);
    for(int i = 0; i < n-2;++i){
        int a,b,c;scanf(" %d %d %d",&a,&b,&c);
        if(freq.count(a))++freq[a];
        else freq[a] = 1;
        if(freq.count(b)) ++freq[b];
        else freq[b] = 1;
        if(freq.count(c)) ++freq[c];
        else freq[c] = 1;
        rela[a].insert(b);rela[a].insert(c);
        rela[b].insert(a);rela[b].insert(c);
        rela[c].insert(a);rela[c].insert(b);
    }
    int va1 = -1;
    for(auto &va:freq){
    	//cout << va.first << " " << va.second << endl;
        if(va.second == 1 && va1 == -1){
        	va1 = va.first;break;
        }
    }
    int ans[n];
    ans[0] = va1;
    printf("%d ",va1);
    int a = *rela[va1].begin(), b = *rela[va1].rbegin();
    rela[a].erase(va1);rela[a].erase(b); rela[b].erase(a);
    rela[b].erase(va1);
    if(freq[b] == 2){ ans[1] = b;ans[2] = a;}
    else{ ans[1] = a; ans[2] = b;}
    for(int i = 1; i < n-2;++i){
    	printf("%d ",ans[i]);
    	ans[i+2] = *(rela[ans[i]].begin());
    	rela[ans[i+1]].erase(ans[i+2]);
    	rela[ans[i+2]].erase(ans[i+1]);
    	rela[ans[i+2]].erase(ans[i]);
    }
    printf("%d %d\n",ans[n-2],ans[n-1]);
    return 0;
}


/**
* F
*/
#include<iostream>
#include<set>
#include<map>
#include<vector>
using namespace std;

int main(){
    int n;scanf(" %d",&n);
    map<int,int> freq;
    vector<set<int>> rela(n+1);
    for(int i = 0; i < n-2;++i){
        int a,b,c;scanf(" %d %d %d",&a,&b,&c);
        if(freq.count(a))++freq[a];
        else freq[a] = 1;
        if(freq.count(b)) ++freq[b];
        else freq[b] = 1;
        if(freq.count(c)) ++freq[c];
        else freq[c] = 1;
        rela[a].insert(b);rela[a].insert(c);
        rela[b].insert(a);rela[b].insert(c);
        rela[c].insert(a);rela[c].insert(b);
    }
    int va1 = -1;
    for(auto &va:freq){
    	//cout << va.first << " " << va.second << endl;
        if(va.second == 1 && va1 == -1){
        	va1 = va.first;break;
        }
    }
    int ans[n];
    ans[0] = va1;
    printf("%d ",va1);
    int a = *rela[va1].begin(), b = *rela[va1].rbegin();
    rela[a].erase(va1);rela[a].erase(b); rela[b].erase(a);
    rela[b].erase(va1);
    if(freq[b] == 2){ ans[1] = b;ans[2] = a;}
    else{ ans[1] = a; ans[2] = b;}
    for(int i = 1; i < n-2;++i){
    	printf("%d ",ans[i]);
    	ans[i+2] = *(rela[ans[i]].begin());
    	rela[ans[i+1]].erase(ans[i+2]);
    }
    printf("%d %d\n",ans[n-2],ans[n-1]);
    return 0;
}


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

int main(){
    int n;scanf(" %d",&n);
    map<int,int> freq;
    vector<set<int>> rela(n+1);
    for(int i = 0; i < n-2;++i){
        int a,b,c;scanf(" %d %d %d",&a,&b,&c);
        if(freq.count(a))++freq[a];
        else freq[a] = 1;
        if(freq.count(b)) ++freq[b];
        else freq[b] = 1;
        if(freq.count(c)) ++freq[c];
        else freq[c] = 1;
        rela[a].insert(b);rela[a].insert(c);
        rela[b].insert(a);rela[b].insert(c);
        rela[c].insert(a);rela[c].insert(b);
    }
    vector<pair<int,int>> lel;
    for(auto &va:freq)
        lel.push_back({va.second,va.first});
    sort(lel.begin(),lel.end());
    vector<int> ans(n);
    for(int i = 0, j = n-1,k = 0; i < n;i+=2,--j,++k){
        if(i == n-1)
            ans[k] = lel[i].second;
        else if(i == 0){
            ans[k] = lel[i].second;
            ans[j] = lel[i+1].second;
        }
        else{
            if(rela[lel[i].second].count(ans[max(k-2,0)])){
                ans[k] = lel[i].second;
                ans[j] = lel[i+1].second;
            }
            else{
                ans[j] = lel[i].second;
                ans[k] = lel[i+1].second;
            }
        }
    }
    for(int i = 0; i < n;++i)printf("%d ",ans[i]);
    puts("");
    return 0;
}


/**
* F
*/
#include<iostream>
#include<set>
#include<map>
using namespace std;

int main(){
    int n;scanf(" %d",&n);
    map<int,int> freq;
    vector<set<int>> rela(n+1);
    for(int i = 0; i < n-2;++i){
        int a,b,c;scanf(" %d %d %d",&a,&b,&c);
        if(freq.count(a))++freq[a];
        else freq[a] = 1;
        if(freq.count(b)) ++freq[b];
        else freq[b] = 1;
        if(freq.count(c)) ++freq[c];
        else freq[c] = 1;
        rela[a].insert(b);rela[a].insert(c);
        rela[b].insert(a);rela[b].insert(c);
        rela[c].insert(a);rela[c].insert(b);
    }
    int va1 = -1;
    for(auto &va:freq){
        if(va.second == 1 && va1 == -1){
        	va1 = va.second;break;
        }
    }
    int ans[n];
    ans[0] = va1;
    printf("%d ",va1);
    int a = *rela[va1].begin(), b = *rela[va1].rbegin();
    rela[a].erase(va1);rela[a].erase(b); rela[b].erase(a);
    rela[b].erase(va1);
    if(freq[b] == 2){ ans[1] = b;ans[2] = a;}
    else{ ans[1] = a; ans[2] = b;}
    for(int i = 1; i < n-2;++i){
    	printf("%d ",ans[i]);
    	ans[i+2] = *(rela[ans[i]].begin());
    	rela[ans[i+1]].erase(ans[i+2]);
    }
    printf("%d %d\n",ans[n-2],ans[n-1]);
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <ctime>
#include <queue>
#include <stack>
#include <deque>
#include <bitset>
#include <set>
#include <map>
#define lowbit(x) x&(-x)

using namespace std;
typedef long long LL;
typedef unsigned long long uLL;
const int N = 1e5+10;
const int M = 1e5;
const int INF = 1e9+7;
const int mod = 1e9+7;

inline int read()
{
    int s=0,w=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
        if(ch=='-')w=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
    return s*w;
}

int dis[N][10];
int vis[N];
int sss[N];

void Fun(int x, int y, int z)
{
    for ( int i=0; i<8; i++ )
    {
        if ( dis[x][i] ) continue;
        else { dis[x][i] = z; break; }
    }
    for ( int i=0; i<8; i++ )
    {
        if ( dis[y][i] ) continue;
        else { dis[y][i] = z; break; }
    }

    for ( int i=0; i<8; i++ )
    {
        if ( dis[x][i] ) continue;
        else { dis[x][i] = y; break; }
    }
    for ( int i=0; i<8; i++ )
    {
        if ( dis[z][i] ) continue;
        else { dis[z][i] = y; break; }
    }

    for ( int i=0; i<8; i++ )
    {
        if ( dis[z][i] ) continue;
        else { dis[z][i] = x; break; }
    }
    for ( int i=0; i<8; i++ )
    {
        if ( dis[y][i] ) continue;
        else { dis[y][i] = x; break; }
    }
}

int Find(int x, int y, int z)
{
    for (int i=0; i<8; i++ )
        for ( int j=0; j<8; j++ )
            if ( (dis[x][i] == dis[y][j]) && dis[x][i] && dis[y][j]
                && dis[x][i] != z && dis[x][i] != y && dis[x][i] != x )
                return dis[x][i];
    return 0;
}

struct node
{
    int x, y, z;
} mp[N];

int main()
{
    memset( dis, 0, sizeof dis);
    memset( vis, 0, sizeof vis);
    memset( sss, 0, sizeof sss);
    memset( mp, 0, sizeof mp);
    int n, k;
    n = read();
    for ( int i=1; i<=n-2; i++ )
    {
        mp[i].x = read();
        mp[i].y = read();
        mp[i].z = read();
//        mp[i].x = i+2;
//        mp[i].y = i;
//        mp[i].z = i+1;
        if ( !vis[mp[i].x] ) k = i;
        vis[mp[i].x] ++;
        if ( !vis[mp[i].y] ) k = i;
        vis[mp[i].y] ++;
        if ( !vis[mp[i].z] ) k = i;
        vis[mp[i].z] ++;
        Fun(mp[i].x, mp[i].y, mp[i].z);
    }

    for ( int i=1; i<=n; i++ )
        sss[i] = vis[i];

    int x, y, z;
    int a, b, c;
    x = mp[k].x;
    y = mp[k].y;
    z = mp[k].z;

    for ( int i=0; i<n-2; i++ )
    {
        if ( vis[x] == 1 ) a = x, b = y, c = z;
        if ( vis[y] == 1 ) a = y, b = x, c = z;
        if ( vis[z] == 1 ) a = z, b = x, c = y;
        printf("%d ", a);
        x = Find(b, c, a);
        y = b;
        z = c;
        if ( vis[x] == 1 )
        {
            if ( sss[z] > sss[y] )
                printf("%d %d %d\n", z, y, x);
            else
                printf("%d %d %d\n", y, z, x);
            break;
        }
        vis[a]--, vis[b]--, vis[c]--;
    }
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <ctime>
#include <queue>
#include <stack>
#include <deque>
#include <bitset>
#include <set>
#include <map>
#define lowbit(x) x&(-x)

using namespace std;
typedef long long LL;
typedef unsigned long long uLL;
const int N = 1e5+10;
const int M = 1e5;
const int INF = 1e9+7;
const int mod = 1e9+7;

inline int read()
{
    int s=0,w=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
        if(ch=='-')w=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
    return s*w;
}

int dis[N*10];
int vis[N];
int sss[N];

void Fun(int x, int y, int z)
{
    for ( int i=0; i<8; i++ )
    {
        if ( dis[x+i*M] ) continue;
        else { dis[x+i*M] = z; break; }
    }
    for ( int i=0; i<8; i++ )
    {
        if ( dis[y+i*M] ) continue;
        else { dis[y+i*M] = z; break;}
    }

    for ( int i=0; i<8; i++ )
    {
        if ( dis[x+i*M] ) continue;
        else { dis[x+i*M] = y; break; }
    }
    for ( int i=0; i<8; i++ )
    {
        if ( dis[z+i*M] ) continue;
        else { dis[z+i*M] = y; break; }
    }

    for ( int i=0; i<8; i++ )
    {
        if ( dis[z+i*M] ) continue;
        else { dis[z+i*M] = x; break; }
    }
    for ( int i=0; i<8; i++ )
    {
        if ( dis[y+i*M] ) continue;
        else { dis[y+i*M] = x; break; }
    }
}

int Find(int x, int y, int z)
{
    for (int i=0; i<8; i++ )
        for ( int j=0; j<8; j++ )
            if ( (dis[i*M+x] == dis[j*M+y]) && dis[i*M+x] && dis[j*M+y]
                && dis[i*M+x] != z && dis[i*M+x] != y && dis[i*M+x] != x )
                return dis[i*M+x];
}

struct node
{
    int x, y, z;
} mp[N];

int main()
{
    memset( dis, 0, sizeof dis);
    memset( vis, 0, sizeof vis);
    memset( sss, 0, sizeof sss);
    memset( mp, 0, sizeof mp);
    int n, k;
    n = read();
    for ( int i=1; i<=n-2; i++ )
    {
        mp[i].x = read();
        mp[i].y = read();
        mp[i].z = read();
        if ( !vis[mp[i].x] ) k = i;
        vis[mp[i].x] ++;
        if ( !vis[mp[i].y] ) k = i;
        vis[mp[i].y] ++;
        if ( !vis[mp[i].z] ) k = i;
        vis[mp[i].z] ++;
        Fun(mp[i].x, mp[i].y, mp[i].z);
    }

    for ( int i=1; i<=n; i++ )
        sss[i] = vis[i];

    int x, y, z;
    int a, b, c;
    x = mp[k].x;
    y = mp[k].y;
    z = mp[k].z;

    for ( int i=0; i<n-2; i++ )
    {
        if ( vis[x] == 1 ) a = x, b = y, c = z;
        if ( vis[y] == 1 ) a = y, b = x, c = z;
        if ( vis[z] == 1 ) a = z, b = x, c = y;
        printf("%d ", a);
        x = Find(b, c, a);
        y = b;
        z = c;
        if ( vis[x] ==1 )
        {
            if ( sss[z] > sss[y] )
                printf("%d %d %d\n", z, y, x);
            else
                printf("%d %d %d\n", y, z, x);
            break;
        }
        vis[a]--, vis[b]--, vis[c]--;
    }
    return 0;
}

/*
5
1 2 3
2 3 4
3 4 5
*/


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <ctime>
#include <queue>
#include <stack>
#include <deque>
#include <bitset>
#include <set>
#include <map>
#define lowbit(x) x&(-x)
#define mes(x, a) memset(x, a, sizeof x)
using namespace std;
typedef long long LL;
typedef unsigned long long uLL;
const int N = 1e5+10;
const int M = 1e5;
const int INF = 1e9+7;
const int mod = 1e9+7;

inline int read()
{
    int s=0,w=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
        if(ch=='-')w=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
    return s*w;
}

int dis[N][10];
int vis[N];
int sss[N];

void Fun(int x, int y, int z)
{
    for (int i=0; i<6; i++ )
    {
        if (dis[x][i]) continue;
        else { dis[x][i]=y; break;}
    }
    for (int i=0; i<6; i++ )
    {
        if (dis[z][i]) continue;
        else { dis[z][i]=y; break;}
    }

    for (int i=0; i<6; i++ )
    {
        if (dis[x][i]) continue;
        else { dis[x][i]=z; break;}
    }
    for (int i=0; i<6; i++ )
    {
        if (dis[y][i]) continue;
        else { dis[y][i]=z; break;}
    }

        for (int i=0; i<6; i++ )
    {
        if (dis[z][i]) continue;
        else { dis[z][i]=x; break;}
    }
        for (int i=0; i<6; i++ )
    {
        if (dis[y][i]) continue;
        else { dis[y][i]=x; break;}
    }
}

int Find(int x, int y, int z)
{
    for ( int i=0; i<6; i++ )
        for ( int j=0; j<6; j++ )
            if ( dis[x][i]==dis[y][j] )
                if ( dis[x][i] && dis[y][j] && dis[x][i]!=z )
                    return dis[x][i];
}

int main()
{
    mes(vis, 0);
    mes(sss, 0);
    mes(dis, 0);
    int n, a, b, c, x, y, z;
    n = read();
    for (int i=0; i<n-2; i++ )
    {
        c = read();
        b = read();
        a = read();
        if ( !vis[a] ) x=a, y=b, z=c;
        if ( !vis[b] ) x=a, y=b, z=c;
        if ( !vis[c] ) x=a, y=b, z=c;
        vis[a] ++;
        vis[b] ++;
        vis[c] ++;
        Fun(a, b, c);
    }

    for (int i=1; i<=n; i++ ) sss[i] = vis[i];
    for ( int i=0; i<n; i++ )
    {
        if ( vis[x] == 1 ) a=x, b=y, c=z;
        if ( vis[y] == 1 ) a=y, b=x, c=z;
        if ( vis[z] == 1 ) a=z, b=y, c=x;
        printf("%d ", a);
        x = Find(b, c, a);
        y = b, z = c;
        if ( vis[x]==1 )
        {
            if ( sss[y] > sss[z] ) printf("%d %d %d\n", y, z, x);
            else printf("%d %d %d\n", z, y, x);
            break;
        }
        vis[a]--, vis[b]--, vis[c]--;
    }

    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <ctime>
#include <queue>
#include <stack>
#include <deque>
#include <bitset>
#include <set>
#include <map>
#define lowbit(x) x&(-x)

using namespace std;
typedef long long LL;
typedef unsigned long long uLL;
const int N = 1e5+10;
const int M = 1e5;
const int INF = 1e9+7;
const int mod = 1e9+7;

inline int read()
{
    int s=0,w=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
        if(ch=='-')w=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
    return s*w;
}

int dis[N*6];
int vis[N];
int sss[N];

void Fun(int x, int y, int z)
{
    for ( int i=0; i<6; i++ )
    {
        if ( dis[x+i*M] ) continue;
        else { dis[x+i*M] = z; break; }
    }
    for ( int i=0; i<6; i++ )
    {
        if ( dis[y+i*M] ) continue;
        else { dis[y+i*M] = z; break;}
    }

    for ( int i=0; i<6; i++ )
    {
        if ( dis[x+i*M] ) continue;
        else { dis[x+i*M] = y; break; }
    }
    for ( int i=0; i<6; i++ )
    {
        if ( dis[z+i*M] ) continue;
        else { dis[z+i*M] = y; break; }
    }

    for ( int i=0; i<6; i++ )
    {
        if ( dis[z+i*M] ) continue;
        else { dis[z+i*M] = x; break; }
    }
    for ( int i=0; i<6; i++ )
    {
        if ( dis[y+i*M] ) continue;
        else { dis[y+i*M] = x; break; }
    }
}

int Find(int x, int y, int z)
{
    for (int i=0; i<6; i++ )
        for ( int j=0; j<6; j++ )
            if ( (dis[i*M+x] == dis[j*M+y]) && dis[i*M+x] && dis[j*M+y]
                && dis[i*M+x] != z && dis[i*M+x] != y && dis[i*M+x] != x )
                return dis[i*M+x];
}

struct node
{
    int x, y, z;
} mp[N];

int main()
{
    memset( dis, 0, sizeof dis);
    memset( vis, 0, sizeof vis);
    memset( sss, 0, sizeof sss);
    memset( mp, 0, sizeof mp);
    int n, k;
    n = read();
    for ( int i=1; i<=n-2; i++ )
    {
        mp[i].x = read();
        mp[i].y = read();
        mp[i].z = read();
        if ( !vis[mp[i].x] ) k = i;
        vis[mp[i].x] ++;
        if ( !vis[mp[i].y] ) k = i;
        vis[mp[i].y] ++;
        if ( !vis[mp[i].z] ) k = i;
        vis[mp[i].z] ++;
        Fun(mp[i].x, mp[i].y, mp[i].z);
    }

    for ( int i=1; i<=n; i++ )
        sss[i] = vis[i];

    int x, y, z;
    int a, b, c;
    x = mp[k].x;
    y = mp[k].y;
    z = mp[k].z;

    for ( int i=0; i<n-2; i++ )
    {
        if ( vis[x] == 1 ) a = x, b = y, c = z;
        if ( vis[y] == 1 ) a = y, b = x, c = z;
        if ( vis[z] == 1 ) a = z, b = x, c = y;
        printf("%d ", a);
        x = Find(b, c, a);
        y = b;
        z = c;
        if ( vis[x] ==1 )
        {
            if ( sss[z] > sss[y] )
                printf("%d %d %d\n", z, y, x);
            else
                printf("%d %d %d\n", y, z, x);
            break;
        }
        vis[a]--, vis[b]--, vis[c]--;
    }
    return 0;
}

/*
5
1 2 3
2 3 4
3 4 5
*/


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <ctime>
#include <queue>
#include <stack>
#include <deque>
#include <bitset>
#include <set>
#include <map>
#define lowbit(x) x&(-x)

using namespace std;
typedef long long LL;
typedef unsigned long long uLL;
const int N = 1e5+10;
const int M = 1e5;
const int INF = 1e9+7;
const int mod = 1e9+7;

inline int read()
{
    int s=0,w=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
        if(ch=='-')w=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
    return s*w;
}

int dis[N*8];
int vis[N];
int sss[N];

void Fun(int x, int y, int z)
{
    for ( int i=0; i<8; i++ )
    {
        if ( dis[x+i*M] ) continue;
        else { dis[x+i*M] = z; break; }
    }
    for ( int i=0; i<8; i++ )
    {
        if ( dis[y+i*M] ) continue;
        else { dis[y+i*M] = z; break;}
    }

    for ( int i=0; i<8; i++ )
    {
        if ( dis[x+i*M] ) continue;
        else { dis[x+i*M] = y; break; }
    }
    for ( int i=0; i<8; i++ )
    {
        if ( dis[z+i*M] ) continue;
        else { dis[z+i*M] = y; break; }
    }

    for ( int i=0; i<8; i++ )
    {
        if ( dis[z+i*M] ) continue;
        else { dis[z+i*M] = x; break; }
    }
    for ( int i=0; i<8; i++ )
    {
        if ( dis[y+i*M] ) continue;
        else { dis[y+i*M] = x; break; }
    }
}

int Find(int x, int y, int z)
{
    for (int i=0; i<8; i++ )
        for ( int j=0; j<8; j++ )
            if ( (dis[i*M+x] == dis[j*M+y]) && dis[i*M+x] && dis[j*M+y]
                && dis[i*M+x] != z && dis[i*M+x] != y && dis[i*M+x] != x )
                return dis[i*M+x];
}

struct node
{
    int x, y, z;
} mp[N];

int main()
{
    memset( dis, 0, sizeof dis);
    memset( vis, 0, sizeof vis);
    memset( sss, 0, sizeof sss);
    memset( mp, 0, sizeof mp);
    int n, k;
    n = read();
    for ( int i=1; i<=n-2; i++ )
    {
        mp[i].x = read();
        mp[i].y = read();
        mp[i].z = read();
        if ( !vis[mp[i].x] ) k = i;
        vis[mp[i].x] ++;
        if ( !vis[mp[i].y] ) k = i;
        vis[mp[i].y] ++;
        if ( !vis[mp[i].z] ) k = i;
        vis[mp[i].z] ++;
        Fun(mp[i].x, mp[i].y, mp[i].z);
    }

    for ( int i=1; i<=n; i++ )
        sss[i] = vis[i];

    int x, y, z;
    int a, b, c;
    x = mp[k].x;
    y = mp[k].y;
    z = mp[k].z;

    for ( int i=0; i<n-2; i++ )
    {
        if ( vis[x] == 1 ) a = x, b = y, c = z;
        if ( vis[y] == 1 ) a = y, b = x, c = z;
        if ( vis[z] == 1 ) a = z, b = x, c = y;
        printf("%d ", a);
        x = Find(b, c, a);
        y = b;
        z = c;
        if ( vis[x] ==1 )
        {
            if ( sss[z] > sss[y] )
                printf("%d %d %d\n", z, y, x);
            else
                printf("%d %d %d\n", y, z, x);
            break;
        }
        vis[a]--, vis[b]--, vis[c]--;
    }
    return 0;
}

/*
5
1 2 3
2 3 4
3 4 5
*/


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <ctime>
#include <queue>
#include <stack>
#include <deque>
#include <bitset>
#include <set>
#include <map>
#define lowbit(x) x&(-x)
#define mes(x, a) memset(x, a, sizeof x)
using namespace std;
typedef long long LL;
typedef unsigned long long uLL;
const int N = 1e5+10;
const int M = 1e5;
const int INF = 1e9+7;
const int mod = 1e9+7;

inline int read()
{
    int s=0,w=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
        if(ch=='-')w=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
    return s*w;
}

int hei[N][5];
int dis[N][10];
int vis[N];
int sss[N];

void Fun(int x, int y)
{
    for (int i=0; i<7; i++ )
    {
        if ( dis[x][i]==y ) return;
        else if ( !dis[x][i] )
        {
            dis[x][i]=y;
            return;
        }
    }
}

int Find(int x, int y, int z)
{
    for ( int i=0; i<7; i++ )
        for ( int j=0; j<7; j++ )
            if ( dis[x][i]==dis[y][j] && dis[x][i] && dis[y][j] && dis[x][i]!=z )
                return dis[x][i];
    return 0;
}

int main()
{
    mes(vis, 0);
    mes(sss, 0);
    mes(dis, 0);
    int n, k, a, b, c, x, y, z;
    n = read();
    for (int i=1; i<=n-2; i++ )
    {
        a = read();
        b = read();
        c = read();
        vis[a] ++;
        vis[b] ++;
        vis[c] ++;
        Fun(a, b), Fun(a, c);
        Fun(b, a), Fun(b, c);
        Fun(c, b), Fun(c, a);
        hei[i][0] =a;
        hei[i][1] =b;
        hei[i][2] =c;
        hei[i][3] =i;
    }
    for (int i=1; i<=n; i++ ) sss[i] = vis[i];

    for ( int i=1; i<=n; i++ )
    {
        if ( vis[hei[i][0]]==1 || vis[hei[i][1]]==1 || vis[hei[i][2]]==1 )
        {
            x=hei[i][0], y=hei[i][1], z=hei[i][2];
            break;
        }
    }

    //cout << x << y << z << endl;
    k=n;
    while (k--)
    {
        if ( vis[x] == 1 ) a=x, b=y, c=z;
        if ( vis[y] == 1 ) a=y, b=x, c=z;
        if ( vis[z] == 1 ) a=z, b=y, c=x;
        printf("%d ", a);
        x = Find(b, c, a);
        if ( !x ) break;
        y = b, z = c;
        if ( vis[x]==1 )
        {
            if ( sss[y] > sss[z] ) printf("%d %d %d\n", y, z, x);
            else printf("%d %d %d\n", z, y, x);
            break;
        }
        vis[a]--, vis[b]--, vis[c]--;
    }

    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <ctime>
#include <queue>
#include <stack>
#include <deque>
#include <bitset>
#include <set>
#include <map>
#define lowbit(x) x&(-x)
#define mes(x, a) memset(x, a, sizeof x)
using namespace std;
typedef long long LL;
typedef unsigned long long uLL;
const int N = 1e5+10;
const int M = 1e5;
const int INF = 1e9+7;
const int mod = 1e9+7;

inline int read()
{
    int s=0,w=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
        if(ch=='-')w=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
    return s*w;
}

int dis[N][10];
int vis[N];
int sss[N];

void Fun(int x, int y)
{
    if ( x==y ) return;
    for (int i=0; i<7; i++ )
    {
        if ( dis[x][i]==y ) return;
        if (dis[x][i]) continue;
        else
        {
            dis[x][i]=y;
            return;
        }
    }
}

int Find(int x, int y, int z)
{
    for ( int i=0; i<7; i++ )
        for ( int j=0; j<7; j++ )
            if ( dis[x][i]==dis[y][j] )
            {
                if ( dis[x][i] && dis[y][j] && dis[x][i]!=z )
                    return dis[x][i];
            }
}

int main()
{
    mes(vis, 0);
    mes(sss, 0);
    mes(dis, 0);
    int n, k, a, b, c, x, y, z;
    n = read();
    for (int i=1; i<=n-2; i++ )
    {
        a = read();
        b = read();
        c = read();
        if ( !vis[a] || !vis[b] || !vis[c] )
            x=a, y=b, z=c;
        vis[a] ++;
        vis[b] ++;
        vis[c] ++;
        Fun(a, b);
        Fun(a, c);
        Fun(b, a);
        Fun(b, c);
        Fun(c, b);
        Fun(c, a);
    }
    for (int i=1; i<=n; i++ ) sss[i] = vis[i];

    k=n;
    while (k--)
    {
        if ( vis[x] == 1 ) a=x, b=y, c=z;
        if ( vis[y] == 1 ) a=y, b=x, c=z;
        if ( vis[z] == 1 ) a=z, b=y, c=x;
        printf("%d ", a);
        x = Find(b, c, a);
        if ( !x ) break;
        y = b, z = c;
        if ( vis[x]==1 )
        {
            if ( sss[y] > sss[z] ) printf("%d %d %d\n", y, z, x);
            else printf("%d %d %d\n", z, y, x);
            break;
        }
        vis[a]--, vis[b]--, vis[c]--;
    }

    return 0;
}