import java.util.*;
import shapes.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.nextLine(); // Consume newline

        if (n < 1 || n > 100) {
            System.out.println("Invalid input");
            return;
        }

        for (int i = 0; i < n; i++) {
            String[] input = sc.nextLine().trim().split("\\s+");
            if (input.length < 2) {
                System.out.println("Invalid input");
                continue;
            }

            String type = input[0];
            Shape shape = null;

            try {
                switch (type) {
                    case "Circle":
                        double r = Double.parseDouble(input[1]);
                        if (r <= 0 || r > 10000) throw new Exception();
                        shape = new Circle(r);
                        break;
                    case "Rectangle":
                        double l = Double.parseDouble(input[1]);
                        double b = Double.parseDouble(input[2]);
                        if (l <= 0 || b <= 0 || l > 10000 || b > 10000) throw new Exception();
                        shape = new Rectangle(l, b);
                        break;
                    case "Triangle":
                        double base = Double.parseDouble(input[1]);
                        double height = Double.parseDouble(input[2]);
                        if (base <= 0 || height <= 0 || base > 10000 || height > 10000) throw new Exception();
                        shape = new Triangle(base, height);
                        break;
                    default:
                        System.out.println("Invalid input");
                        continue;
                }

                System.out.printf("Shape: %s Area: %.2f%n", type, shape.area());
            } catch (Exception e) {
                System.out.println("Invalid input");
            }
        }

        sc.close();
    }
}
