#include"stdio.h"
#include"string.h"
int main()
{
int num;
scanf("%d",&num);
int ca=1;
while(num--)
{
double a,b;
char d[3];
scanf("%lf %s",&a,d);
if
(strcmp(d,"kg")==0) {b=a*2.2046;strcpy(d,"lb");}
else if(strcmp(d,"lb")==0)
{b=a*0.4536;strcpy(d,"kg");}
else if(strcmp(d,"l")==0)
{b=a*0.2642;strcpy(d,"g");}
else if(strcmp(d,"g")==0)
{b=a*3.7854;strcpy(d,"l");}
printf("%d %.4lf
%s\n",ca,b,d);
ca++;
}
return 0;
}