#include <stdio.h>
#include <math.h>
#include <stdlib.h>

typedef struct
{
    char name[200];
    int a;
    int b;
    int c;
    int sigdig;
}box;


void getInput(int *cases, box **boxes)
{
   int x;
   box *b;
   scanf ("%d\n", cases); 
   *boxes = malloc(*cases * sizeof(box));
   b = *boxes;
   for (x = 0;  x < *cases; x++)
   {
      scanf("'%[^']' %d %d %d %d ", b[x].name, &(b[x].a), &(b[x].b), &(b[x].c), &(b[x].sigdig));
      /*printf("%s\n", b[x].name);*/
   }
}

int sigdigit (int area, int sigdig)
{
    int temp;
    int digits = 0;
    int i;

    temp = area;
    while (temp > 0)
    {
        temp = temp/10;
        digits++;
    }
    digits = digits - sigdig;
    for (i = 0; i < digits; i++)
    {
        area = area/10;
    }
    for (i = 0; i < digits; i++)
    {
        area = area*10;
    }
    return area;
}

void process (int cases, box *boxes)
{
    int x;
    int area;
    box b;

    for (x = 0; x < cases; x++)
    {
        /* printf ("processing %s\n", boxes[x].name); */
        b = boxes[x];
        area = (2 * b.b * b.c) + (2 * (b.a+3) * b.b) + (b.a * b.c) + ((b.a+3)*b.c);
        area = sigdigit(area, b.sigdig);
        printf("%s requires %d square frightometers of paper to wrap\n", b.name, area);
    }
}

int main ()
{
    box *boxes;
    int cases;
    getInput(&cases, &boxes);
    process(cases, boxes);
    return 0;
}
