#include <stdio.h>
#define MAX_STUDENTS 20
#define PASS_MARK 40
int main(void)
{
    int first[MAX_STUDENTS], second[MAX_STUDENTS], third[MAX_STUDENTS];
    int n, i, total, passed;
    double average;
    if (scanf("%d", &n) != 1 || n < 1 || n > MAX_STUDENTS) {
        puts("Enter a student count from 1 to 20.");
        return 1;
    }
    for (i = 0; i < n; i++) {
        if (scanf("%d%d%d", &first[i], &second[i], &third[i]) != 3 ||
            first[i] < 0 || first[i] > 100 || second[i] < 0 || second[i] > 100 ||
            third[i] < 0 || third[i] > 100) {
            puts("Enter three marks from 0 to 100 for each student.");
            return 1;
        }
    }
    for (i = 0; i < n; i++) {
        total = first[i] + second[i] + third[i];
        average = total / 3.0;
        passed = first[i] >= PASS_MARK && second[i] >= PASS_MARK && third[i] >= PASS_MARK;
        printf("Student %d: total = %d, average = %.2f, result = %s\n",
               i + 1, total, average, passed ? "PASS" : "FAIL");
    }
    return 0;
}
