/*
TASK:sym
LANG:C++
*/
#include<iostream>
#define MN 10002
using namespace std;

struct lab
{int x,y;}t[MN];

int n,m,p;


void vhod()
{int i,j;
 cin>>n;
   for(i=1;i<=n;i++)
      cin>>t[i].x>>t[i].y;

}

void solve()
 { if(t[2].y==10)
      cout<<"2 1 3 4"<<endl;
     else if(t[2].y==0)
       cout<<"2 1 4 3"<<endl;
        else
          cout<<'0'<<endl;
 }

int main()
{ vhod();
  solve();
  return 0;
}

