#include<iostream>
#include<math.h>
#include<algorithm>
using namespace std;
bool lol(pair<long long, double> a, pair<long long, double> b)
{
            return a.second<b.second;
            }
int main()
{
    double zb=0,zbi=0;
    pair<long long, double> fri[20001];
 double a,b,c;
 int n,e,f,i;
    cin>>n;
    for(i=0;i<n;i++)
    {
     cin>>fri[i].first>>fri[i].second;               
                    }
                    sort(fri,fri+n,lol);
                        for(i=0;i<n;i++) cout<<fri[i].second<<" ";
    for(i=0;i<n;i++)
    {                  
 zbi=zbi+fri[i].first;                  
}
    
 for(i=0;i<n;i++)
 {cout<<endl<<zbi*(fri[i].second)/100<<" "<<fri[i].second;
  if(zbi*(fri[i].second)/100>zb)
  zb= zbi*fri[i].second/100;
  zbi=zbi-fri[i].first;              
                 }    
    
    cout<<zb;
    cin>>a;
    
    
    
    
}

    
    
    
    
}