#include<iostream> using namespace std; int main(){ int n; int x,y,z,data[10]; char name[10][10]; int maxv,minv,maxi,mini; while(scanf("%d",&n)==1&&n!=-1){ maxv = -1; minv = 9999; for(int i=0;i<n;i++){ scanf("%d%d%d%s",&x,&y,&z,name[i]); data[i] = x*y*z; if(data[i]>maxv){ maxv = data[i]; maxi = i; } if(data[i]<minv){ minv = data[i]; mini = i; } } printf("%s took clay from %s.\n",name[maxi],name[mini]); } return 0; }