#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
int n,x,b=0,s=0;
string bb,ss;
cin>>n;
int a[n];
for(int i=0;i<n;i++)
cin>>a[i]>>x;
sort(a,a+n);
for(int i=0;i<n;i++)
{
cout<<a[i]<<" ";
if(a[i]<60)
{
b=a[i];
if(b==a[n-1])
{
s=999;
}
else
s=a[i+1];
}
}
cout<<endl;
if(b==0)
{
bb="best case";
cout<<bb<<endl;
}
if(s==999)
{
ss="worst case";
cout<<ss;
}
}