Multi-level filtering and aggregation of data using lambda expressions

Kotlin Hard lambdas

Task «Multi-level filtering and aggregation of data using lambda expressions»

Write a program in Kotlin that reads a list of strings from standard input. Each string contains numbers separated by spaces. Using lambda expressions and higher-order functions (map, filter, reduce, takeWhile, dropWhile, etc.), perform the following actions: filter strings where the number of numbers is a multiple of 2, then from each such string select only positive numbers (greater than zero), then for each string calculate the product of all selected numbers raised to the power equal to the number of numbers in the original string. If after filtering there are no numbers left in the string, consider the product to be 0. Output the results in ascending order. Constraints: the number of strings does not exceed 100, each number modulo does not exceed 1000.

Input Format

The first line contains an integer N (1 ≤ N ≤ 100) — the number of lines. Then follow N lines, each containing integers separated by spaces. The number of numbers in a line does not exceed 50.

Output Format

Output N integers — the results of processing each line, sorted in ascending order, each on a new line.

Examples

Example 1

INPUT
3 User Alice 25 Address Moscow Tverskaya Product 1 Laptop 999.99
OUTPUT
Для данного ввода задача не определена, так как строки не содержат только числа.

Example 2

INPUT
1 User Bob 30
OUTPUT
Для данного ввода задача не определена, так как строка не содержит только числа.
main.kt