The only difference between problems C1 and C2 is that all values in input of problem C1 are distinct (this condition may be false for problem C2).You are given a sequence $$$a$$$ consisting of $$$n$$$ integers. All these integers are distinct, each value from $$$1$$$ to $$$n$$$ appears in the sequence exactly once.You are making a sequence of moves. During each move you must take either the leftmost element of the sequence or the rightmost element of the sequence, write it down and remove it from the sequence. Your task is to write down a strictly increasing sequence, and among all such sequences you should take the longest (the length of the sequence is the number of elements in it).For example, for the sequence $$$[2, 1, 5, 4, 3]$$$ the answer is $$$4$$$ (you take $$$2$$$ and the sequence becomes $$$[1, 5, 4, 3]$$$, then you take the rightmost element $$$3$$$ and the sequence becomes $$$[1, 5, 4]$$$, then you take $$$4$$$ and the sequence becomes $$$[1, 5]$$$ and then you take $$$5$$$ and the sequence becomes $$$[1]$$$, the obtained increasing sequence is $$$[2, 3, 4, 5]$$$).

The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le n$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$. All these integers are pairwise distinct.

In the first line of the output print $$$k$$$ — the maximum number of elements in a strictly increasing sequence you can obtain. In the second line print a string $$$s$$$ of length $$$k$$$, where the $$$j$$$-th character of this string $$$s_j$$$ should be 'L' if you take the leftmost element during the $$$j$$$-th move and 'R' otherwise. If there are multiple answers, you can print any.

NoteThe first example is described in the problem statement.

package main

import (
	"bufio"
	"fmt"
	"os"
)

// Range ...
type Range = struct {
	l   int
	r   int
	min uint32
}

var memo map[Range][]bool

func solve(a *[]uint32, l, r int, min uint32) []bool {
	if l > r {
		return nil
	}

	hash := Range{l, r, min}

	res, found := memo[hash]
	if found {
		return res
	}

	arr := *a

	res = make([]bool, 0, len(arr))

	for ok := true; ok && l <= r; {
		ok = true
		if arr[l] > min && (arr[l] < arr[r] || arr[r] <= min) {
			res = append(res, false) //+ solve(a, 1+l, r, arr[l])
			min = arr[l]
			l++
			continue
		}

		if arr[r] > min {
			res = append(res, true) // + solve(a, l, r-1, arr[r])
			min = arr[r]
			r--
			continue
		}
		ok = false
	}

	//	memo[hash] = res
	return res
}

func toInt(buf []byte) uint32 {
	n := uint32(0)
	for _, v := range buf {
		n = n*10 + uint32(v-'0')
	}

	return n
}

func main() {
	memo = map[Range][]bool{}
	var n int

	fmt.Scan(&n)

	a := make([]uint32, n)
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for i := range a {
		scanner.Scan()
		a[i] = toInt(scanner.Bytes())
	}

	ans := solve(&a, 0, len(a)-1, 0)

	fmt.Println(len(ans))
	for _, b := range ans {
		if b {
			fmt.Print("R")
		} else {
			fmt.Print("L")
		}
	}
	fmt.Println()
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

// Range ...
type Range = struct {
	l   int
	r   int
	min uint32
}

var memo map[Range]string

func solve(a *[]uint32, l, r int, min uint32) string {
	if l > r {
		return ""
	}

	hash := Range{l, r, min}

	res, found := memo[hash]
	if found {
		return res
	}

	res = ""
	arr := *a
	for l <= r && (arr[l] > min || arr[r] > min) && arr[l] != arr[r] {
		if arr[l] > min && arr[l] < arr[r] {
			res += "L" //+ solve(a, 1+l, r, arr[l])
			l++
		} else {
			if arr[r] > min {
				res += "R" // + solve(a, l, r-1, arr[r])
				r--
			}
		}
	}
	memo[hash] = res
	return res
}

func toInt(buf []byte) uint32 {
	n := uint32(0)
	for _, v := range buf {
		n = n*10 + uint32(v-'0')
	}

	return n
}

func main() {
	memo = map[Range]string{}
	var n int

	fmt.Scan(&n)

	a := make([]uint32, n)
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for i := range a {
		scanner.Scan()
		a[i] = toInt(scanner.Bytes())
	}

	ans := solve(&a, 0, len(a)-1, 0)

	fmt.Println(len(ans))
	fmt.Println(ans)
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

// Range ...
type Range = struct {
	l   int
	r   int
	min uint32
}

var memo map[Range][]bool

func solve(a *[]uint32, l, r int, min uint32) []bool {
	if l > r {
		return nil
	}

	hash := Range{l, r, min}

	res, found := memo[hash]
	if found {
		return res
	}

	arr := *a

	res = make([]bool, 0, len(arr))

	for l <= r {
		if arr[l] > min && arr[l] < arr[r] {
			res = append(res, false) //+ solve(a, 1+l, r, arr[l])
			min = arr[l]
			l++
			continue
		}

		if arr[r] > min {
			res = append(res, true) // + solve(a, l, r-1, arr[r])
			min = arr[r]
			r--
			continue
		}

		break
	}

	//	memo[hash] = res
	return res
}

func toInt(buf []byte) uint32 {
	n := uint32(0)
	for _, v := range buf {
		n = n*10 + uint32(v-'0')
	}

	return n
}

func main() {
	memo = map[Range][]bool{}
	var n int

	fmt.Scan(&n)

	a := make([]uint32, n)
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for i := range a {
		scanner.Scan()
		a[i] = toInt(scanner.Bytes())
	}

	ans := solve(&a, 0, len(a)-1, 0)

	fmt.Println(len(ans))
	for _, b := range ans {
		if b {
			fmt.Print("R")
		} else {
			fmt.Print("L")
		}
	}
	fmt.Println()
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

// Range ...
type Range = struct {
	l   int
	r   int
	min uint32
}

var memo map[Range]string

func solve(a *[]uint32, l, r int, min uint32) string {
	if l > r {
		return ""
	}

	hash := Range{l, r, min}

	res, found := memo[hash]
	if found {
		return res
	}

	res = ""
	arr := *a
	for l <= r && (arr[l] > min || arr[r] > min) && arr[l] != arr[r] {
		if arr[l] > min && arr[l] < arr[r] {
			res += "L" //+ solve(a, 1+l, r, arr[l])
			min = arr[l]
			l++
		} else {
			if arr[r] > min {
				res += "R" // + solve(a, l, r-1, arr[r])
				min = arr[r]
				r--
			}
		}
	}

	memo[hash] = res
	return res
}

func toInt(buf []byte) uint32 {
	n := uint32(0)
	for _, v := range buf {
		n = n*10 + uint32(v-'0')
	}

	return n
}

func main() {
	memo = map[Range]string{}
	var n int

	fmt.Scan(&n)

	a := make([]uint32, n)
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for i := range a {
		scanner.Scan()
		a[i] = toInt(scanner.Bytes())
	}

	ans := solve(&a, 0, len(a)-1, 0)

	fmt.Println(len(ans))
	fmt.Println(ans)
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

// Range ...
type Range = struct {
	l   int
	r   int
	min uint32
}

var memo map[Range][]bool

func solve(a *[]uint32, l, r int, min uint32) []bool {
	if l > r {
		return nil
	}

	hash := Range{l, r, min}

	res, found := memo[hash]
	if found {
		return res
	}

	arr := *a

	res = make([]bool, 0, len(arr))

	for ok := true; ok && l <= r; {
		ok = true
		if arr[l] > min && arr[l] < arr[r] {
			res = append(res, false) //+ solve(a, 1+l, r, arr[l])
			min = arr[l]
			l++
			continue
		}

		if arr[r] > min {
			res = append(res, true) // + solve(a, l, r-1, arr[r])
			min = arr[r]
			r--
			continue
		}
		ok = false
	}

	//	memo[hash] = res
	return res
}

func toInt(buf []byte) uint32 {
	n := uint32(0)
	for _, v := range buf {
		n = n*10 + uint32(v-'0')
	}

	return n
}

func main() {
	memo = map[Range][]bool{}
	var n int

	fmt.Scan(&n)

	a := make([]uint32, n)
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for i := range a {
		scanner.Scan()
		a[i] = toInt(scanner.Bytes())
	}

	ans := solve(&a, 0, len(a)-1, 0)

	fmt.Println(len(ans))
	for _, b := range ans {
		if b {
			fmt.Print("R")
		} else {
			fmt.Print("L")
		}
	}
	fmt.Println()
}


You are given an array of integers $$$a_1,a_2,\ldots,a_n$$$. Find the maximum possible value of $$$a_ia_ja_ka_la_t$$$ among all five indices $$$(i, j, k, l, t)$$$ ($$$i<j<k<l<t$$$).

The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1\le t\le 2 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$5\le n\le 10^5$$$) — the size of the array. The second line of each test case contains $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ ($$$-3\times 10^3\le a_i\le 3\times 10^3$$$) — given array. It's guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2\cdot 10^5$$$.

For each test case, print one integer — the answer to the problem.

NoteIn the first test case, choosing $$$a_1,a_2,a_3,a_4,a_5$$$ is a best choice: $$$(-1)\cdot (-2) \cdot (-3)\cdot (-4)\cdot (-5)=-120$$$.In the second test case, choosing $$$a_1,a_2,a_3,a_5,a_6$$$ is a best choice: $$$(-1)\cdot (-2) \cdot (-3)\cdot 2\cdot (-1)=12$$$.In the third test case, choosing $$$a_1,a_2,a_3,a_4,a_5$$$ is a best choice: $$$(-1)\cdot 0\cdot 0\cdot 0\cdot (-1)=0$$$.In the fourth test case, choosing $$$a_1,a_2,a_3,a_4,a_6$$$ is a best choice: $$$(-9)\cdot (-7) \cdot (-5)\cdot (-3)\cdot 1=945$$$.

package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
)

func main() {
	io := NewFastIO(os.Stdin, os.Stdout)
	defer io.Flush()

	for t := io.NextInt(); t > 0; t-- {
		n := io.NextInt()
		a := io.NextInts(n)

		mx, mn := make([]int64, n+1), make([]int64, n+1)
		for i := range mx {
			mx[i], mn[i] = 1, 1
		}
		for i := 0; i < 5; i++ {
			nmx, nmn := make([]int64, n+1), make([]int64, n+1)
			nmx[i], nmn[i] = math.MinInt64, math.MaxInt64
			for j := i + 1; j <= n; j++ {
				x := int64(a[j-1])
				a, b := x*mx[j-1], x*mn[j-1]
				nmx[j], nmn[j] = max(nmx[j-1], max(a, b)), min(nmn[j-1], min(a, b))
			}
			mx, mn = nmx, nmn
		}
		io.Println(mx[n])
	}
}

func min(i, j int64) int64 {
	if i < j {
		return i
	}
	return j
}

func max(i, j int64) int64 {
	if i > j {
		return i
	}
	return j
}

type FastIO struct {
	*bufio.Writer
	r    io.Reader
	buf  [8192]byte
	i, n int
}

func NewFastIO(r io.Reader, w io.Writer) *FastIO {
	return &FastIO{r: r, Writer: bufio.NewWriter(w)}
}

func (f *FastIO) readC() byte {
	if f.i == f.n {
		f.n, _ = f.r.Read(f.buf[:])
		if f.n == 0 {
			panic("EOF")
		}
		f.i = 0
	}
	f.i++
	return f.buf[f.i-1]
}

func (f *FastIO) NextInt() int {
	c := f.readC()
	for ; c <= ' '; c = f.readC() {
	}
	neg := false
	if c == '-' {
		neg = true
		c = f.readC()
	}
	n := 0
	for ; '0' <= c && c <= '9'; c = f.readC() {
		n = n*10 + int(c) - '0'
	}
	if neg {
		return -n
	}
	return n
}

func (f *FastIO) NextInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = f.NextInt()
	}
	return a
}

func (f *FastIO) Println(a ...interface{}) {
	fmt.Fprintln(f, a...)
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }

func ifPositiveLessThenTwo(arr []int) int64 {
	return int64(arr[0] * arr[1] * arr[2] * arr[3] * arr[len(arr)-1])
}

func maxMultiplication(arr []int) int64 {
	N := len(arr)
	sort.Slice(arr, func(i, j int) bool {
		return arr[i] < arr[j]
	})

	cases := [][]int{
		{0, 1, 2, 3, N-1},
		{0, 1, N-1, N-2, N-3},
		{N - 5,  N - 4, N-3, N-2, N-1},
	}

	maxMul := int64(math.MinInt64)
	for _, c := range cases {
		mul := int64(1)
		for _, el := range c {
			mul *= int64(arr[el])
		}

		if maxMul < mul {
			maxMul = mul
		}
	}

	return maxMul
}

func main() {
	defer writer.Flush()
	var N int
	scanf("%d\n", &N)

	var M int
	for i := 0; i < N; i++ {
		scanf("%d\n", &M)
		arr := make([]int, M)
		for j := 0; j < M; j++ {
			scanf("%d", &arr[j])
		}
		scanf("\n")

		printf("%d\n", maxMultiplication(arr))
	}
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }

func main() {
	defer writer.Flush()

	var t int
	scanf("%d\n", &t)
	for t > 0 {

		var n int
		scanf("%d\n", &n)
		var arr []int
		arr = make([]int, n)
		mx := math.MinInt16
		for i := 0; i < n; i++ {
			scanf("%d", &arr[i])
			if mx < arr[i] {
				mx = arr[i]
			}
		}
		scanf("\n")
		sort.SliceStable(arr, func(i, j int) bool {
			return math.Abs(float64(arr[i])) > math.Abs(float64(arr[j]))
		})
		// printf("%d\n", arr)
		var ans int64

		if mx < 0 {
			ans = int64(arr[n-1]) * int64(arr[n-2]) * int64(arr[n-3]) * int64(arr[n-4]) * int64(arr[n-5])
			printf("%v\n", ans)
		} else {
			ans = int64(arr[0]) * int64(arr[1]) * int64(arr[2]) * int64(arr[3]) * int64(arr[4])
			for i := 5; i < n; i++ {
				for j := 0; j < 5; j++ {
					var temp int64
					temp = int64(arr[i])
					for k := 0; k < 5; k++ {
						if k != j {
							temp *= int64(arr[k])
						}
					}
					if ans < temp {
						ans = temp
					}
				}
			}
			printf("%v\n", ans)
		}
		t--
	}
}

/*
URL:
https://codeforces.com/contest/1406/problem/B
*/

package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"sort"
	"strconv"
)

var (
	t int

	n int
	A []int64
)

func main() {
	defer stdout.Flush()

	t = readi()
	for tc := 0; tc < t; tc++ {
		n = readi()
		A = readlls(n)

		solve()
	}
}

func solve() {
	P, N := []int64{}, []int64{}
	O := []int64{}

	pos, neg, zero := 0, 0, 0
	for _, a := range A {
		if a > 0 {
			P = append(P, a)
			O = append(O, a)
			pos++
		} else if a < 0 {
			N = append(N, -a)
			O = append(O, -a)
			neg++
		} else {
			zero++
			O = append(O, a)
		}
	}

	sort.Slice(P, func(i, j int) bool {
		return P[i] > P[j]
	})
	sort.Slice(N, func(i, j int) bool {
		return N[i] > N[j]
	})
	// Oは絶対値の小さい順
	sort.Slice(O, func(i, j int) bool {
		return O[i] < O[j]
	})

	var ans int64
	ans = -INF_B60

	if zero > 0 {
		ans = 0
	}

	if pos >= 5 {
		tmp := int64(1)
		for i := 0; i < 5; i++ {
			tmp *= P[i]
		}
		ChMax(&ans, tmp)
	}

	if neg >= 2 && pos >= 3 {
		tmp := int64(1)
		for i := 0; i < 2; i++ {
			tmp *= N[i]
		}
		for i := 0; i < 3; i++ {
			tmp *= P[i]
		}
		ChMax(&ans, tmp)
	}

	if neg >= 4 && pos >= 1 {
		tmp := int64(1)
		for i := 0; i < 4; i++ {
			tmp *= N[i]
		}
		for i := 0; i < 1; i++ {
			tmp *= P[i]
		}
		ChMax(&ans, tmp)
	}

	// 負のパターン
	tmp := int64(1)
	for i := 0; i < 5; i++ {
		tmp *= O[i]
	}
	ChMax(&ans, -tmp)

	fmt.Println(ans)
}

// ChMax accepts a pointer of integer and a target value.
// If target value is LARGER than the first argument,
//	then the first argument will be updated by the second argument.
func ChMax(updatedValue *int64, target int64) bool {
	if *updatedValue < target {
		*updatedValue = target
		return true
	}
	return false
}

/*******************************************************************/

/********** common constants **********/

const (
	MOD = 1000000000 + 7
	// MOD          = 998244353
	ALPH_N  = 26
	INF_I64 = math.MaxInt64
	INF_B60 = 1 << 60
	INF_I32 = math.MaxInt32
	INF_B30 = 1 << 30
	NIL     = -1
)

// modi can calculate a right residual whether value is positive or negative.
func modi(val, m int) int {
	res := val % m
	if res < 0 {
		res += m
	}
	return res
}

// modll can calculate a right residual whether value is positive or negative.
func modll(val, m int64) int64 {
	res := val % m
	if res < 0 {
		res += m
	}
	return res
}

/********** bufio setting **********/

func init() {
	// bufio.ScanWords <---> bufio.ScanLines
	reads = newReadString(os.Stdin, bufio.ScanWords)
	stdout = bufio.NewWriter(os.Stdout)
}

/********** FAU standard libraries **********/

//fmt.Sprintf("%b\n", 255) 	// binary expression

/********** I/O usage **********/

//str := reads()
//i := readi()
//X := readis(n)
//S := readrs()
//a := readf()
//A := readfs(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

/*********** Input ***********/

var (
	// reads returns a WORD string.
	reads  func() string
	stdout *bufio.Writer
)

func newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	r.Split(sf)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// readi returns an integer.
func readi() int {
	return int(_readInt64())
}
func readi2() (int, int) {
	return int(_readInt64()), int(_readInt64())
}
func readi3() (int, int, int) {
	return int(_readInt64()), int(_readInt64()), int(_readInt64())
}
func readi4() (int, int, int, int) {
	return int(_readInt64()), int(_readInt64()), int(_readInt64()), int(_readInt64())
}

// readll returns as integer as int64.
func readll() int64 {
	return _readInt64()
}
func readll2() (int64, int64) {
	return _readInt64(), _readInt64()
}
func readll3() (int64, int64, int64) {
	return _readInt64(), _readInt64(), _readInt64()
}
func readll4() (int64, int64, int64, int64) {
	return _readInt64(), _readInt64(), _readInt64(), _readInt64()
}

func _readInt64() int64 {
	i, err := strconv.ParseInt(reads(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// readis returns an integer slice that has n integers.
func readis(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readi()
	}
	return b
}

// readlls returns as int64 slice that has n integers.
func readlls(n int) []int64 {
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		b[i] = readll()
	}
	return b
}

// readf returns an float64.
func readf() float64 {
	return float64(_readFloat64())
}

func _readFloat64() float64 {
	f, err := strconv.ParseFloat(reads(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// ReadFloatSlice returns an float64 slice that has n float64.
func readfs(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = readf()
	}
	return b
}

// readrs returns a rune slice.
func readrs() []rune {
	return []rune(reads())
}

/*********** Output ***********/

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintIntsLine returns integers string delimited by a space.
func PrintInts64Line(A ...int64) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.FormatInt(A[i], 10) // 64bit int version
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// Printf is function for output strings to buffered os.Stdout.
// You may have to call stdout.Flush() finally.
func printf(format string, a ...interface{}) {
	fmt.Fprintf(stdout, format, a...)
}

/*********** Debugging ***********/

// debugf is wrapper of fmt.Fprintf(os.Stderr, format, a...)
func debugf(format string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, format, a...)
}

// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.
// For debugging use.
func ZeroPaddingRuneSlice(n, digitsNum int) []rune {
	sn := fmt.Sprintf("%b", n)

	residualLength := digitsNum - len(sn)
	if residualLength <= 0 {
		return []rune(sn)
	}

	zeros := make([]rune, residualLength)
	for i := 0; i < len(zeros); i++ {
		zeros[i] = '0'
	}

	res := []rune{}
	res = append(res, zeros...)
	res = append(res, []rune(sn)...)

	return res
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
)

func abs(a int64) int64 {
	if a > 0 {
		return a
	}
	return -a
}

func main() {
	io := newFastIO(os.Stdin, os.Stdout)
	defer io.Flush()

	t := io.nextInt()
	for i := 0; i < t; i++ {
		n := io.nextInt()
		var a []int64
		for j := 0; j < n; j++ {
			g := int64(io.nextInt())
			a = append(a, g)
		}
		sort.Slice(a, func(i, j int) bool { return a[i] < a[j] })
		best := a[n-1] * a[n-2] * a[n-3] * a[n-4] * a[n-5]
		cur := a[0] * a[1] * a[n-1] * a[n-2] * a[n-3]
		if cur > best {
			best = cur
		}
		cur = a[0] * a[1] * a[2] * a[3] * a[n-1]
		if cur > best {
			best = cur
		}
		sort.Slice(a, func(i, j int) bool { return abs(a[i]) < abs(a[j]) })
		cur = a[0] * a[1] * a[2] * a[3] * a[4]
		if cur > best {
			best = cur
		}
		fmt.Printf("%d\n", best)
	}
}

type fastIO struct {
	*bufio.Reader
	*bufio.Writer
	p [1]byte
}

func newFastIO(r io.Reader, w io.Writer) *fastIO {
	return &fastIO{Reader: bufio.NewReader(r), Writer: bufio.NewWriter(w)}
}

func (f *fastIO) nextInt() int {
	f.Read(f.p[:])
	for f.p[0] <= ' ' {
		f.Read(f.p[:])
	}
	neg := false
	if f.p[0] == '-' {
		neg = true
		f.Read(f.p[:])
	}
	n := 0
	for '0' <= f.p[0] && f.p[0] <= '9' {
		n = n*10 + int(f.p[0]) - '0'
		f.Read(f.p[:])
	}
	if neg {
		return -n
	}
	return n
}

func (f *fastIO) nextInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = f.nextInt()
	}
	return a
}

func (f *fastIO) next() string {
	f.Read(f.p[:])
	for f.p[0] <= ' ' {
		f.Read(f.p[:])
	}
	var s []byte
	for f.p[0] > ' ' {
		s = append(s, f.p[0])
		f.Read(f.p[:])
	}
	return string(s)
}

func (f *fastIO) println(a ...interface{}) {
	fmt.Fprintln(f.Writer, a...)
}

func (f *fastIO) print(a ...interface{}) {
	fmt.Fprint(f.Writer, a...)
}

func (f *fastIO) printInts(a ...int) {
	if len(a) > 0 {
		f.print(a[0])
		for _, x := range a[1:] {
			f.print(" ", x)
		}
	}
}

func (f *fastIO) printlnInts(a ...int) {
	f.printInts(a...)
	f.println()
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
)

var rw = NewFastIO(os.Stdin, os.Stdout)

func main() {
	defer rw.Flush()
	tt := rw.NextInt()
	for i := 0; i < tt; i++ {
		solveCase()
	}
}

func solveCase() {
	n := rw.NextInt()
	a := rw.NextInt64s(n)
	sort.Slice(a[:], func(i, j int) bool { return a[i] < a[j] })
	var ans int64
	for i := 0; i <= 5; i++ {
		cur := int64(1)
		for j := 0; j < i; j++ {
			cur *= a[j]
		}
		for j := 0; j < 5-i; j++ {
			cur *= a[n-1-j]
		}
		if i == 0 || cur > ans {
			ans = cur
		}
	}
	rw.Println(ans)
}

// @meooow template uwu
type FastIO struct {
	*bufio.Writer
	r    io.Reader
	buf  [8192]byte
	i, n int
}

func NewFastIO(r io.Reader, w io.Writer) *FastIO {
	return &FastIO{r: r, Writer: bufio.NewWriter(w)}
}

func (f *FastIO) readC() byte {
	if f.i == f.n {
		f.n, _ = f.r.Read(f.buf[:])
		if f.n == 0 {
			panic("EOF")
		}
		f.i = 0
	}
	f.i++
	return f.buf[f.i-1]
}

func (f *FastIO) Next() string {
	c := f.readC()
	for ; c <= ' '; c = f.readC() {
	}
	var s []byte
	for ; c > ' '; c = f.readC() {
		s = append(s, c)
	}
	return string(s)
}

func (f *FastIO) NextInt() int {
	c := f.readC()
	for ; c <= ' '; c = f.readC() {
	}
	neg := false
	if c == '-' {
		neg = true
		c = f.readC()
	}
	n := 0
	for ; '0' <= c && c <= '9'; c = f.readC() {
		n = n*10 + int(c) - '0'
	}
	if neg {
		return -n
	}
	return n
}
func (f *FastIO) NextInt64() int64 {
	c := f.readC()
	for ; c <= ' '; c = f.readC() {
	}
	neg := false
	if c == '-' {
		neg = true
		c = f.readC()
	}
	n := int64(0)
	for ; '0' <= c && c <= '9'; c = f.readC() {
		n = n*10 + int64(c) - '0'
	}
	if neg {
		return -n
	}
	return n
}

func (f *FastIO) NextInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = f.NextInt()
	}
	return a
}
func (f *FastIO) NextInt64s(n int) []int64 {
	a := make([]int64, n)
	for i := 0; i < n; i++ {
		a[i] = f.NextInt64()
	}
	return a
}

func (f *FastIO) Println(a ...interface{}) {
	fmt.Fprintln(f, a...)
}

func (f *FastIO) Print(a ...interface{}) {
	fmt.Fprint(f, a...)
}
func (f *FastIO) PrintInts(a ...int) {
	if len(a) > 0 {
		f.Print(a[0])
		for _, x := range a[1:] {
			f.Print(" ", x)
		}
	}
}
func (f *FastIO) PrintlnInts(a ...int) {
	f.PrintInts(a...)
	f.Println()
}
func (f *FastIO) PrintInt64s(a ...int64) {
	if len(a) > 0 {
		f.Print(a[0])
		for _, x := range a[1:] {
			f.Print(" ", x)
		}
	}
}
func (f *FastIO) PrintlnInt64s(a ...int64) {
	f.PrintInt64s(a...)
	f.Println()
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"math"
	"os"
	"sort"
)

/*
5
5
-1 -2 -3 -4 -5
6
-1 -2 -3 1 2 -1
6
-1 0 0 0 -1 -1
6
-9 -7 -5 -3 -2 1
10
1 1 -4 -5 -3 -1 4 5 -3 -1

*/

func MaxProduct(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var T, N, S int64
	for Fscan(in, &T); T > 0; T-- {
		var positive, negative []int64
		Fscan(in, &N)

		zeroFlag := false

		for tmp := N; tmp > 0; tmp-- {
			Fscan(in, &S)
			if S > 0 {
				positive = append(positive, S)
			} else if S < 0 {
				negative = append(negative, S)
			} else {
				zeroFlag = true
			}
		}

		if (len(negative)+len(positive) < 5) || (len(positive) == 0 && zeroFlag) {
			Fprintln(out, 0)
			continue
		}

		var sum int64 = math.MinInt64
		sort.Slice(positive, func(i, j int) bool {
			return positive[i] < positive[j]
		})
		sort.Slice(negative, func(i, j int) bool {
			return negative[i] < negative[j]
		})

		for pnums := 0; pnums <= 5; pnums++ {
			if len(negative) < 5-pnums || len(positive) < pnums {
				continue
			}

			if (5-pnums)%2 != 0 {
				var tmpSum int64 = 1
				for i := 0; i < pnums; i++ {
					tmpSum = tmpSum * positive[i]
				}

				for j := len(negative) - 1; j > len(negative)-6+pnums; j-- {
					tmpSum = tmpSum * negative[j]
				}

				sum = MPMax(sum, tmpSum)
			} else {
				var tmpSum int64 = 1
				for i := 0; i < pnums; i++ {
					tmpSum = tmpSum * positive[len(positive)-i-1]
				}

				for j := 0; j < 5-pnums; j++ {
					tmpSum = tmpSum * negative[j]
				}

				sum = MPMax(sum, tmpSum)
			}

		}

		if zeroFlag {
			sum = MPMax(sum, 0)
		}

		Fprintln(out, sum)
	}
}

func MPMax(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func main() {
	MaxProduct(os.Stdin, os.Stdout)
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

type Int64 []int64

func (a Int64) Less(i, j int) bool {
	return a[i] < a[j]
}

func (a Int64) Len() int {
	return len(a)
}

func (a Int64) Swap(i, j int) {
	a[i], a[j] = a[j], a[i]
}

func maxProduct(a []int64, n int) int64 {
	sort.Sort(Int64(a))
	var ans, tempAns int64
	ans = a[n-1] * a[n-2] * a[n-3] * a[n-4] * a[n-5]
	tempAns = a[0] * a[1] * a[2] * a[3] * a[n-1]
	if tempAns > ans {
		ans = tempAns
	}
	tempAns = a[0] * a[1] * a[n-1] * a[n-2] * a[n-3]
	if tempAns > ans {
		ans = tempAns
	}
	return ans
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	var t, n int
	var ans int64
	fmt.Fscanln(reader, &t)
	for i := 0; i < t; i++ {
		fmt.Fscanln(reader, &n)
		a := make([]int64, n)
		for j := 0; j < n-1; j++ {
			fmt.Fscanf(reader, "%d ", &a[j])
		}
		fmt.Fscanf(reader, "%d\n", &a[n-1])
		ans = maxProduct(a, n)
		fmt.Fprintln(writer, ans)
	}
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
)

const (
	SCANNER_BUF_SIZE = 2 << 20

	INF = int64(math.MaxInt64)
	MOD = 1e9 + 7
)

var (
	writer  *bufio.Writer
	scanner *bufio.Scanner
)

func init() {
	writer = bufio.NewWriter(os.Stdout)
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, SCANNER_BUF_SIZE), SCANNER_BUF_SIZE)
}

func printf(f string, a ...interface{}) {
	fmt.Fprintf(writer, f, a...)
}

func sint64() int64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := int64(0)
	if bb[0] == '-' {
		for _, b := range bb[1:] {
			i *= 10
			i -= int64(b - '0')
		}
		return i
	}
	for _, b := range bb {
		i *= 10
		i += int64(b - '0')
	}
	return i
}

func suint64() uint64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := uint64(0)
	for _, b := range bb {
		i *= 10
		i += uint64(b - '0')
	}
	return i
}

func sstring() string {
	scanner.Scan()
	return scanner.Text()
}

func gcd(a, b int64) int64 {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

func lcm(a, b int64) int64 {
	return a * b / gcd(a, b)
}

func abs(a int64) int64 {
	if a < 0 {
		return a * -1
	}
	return a
}

func min(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r < a {
			a = r
		}
	}
	return a
}

func max(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r > a {
			a = r
		}
	}
	return a
}

func main() {
	defer writer.Flush()
	t := sint64()
	for ; t > 0; t-- {
		n := sint64()
		a := make([]int64, n)
		for i := range a {
			a[i] = sint64()
		}
		printf("%d\n", sol(a))
	}
}

func prod(a []int64) int64 {
	ret := int64(1)
	for _, ai := range a {
		ret *= ai
	}
	return ret
}

func sol(a []int64) int64 {
	sort.Slice(a, func(il, ir int) bool {
		return a[il] < a[ir]
	})
	return max(
		prod([]int64{a[len(a)-5], a[len(a)-4], a[len(a)-3], a[len(a)-2], a[len(a)-1]}),
		prod([]int64{a[0], a[len(a)-4], a[len(a)-3], a[len(a)-2], a[len(a)-1]}),
		prod([]int64{a[0], a[1], a[len(a)-3], a[len(a)-2], a[len(a)-1]}),
		prod([]int64{a[0], a[1], a[2], a[len(a)-2], a[len(a)-1]}),
		prod([]int64{a[0], a[1], a[2], a[3], a[len(a)-1]}),
		prod([]int64{a[0], a[1], a[2], a[3], a[4]}),
	)
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }

func ifPositiveLessThenTwo(arr []int) int64 {
	return int64(arr[0] * arr[1] * arr[2] * arr[3] * arr[len(arr)-1])
}

func maxMultiplication(arr []int) int64 {
	N := len(arr)
	sort.Slice(arr, func(i, j int) bool {
		return arr[i] < arr[j]
	})

	if arr[N-3] <= 0 {
		return ifPositiveLessThenTwo(arr)
	}

	mul := int64(1)
	left := 0
	right := len(arr) - 1

	if arr[left]*arr[left+1] >= arr[right]*arr[right-1] {
		mul *= int64(arr[left] * arr[left+1])
		left += 2
	} else {
		mul *= int64(arr[right] * arr[right-1])
		right -= 2
	}

	if arr[left]*arr[left+1] >= arr[right]*arr[right-1] {
		mul *= int64(arr[left] * arr[left+1])
		left += 2
	} else {
		mul *= int64(arr[right] * arr[right-1])
		right -= 2
	}

	if arr[left] > arr[right] {
		mul *= int64(arr[left])
	} else {
		mul *= int64(arr[right])
	}

	return mul
}

func main() {
	defer writer.Flush()
	var N int
	scanf("%d\n", &N)

	var M int
	for i := 0; i < N; i++ {
		scanf("%d\n", &M)
		arr := make([]int, M)
		for j := 0; j < M; j++ {
			scanf("%d", &arr[j])
		}
		scanf("\n")

		printf("%d", maxMultiplication(arr))
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }

func ifPositiveLessThenTwo(arr []int) int64 {
	return int64(arr[0] * arr[1] * arr[2] * arr[3] * arr[len(arr)-1])
}

func maxMultiplication(arr []int) int64 {
	N := len(arr)
	sort.Slice(arr, func(i, j int) bool {
		return arr[i] < arr[j]
	})

	if arr[N-3] <= 0 {
		return ifPositiveLessThenTwo(arr)
	}

	mul := int64(1)
	left := 0
	right := len(arr) - 1

	if arr[left]*arr[left+1] >= arr[right]*arr[right-1] {
		mul *= int64(arr[left] * arr[left+1])
		left += 2
	} else {
		mul *= int64(arr[right] * arr[right-1])
		right -= 2
	}

	if arr[left]*arr[left+1] >= arr[right]*arr[right-1] {
		mul *= int64(arr[left] * arr[left+1])
		left += 2
	} else {
		mul *= int64(arr[right] * arr[right-1])
		right -= 2
	}

	if arr[left] > arr[right] {
		mul *= int64(arr[left])
	} else {
		mul *= int64(arr[right])
	}

	return mul
}

func main() {
	defer writer.Flush()
	var N int
	scanf("%d\n", &N)

	var M int
	for i := 0; i < N; i++ {
		scanf("%d\n", &M)
		arr := make([]int, M)
		for j := 0; j < M; j++ {
			scanf("%d", &arr[j])
		}
		scanf("\n")

		printf("%d\n", maxMultiplication(arr))
	}
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }

func main() {
	defer writer.Flush()

	var t int
	scanf("%d\n", &t)
	for t > 0 {

		var n int
		scanf("%d\n", &n)
		var arr []int
		arr = make([]int, n)
		mx := math.MinInt16
		for i := 0; i < n; i++ {
			scanf("%d", &arr[i])
			if mx < arr[i] {
				mx = arr[i]
			}
		}
		scanf("\n")
		sort.SliceStable(arr, func(i, j int) bool {
			return math.Abs(float64(arr[i])) > math.Abs(float64(arr[j]))
		})
		// printf("%d\n", arr)
		if mx < 0 {
			printf("%d\n", arr[n-1]*arr[n-2]*arr[n-3]*arr[n-4]*arr[n-5])
		} else {
			ans := 0
			for i := 5; i < n; i++ {
				for j := 0; j < 5; j++ {
					temp := arr[i]
					for k := 0; k < 5; k++ {
						if k != j {
							temp = temp * arr[k]
						}
					}
					if ans < temp {
						ans = temp
					}
				}
			}
			printf("%d\n", ans)
		}
		t--
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }

func main() {
	defer writer.Flush()

	var t int
	scanf("%d\n", &t)
	for t > 0 {

		var n int
		scanf("%d\n", &n)
		var arr []int
		arr = make([]int, n)
		for i := 0; i < n; i++ {
			scanf("%d", &arr[i])
		}
		scanf("\n")

		var m int
		m = 1
		for i := 0; i < 5; i++ {
			m = m * arr[i]
		}

		ans := m
		for i := 5; i < n; i++ {
			m := m * arr[i]
			for j := i - 5; j < i; j++ {
				if arr[j] != 0 && ans < m/arr[j] {
					ans = m / arr[j]
				}
			}
			if arr[i-5] != 0 {
				m = m / arr[i-5]
			}
		}
		printf("%d\n", ans)
		t--
	}
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }

func main() {
	defer writer.Flush()

	var t int
	scanf("%d\n", &t)
	for t > 0 {

		var n int
		scanf("%d\n", &n)
		var arr []int
		arr = make([]int, n)
		mx := math.MinInt16
		for i := 0; i < n; i++ {
			scanf("%d", &arr[i])
			if mx < arr[i] {
				mx = arr[i]
			}
		}
		scanf("\n")
		sort.SliceStable(arr, func(i, j int) bool {
			return math.Abs(float64(arr[i])) > math.Abs(float64(arr[j]))
		})
		// printf("%d\n", arr)
		var ans int64

		if mx < 0 {
			ans = int64(arr[n-1] * arr[n-2] * arr[n-3] * arr[n-4] * arr[n-5])
			printf("%d\n", ans)
		} else {
			ans = int64(arr[0] * arr[1] * arr[2] * arr[3] * arr[4])
			for i := 5; i < n; i++ {
				for j := 0; j < 5; j++ {
					var temp int64
					temp = int64(arr[i])
					for k := 0; k < 5; k++ {
						if k != j {
							temp *= int64(arr[k])
						}
					}
					if ans < temp {
						ans = temp
					}
				}
			}
			printf("%d\n", ans)
		}
		t--
	}
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }

func main() {
	defer writer.Flush()

	var t int
	scanf("%d\n", &t)
	for t > 0 {

		var n int
		scanf("%d\n", &n)
		var arr []int
		arr = make([]int, n)
		mx := math.MinInt16
		for i := 0; i < n; i++ {
			scanf("%d", &arr[i])
			if mx < arr[i] {
				mx = arr[i]
			}
		}
		scanf("\n")
		sort.SliceStable(arr, func(i, j int) bool {
			return math.Abs(float64(arr[i])) > math.Abs(float64(arr[j]))
		})
		// printf("%d\n", arr)
		var ans int64

		if mx < 0 {
			printf("%d\n", int64(arr[n-1]*arr[n-2]*arr[n-3]*arr[n-4]*arr[n-5]))
		} else {
			ans = int64(arr[0] * arr[1] * arr[2] * arr[3] * arr[4])
			for i := 5; i < n; i++ {
				for j := 0; j < 5; j++ {
					var temp int64
					temp = int64(arr[i])
					for k := 0; k < 5; k++ {
						if k != j {
							temp *= int64(arr[k])
						}
					}
					if ans < temp {
						ans = temp
					}
				}
			}
			printf("%d\n", ans)
		}
		t--
	}
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }

func main() {
	defer writer.Flush()

	var t int
	scanf("%d\n", &t)
	for t > 0 {

		var n int
		scanf("%d\n", &n)
		var arr []int
		arr = make([]int, n)
		mx := math.MinInt16
		for i := 0; i < n; i++ {
			scanf("%d", &arr[i])
			if mx < arr[i] {
				mx = arr[i]
			}
		}
		scanf("\n")
		sort.SliceStable(arr, func(i, j int) bool {
			return math.Abs(float64(arr[i])) > math.Abs(float64(arr[j]))
		})
		// printf("%d\n", arr)
		if mx < 0 {
			printf("%d\n", arr[n-1]*arr[n-2]*arr[n-3]*arr[n-4]*arr[n-5])
		} else {
			ans := arr[0] * arr[1] * arr[2] * arr[3] * arr[4]
			for i := 5; i < n; i++ {
				for j := 0; j < 5; j++ {
					temp := arr[i]
					for k := 0; k < 5; k++ {
						if k != j {
							temp = temp * arr[k]
						}
					}
					if ans < temp {
						ans = temp
					}
				}
			}
			printf("%d\n", ans)
		}
		t--
	}
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }

func main() {
	defer writer.Flush()

	var t int
	scanf("%d\n", &t)
	for t > 0 {

		var n int
		scanf("%d\n", &n)
		var arr []int
		arr = make([]int, n)
		mx := math.MinInt16
		for i := 0; i < n; i++ {
			scanf("%d", &arr[i])
			if mx < arr[i] {
				mx = arr[i]
			}
		}
		scanf("\n")
		sort.SliceStable(arr, func(i, j int) bool {
			return math.Abs(float64(arr[i])) > math.Abs(float64(arr[j]))
		})
		// printf("%d\n", arr)
		var ans int64

		if mx < 0 {
			ans = int64(arr[n-1] * arr[n-2] * arr[n-3] * arr[n-4] * arr[n-5])
			printf("%v\n", ans)
		} else {
			ans = int64(arr[0] * arr[1] * arr[2] * arr[3] * arr[4])
			for i := 5; i < n; i++ {
				for j := 0; j < 5; j++ {
					var temp int64
					temp = int64(arr[i])
					for k := 0; k < 5; k++ {
						if k != j {
							temp *= int64(arr[k])
						}
					}
					if ans < temp {
						ans = temp
					}
				}
			}
			printf("%v\n", ans)
		}
		t--
	}
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }

func main() {
	defer writer.Flush()

	var t int
	scanf("%d\n", &t)
	for t > 0 {

		var n int
		scanf("%d\n", &n)
		var arr []int
		arr = make([]int, n)
		mx := math.MinInt16
		for i := 0; i < n; i++ {
			scanf("%d", &arr[i])
			if mx < arr[i] {
				mx = arr[i]
			}
		}
		scanf("\n")
		sort.SliceStable(arr, func(i, j int) bool {
			return math.Abs(float64(i)) < math.Abs(float64(j))
		})
		// printf("%d\n", arr)
		if mx < 0 {
			printf("%d\n", arr[n-1]*arr[n-2]*arr[n-3]*arr[n-4]*arr[n-5])
		} else {
			ans := 0
			for i := 5; i < n; i++ {
				for j := 0; j < 5; j++ {
					temp := arr[i]
					for k := 0; k < 5; k++ {
						if k != j {
							temp = temp * arr[k]
						}
					}
					if ans < temp {
						ans = temp
					}
				}
			}
			printf("%d\n", ans)
		}
		t--
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }

func main() {
	defer writer.Flush()

	var t int
	scanf("%d\n", &t)
	for t > 0 {

		var n int
		scanf("%d\n", &n)
		var arr []int
		arr = make([]int, n)
		for i := 0; i < n; i++ {
			scanf("%d", &arr[i])
		}
		scanf("\n")

		var m int
		m = 1
		for i := 0; i < 5; i++ {
			m = m * arr[i]
		}

		ans := m
		for i := 5; i < n; i++ {
			m := m * arr[i]
			for j := i - 5; j < i; j++ {
				if arr[j] == 0 {
					arr[j] = 1
					if ans < 0 {
						ans = 0
					}
				}
				if ans < m/arr[j] {
					ans = m / arr[j]
				}
			}
			m = m / arr[i-5]
		}
		printf("%d\n", ans)
		t--
	}
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }

func main() {
	defer writer.Flush()

	var t int
	scanf("%d\n", &t)
	for t > 0 {

		var n int
		scanf("%d\n", &n)
		var arr []int
		arr = make([]int, n)
		mx := math.MinInt16
		for i := 0; i < n; i++ {
			scanf("%d", &arr[i])
			if mx < arr[i] {
				mx = arr[i]
			}
		}
		scanf("\n")
		sort.SliceStable(arr, func(i, j int) bool {
			return math.Abs(float64(arr[i])) > math.Abs(float64(arr[j]))
		})
		// printf("%d\n", arr)
		if mx < 0 {
			printf("%d\n", arr[n-1]*arr[n-2]*arr[n-3]*arr[n-4]*arr[n-5])
		} else {
			var ans int64
			ans = int64(arr[0] * arr[1] * arr[2] * arr[3] * arr[4])
			for i := 5; i < n; i++ {
				for j := 0; j < 5; j++ {
					var temp int64
					temp = int64(arr[i])
					for k := 0; k < 5; k++ {
						if k != j {
							temp *= int64(arr[k])
						}
					}
					if ans < temp {
						ans = temp
					}
				}
			}
			printf("%d\n", ans)
		}
		t--
	}
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }

func main() {
	defer writer.Flush()

	var t int
	scanf("%d\n", &t)
	for t > 0 {

		var n int
		scanf("%d\n", &n)
		var arr []int
		arr = make([]int, n)
		mx := math.MinInt16
		for i := 0; i < n; i++ {
			scanf("%d", &arr[i])
			if mx < arr[i] {
				mx = arr[i]
			}
		}
		scanf("\n")
		sort.SliceStable(arr, func(i, j int) bool {
			return math.Abs(float64(arr[i])) > math.Abs(float64(arr[j]))
		})
		printf("%d\n", arr)
		if mx < 0 {
			printf("%d\n", arr[n-1]*arr[n-2]*arr[n-3]*arr[n-4]*arr[n-5])
		} else {
			ans := 0
			for i := 5; i < n; i++ {
				for j := 0; j < 5; j++ {
					temp := arr[i]
					for k := 0; k < 5; k++ {
						if k != j {
							temp = temp * arr[k]
						}
					}
					if ans < temp {
						ans = temp
					}
				}
			}
			printf("%d\n", ans)
		}
		t--
	}
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"math"
	"os"
	"sort"
)

/*
5
5
-1 -2 -3 -4 -5
6
-1 -2 -3 1 2 -1
6
-1 0 0 0 -1 -1
6
-9 -7 -5 -3 -2 1
10
1 1 -4 -5 -3 -1 4 5 -3 -1

*/

func MaxProduct(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var T, N, S int
	for Fscan(in, &T); T > 0; T-- {
		var positive, negative []int
		Fscan(in, &N)

		zeroFlag := false

		for tmp := N; tmp > 0; tmp-- {
			Fscan(in, &S)
			if S > 0 {
				positive = append(positive, S)
			} else if S < 0 {
				negative = append(negative, S)
			} else {
				zeroFlag = true
			}
		}

		if (len(negative)+len(positive) < 5) || (len(positive) == 0 && zeroFlag) {
			Fprintln(out, 0)
			continue
		}

		sum := 1
		total := 0

		sort.Ints(positive)
		sort.Ints(negative)

		pend := len(positive) - 1
		nend := 0
		for total < 5 {
			switch total {
			case 0:
				// 正大于2，负数大于2
				if nend+1 < len(negative) && pend-1 >= 0 {
					if negative[nend]*negative[nend+1] >= positive[pend]*positive[pend-1] || pend-2 < 0 {
						sum = sum * negative[nend] * negative[nend+1]
						nend += 2
						total += 2
					} else {
						sum = sum * positive[pend] * positive[pend-1]
						pend -= 2
						total += 2
					}
				} else if nend+1 < len(negative) {
					sum = sum * negative[nend] * negative[nend+1]
					nend += 2
					total += 2
				} else {
					sum = sum * positive[pend] * positive[pend-1]
					pend -= 2
					total += 2
				}
			case 2:
				var tmpmax int = math.MinInt32
				// 0正数
				if nend+2 < len(negative) {
					tmpmax = negative[nend] * negative[nend+1] * negative[nend+2]
				}

				// 1个正数
				if pend >= 0 && nend+1 < len(negative) {
					tmpmax = MPMax(tmpmax, negative[nend]*negative[nend+1]*positive[pend])

					// 能不能拿3个
					if pend >= 3 {
						if positive[pend]*positive[pend-1]*positive[pend-2] < negative[nend]*negative[nend+1]*positive[pend] {

						} else {
							tmpmax = positive[pend] * positive[pend-1] * positive[pend-2]
						}
					}
				}

				//2正数
				if pend >= 1 && nend < len(negative) {
					tmpmax = MPMax(tmpmax, negative[nend]*positive[pend-1]*positive[pend])
				}

				//3正数
				if pend >= 2 {
					tmpmax = MPMax(tmpmax, positive[pend]*positive[pend-1]*positive[pend-2])
				}

				sum = sum * tmpmax
				total += 3

			}
		}

		if zeroFlag {
			sum = MPMax(0, sum)
		}

		Fprintln(out, sum)
	}
}

func MPMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}
func main() {
	MaxProduct(os.Stdin, os.Stdout)
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
	"sort"
)

/*
4
5
-1 -2 -3 -4 -5
6
-1 -2 -3 1 2 -1
6
-1 0 0 0 -1 -1
6
-9 -7 -5 -3 -2 1
*/

func MaxProduct(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var T, N, S int
	for Fscan(in, &T); T > 0; T-- {
		var positive, negative []int
		Fscan(in, &N)

		zeroFlag := false

		for tmp := N; tmp > 0; tmp-- {
			Fscan(in, &S)
			if S > 0 {
				positive = append(positive, S)
			} else if S < 0 {
				negative = append(negative, S)
			} else {
				zeroFlag = true
			}
		}

		Println(positive, negative)

		if (len(negative)+len(positive) < 5) || (len(positive) == 0 && zeroFlag) {
			Fprintln(out, 0)
			continue
		}

		sum := 1
		total := 0

		sort.Ints(positive)
		sort.Ints(negative)

		pend := len(positive) - 1
		nend := 0
		for total < 5 {

			if total == 4 {
				if pend >= 0 {
					sum = sum * positive[pend]
					pend--
					total++
				} else {
					sum = sum * negative[len(negative)-1]
					total++
				}
				continue
			}

			if nend+1 < len(negative) && pend-1 >= 0 {
				if negative[nend]*negative[nend+1] > positive[pend]*positive[pend-1] || pend-2 < 0 {
					sum = sum * negative[nend] * negative[nend+1]
					nend += 2
					total += 2
				} else {
					sum = sum * positive[pend] * positive[pend-1]
					pend -= 2
					total += 2
				}
			} else if nend+1 < len(negative) {
				sum = sum * negative[nend] * negative[nend+1]
				nend += 2
				total += 2
			} else {
				sum = sum * positive[pend] * positive[pend-1]
				pend -= 2
				total += 2
			}
		}

		Fprintln(out, sum)
	}
}

func main() {
	MaxProduct(os.Stdin, os.Stdout)
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
	"sort"
)

/*
4
5
-1 -2 -3 -4 -5
6
-1 -2 -3 1 2 -1
6
-1 0 0 0 -1 -1
6
-9 -7 -5 -3 -2 1
*/

func MaxProduct(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var T, N, S int
	for Fscan(in, &T); T > 0; T-- {
		var positive, negative []int
		Fscan(in, &N)

		zeroFlag := false

		for tmp := N; tmp > 0; tmp-- {
			Fscan(in, &S)
			if S > 0 {
				positive = append(positive, S)
			} else if S < 0 {
				negative = append(negative, S)
			} else {
				zeroFlag = true
			}
		}

		if (len(negative)+len(positive) < 5) || (len(positive) == 0 && zeroFlag) {
			Fprintln(out, 0)
			continue
		}

		sum := 1
		total := 0

		sort.Ints(positive)
		sort.Ints(negative)

		pend := len(positive) - 1
		nend := 0
		for total < 5 {

			if total == 4 {
				if pend >= 0 {
					sum = sum * positive[pend]
					pend--
					total++
				} else {
					sum = sum * negative[len(negative)-1]
					total++
				}
				continue
			}

			if nend+1 < len(negative) && pend-1 >= 0 {
				if negative[nend]*negative[nend+1] > positive[pend]*positive[pend-1] || pend-2 < 0 {
					sum = sum * negative[nend] * negative[nend+1]
					nend += 2
					total += 2
				} else {
					sum = sum * positive[pend] * positive[pend-1]
					pend -= 2
					total += 2
				}
			} else if nend+1 < len(negative) {
				sum = sum * negative[nend] * negative[nend+1]
				nend += 2
				total += 2
			} else {
				sum = sum * positive[pend] * positive[pend-1]
				pend -= 2
				total += 2
			}
		}

		Fprintln(out, sum)
	}
}

func main() {
	MaxProduct(os.Stdin, os.Stdout)
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"math"
	"os"
	"sort"
)

/*
5
5
-1 -2 -3 -4 -5
6
-1 -2 -3 1 2 -1
6
-1 0 0 0 -1 -1
6
-9 -7 -5 -3 -2 1
10
1 1 -4 -5 -3 -1 4 5 -3 -1

*/

func MaxProduct(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var T, N, S int
	for Fscan(in, &T); T > 0; T-- {
		var positive, negative []int
		Fscan(in, &N)

		zeroFlag := false

		for tmp := N; tmp > 0; tmp-- {
			Fscan(in, &S)
			if S > 0 {
				positive = append(positive, S)
			} else if S < 0 {
				negative = append(negative, S)
			} else {
				zeroFlag = true
			}
		}

		if (len(negative)+len(positive) < 5) || (len(positive) == 0 && zeroFlag) {
			Fprintln(out, 0)
			continue
		}

		sum := math.MinInt32

		sort.Ints(positive)
		sort.Ints(negative)

		for pnums := 0; pnums <= 5; pnums++ {
			if len(negative) < 5-pnums || len(positive) < pnums {
				continue
			}

			if (5-pnums)%2 != 0 {
				tmpSum := 1
				for i := 0; i < pnums; i++ {
					tmpSum = tmpSum * positive[i]
				}

				for j := len(negative) - 1; j > len(negative)-6+pnums; j-- {
					tmpSum = tmpSum * negative[j]
				}

				sum = MPMax(sum, tmpSum)
			} else {
				tmpSum := 1
				for i := 0; i < pnums; i++ {
					tmpSum = tmpSum * positive[len(positive)-i-1]
				}

				for j := 0; j < 5-pnums; j++ {
					tmpSum = tmpSum * negative[j]
				}

				sum = MPMax(sum, tmpSum)
			}

		}

		if zeroFlag {
			sum = MPMax(sum, 0)
		}

		Fprintln(out, sum)
	}
}

func MaxProduct1(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var T, N, S int
	for Fscan(in, &T); T > 0; T-- {
		var positive, negative []int
		Fscan(in, &N)

		zeroFlag := false

		for tmp := N; tmp > 0; tmp-- {
			Fscan(in, &S)
			if S > 0 {
				positive = append(positive, S)
			} else if S < 0 {
				negative = append(negative, S)
			} else {
				zeroFlag = true
			}
		}

		if (len(negative)+len(positive) < 5) || (len(positive) == 0 && zeroFlag) {
			Fprintln(out, 0)
			continue
		}

		sum := 1
		total := 0

		sort.Ints(positive)
		sort.Ints(negative)

		pend := len(positive) - 1
		nend := 0
		for total < 5 {
			switch total {
			case 0:
				// 正大于2，负数大于2
				if nend+1 < len(negative) && pend-1 >= 0 {
					if negative[nend]*negative[nend+1] >= positive[pend]*positive[pend-1] || pend-2 < 0 {
						sum = sum * negative[nend] * negative[nend+1]
						nend += 2
						total += 2
					} else {
						sum = sum * positive[pend] * positive[pend-1]
						pend -= 2
						total += 2
					}
				} else if nend+1 < len(negative) {
					sum = sum * negative[nend] * negative[nend+1]
					nend += 2
					total += 2
				} else {
					sum = sum * positive[pend] * positive[pend-1]
					pend -= 2
					total += 2
				}
			case 2:
				var tmpmax int = math.MinInt32
				// 0正数
				if nend+2 < len(negative) {
					tmpmax = negative[nend] * negative[nend+1] * negative[nend+2]
				}

				// 1个正数
				if pend >= 0 && nend+1 < len(negative) {
					tmpmax = MPMax(tmpmax, negative[nend]*negative[nend+1]*positive[pend])

					// 能不能拿3个
					if pend >= 3 {
						if positive[pend]*positive[pend-1]*positive[pend-2] < negative[nend]*negative[nend+1]*positive[pend] {

						} else {
							tmpmax = positive[pend] * positive[pend-1] * positive[pend-2]
						}
					}
				}

				//2正数
				if pend >= 1 && nend < len(negative) {
					tmpmax = MPMax(tmpmax, negative[nend]*positive[pend-1]*positive[pend])
				}

				//3正数
				if pend >= 2 {
					tmpmax = MPMax(tmpmax, positive[pend]*positive[pend-1]*positive[pend-2])
				}

				sum = sum * tmpmax
				total += 3

			}
		}

		if zeroFlag {
			sum = MPMax(0, sum)
		}

		Fprintln(out, sum)
	}
}

func MPMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}
func main() {
	MaxProduct(os.Stdin, os.Stdout)
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"math"
	"os"
	"sort"
)

/*
5
5
-1 -2 -3 -4 -5
6
-1 -2 -3 1 2 -1
6
-1 0 0 0 -1 -1
6
-9 -7 -5 -3 -2 1
10
1 1 -4 -5 -3 -1 4 5 -3 -1

*/

func MaxProduct(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var T, N, S int
	for Fscan(in, &T); T > 0; T-- {
		var positive, negative []int
		Fscan(in, &N)

		zeroFlag := false

		for tmp := N; tmp > 0; tmp-- {
			Fscan(in, &S)
			if S > 0 {
				positive = append(positive, S)
			} else if S < 0 {
				negative = append(negative, S)
			} else {
				zeroFlag = true
			}
		}

		if (len(negative)+len(positive) < 5) || (len(positive) == 0 && zeroFlag) {
			Fprintln(out, 0)
			continue
		}

		sum := 1
		total := 0

		sort.Ints(positive)
		sort.Ints(negative)

		pend := len(positive) - 1
		nend := 0
		for total < 5 {
			switch total {
			case 0:
				// 正大于2，负数大于2
				if nend+1 < len(negative) && pend-1 >= 0 {
					if negative[nend]*negative[nend+1] >= positive[pend]*positive[pend-1] || pend-2 < 0 {
						sum = sum * negative[nend] * negative[nend+1]
						nend += 2
						total += 2
					} else {
						sum = sum * positive[pend] * positive[pend-1]
						pend -= 2
						total += 2
					}
				} else if nend+1 < len(negative) {
					sum = sum * negative[nend] * negative[nend+1]
					nend += 2
					total += 2
				} else {
					sum = sum * positive[pend] * positive[pend-1]
					pend -= 2
					total += 2
				}
			case 2:
				var tmpmax int = math.MinInt32
				// 0正数
				if nend+2 < len(negative) {
					tmpmax = negative[nend] * negative[nend+1] * negative[nend+2]
				}

				// 1个正数
				if pend >= 0 && nend+1 < len(negative) {
					tmpmax = MPMax(tmpmax, negative[nend]*negative[nend+1]*positive[pend])

					// 能不能拿3个
					if pend >= 3 {
						if positive[pend]*positive[pend-1]*positive[pend-2] < negative[nend]*negative[nend+1]*positive[pend] {

						} else {
							tmpmax = positive[pend] * positive[pend-1] * positive[pend-2]
						}
					}
				}

				//2正数
				if pend >= 1 && nend < len(negative) {
					tmpmax = MPMax(tmpmax, negative[nend]*positive[pend-1]*positive[pend])
				}

				//3正数
				if pend >= 2 {
					tmpmax = MPMax(tmpmax, positive[pend]*positive[pend-1]*positive[pend-2])
				}

				sum = sum * tmpmax
				total += 3

			}

		}

		Fprintln(out, sum)
	}
}

func MPMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}
func main() {
	MaxProduct(os.Stdin, os.Stdout)
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
	"sort"
)

/*
4
5
-1 -2 -3 -4 -5
6
-1 -2 -3 1 2 -1
6
-1 0 0 0 -1 -1
6
-9 -7 -5 -3 -2 1
*/

func MaxProduct(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var T, N, S int
	for Fscan(in, &T); T > 0; T-- {
		var positive, negative []int
		Fscan(in, &N)

		zeroFlag := false

		for tmp := N; tmp > 0; tmp-- {
			Fscan(in, &S)
			if S > 0 {
				positive = append(positive, S)
			} else if S < 0 {
				negative = append(negative, S)
			} else {
				zeroFlag = true
			}
		}

		if (len(negative)+len(positive) < 5) || (len(positive) == 0 && zeroFlag) {
			Fprintln(out, 0)
			continue
		}

		sum := -1
		total := 0

		sort.Ints(positive)
		sort.Ints(negative)

		pend := len(positive) - 1
		nend := 0
		for total < 5 {
			if total == 4 {
				if pend >= 0 {
					sum = sum * positive[pend]
					pend--
					total++
				} else {
					sum = sum * negative[len(negative)-1]
					total++
				}
				continue
			}

			if nend+1 < len(negative) && pend-1 >= 0 {
				if negative[nend]*negative[nend+1] > positive[pend]*positive[pend-1] {
					sum = sum * negative[nend] * negative[nend+1]
					nend += 2
					total += 2
				} else {
					sum = sum * positive[pend] * positive[pend-1]
					pend -= 2
					total += 2
				}
			} else if nend+1 < len(negative) {
				sum = sum * negative[nend] * negative[nend+1]
				nend += 2
				total += 2
			} else {
				sum = sum * positive[pend] * positive[pend-1]
				pend -= 2
				total += 2
			}
		}

		Fprintln(out, sum)
	}
}

func main() {
	MaxProduct(os.Stdin, os.Stdout)
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"math"
	"os"
	"sort"
)

/*
5
5
-1 -2 -3 -4 -5
6
-1 -2 -3 1 2 -1
6
-1 0 0 0 -1 -1
6
-9 -7 -5 -3 -2 1
10
1 1 -4 -5 -3 -1 4 5 -3 -1

*/

func MaxProduct(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var T, N, S int
	for Fscan(in, &T); T > 0; T-- {
		var positive, negative []int
		Fscan(in, &N)

		zeroFlag := false

		for tmp := N; tmp > 0; tmp-- {
			Fscan(in, &S)
			if S > 0 {
				positive = append(positive, S)
			} else if S < 0 {
				negative = append(negative, S)
			} else {
				zeroFlag = true
			}
		}

		if (len(negative)+len(positive) < 5) || (len(positive) == 0 && zeroFlag) {
			Fprintln(out, 0)
			continue
		}

		sum := 1
		total := 0

		sort.Ints(positive)
		sort.Ints(negative)

		pend := len(positive) - 1
		nend := 0
		for total < 5 {
			switch total {
			case 0:
				// 正大于2，负数大于2
				if nend+1 < len(negative) && pend-1 >= 0 {
					if negative[nend]*negative[nend+1] > positive[pend]*positive[pend-1] || pend-2 < 0 {
						sum = sum * negative[nend] * negative[nend+1]
						nend += 2
						total += 2
					} else {
						sum = sum * positive[pend] * positive[pend-1]
						pend -= 2
						total += 2
					}
				} else if nend+1 < len(negative) {
					sum = sum * negative[nend] * negative[nend+1]
					nend += 2
					total += 2
				} else {
					sum = sum * positive[pend] * positive[pend-1]
					pend -= 2
					total += 2
				}
			case 2:
				var tmpmax int = math.MinInt32
				// 0正数
				if nend+2 < len(negative) {
					tmpmax = negative[nend] * negative[nend+1] * negative[nend+2]
				}

				// 1个正数
				if pend >= 0 && nend+1 < len(negative) {
					tmpmax = MPMax(tmpmax, negative[nend]*negative[nend+1]*positive[pend])

					// 能不能拿3个
					if pend >= 3 {
						if positive[pend]*positive[pend-1]*positive[pend-2] < negative[nend]*negative[nend+1]*positive[pend] {

						} else {
							tmpmax = positive[pend] * positive[pend-1] * positive[pend-2]
						}
					}
				}

				//2正数
				if pend >= 1 && nend < len(negative) {
					tmpmax = MPMax(tmpmax, negative[nend]*positive[pend-1]*positive[pend])
				}

				//3正数
				if pend >= 2 {
					tmpmax = MPMax(tmpmax, positive[pend]*positive[pend-1]*positive[pend-2])
				}

				sum = sum * tmpmax
				total += 3

			}

		}

		Fprintln(out, sum)
	}
}

func MPMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}
func main() {
	MaxProduct(os.Stdin, os.Stdout)
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
	"sort"
)

/*
5
5
-1 -2 -3 -4 -5
6
-1 -2 -3 1 2 -1
6
-1 0 0 0 -1 -1
6
-9 -7 -5 -3 -2 1
10
1 1 -4 -5 -3 -1 4 5 -3 -1

*/

func MaxProduct(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var T, N, S int
	for Fscan(in, &T); T > 0; T-- {
		var positive, negative []int
		Fscan(in, &N)

		zeroFlag := false

		for tmp := N; tmp > 0; tmp-- {
			Fscan(in, &S)
			if S > 0 {
				positive = append(positive, S)
			} else if S < 0 {
				negative = append(negative, S)
			} else {
				zeroFlag = true
			}
		}

		if (len(negative)+len(positive) < 5) || (len(positive) == 0 && zeroFlag) {
			Fprintln(out, 0)
			continue
		}

		sum := 1
		total := 0

		sort.Ints(positive)
		sort.Ints(negative)

		pend := len(positive) - 1
		nend := 0
		for total < 5 {
			switch total {
			case 0:
				// 正大于2，负数大于2
				if nend+1 < len(negative) && pend-1 >= 0 {
					if negative[nend]*negative[nend+1] > positive[pend]*positive[pend-1] || pend-2 < 0 {
						sum = sum * negative[nend] * negative[nend+1]
						nend += 2
						total += 2
					} else {
						sum = sum * positive[pend] * positive[pend-1]
						pend -= 2
						total += 2
					}
				} else if nend+1 < len(negative) {
					sum = sum * negative[nend] * negative[nend+1]
					nend += 2
					total += 2
				} else {
					sum = sum * positive[pend] * positive[pend-1]
					pend -= 2
					total += 2
				}
			case 2:
				var tmpmax int
				// 0正数
				if nend+2 < len(negative) {
					tmpmax = negative[nend] * negative[nend+1] * negative[nend+2]
				}

				// 1个正数
				if pend >= 0 && nend+1 < len(negative) {
					tmpmax = MPMax(tmpmax, negative[nend]*negative[nend+1]*positive[pend])

					// 能不能拿3个
					if pend >= 3 {
						if positive[pend]*positive[pend-1]*positive[pend-2] < negative[nend]*negative[nend+1]*positive[pend] {

						} else {
							tmpmax = positive[pend] * positive[pend-1] * positive[pend-2]
						}
					}
				}

				//2正数
				if pend >= 1 && nend < len(negative) {
					tmpmax = MPMax(tmpmax, negative[nend]*positive[pend-1]*positive[pend])
				}

				//3正数
				if pend >= 2 {
					tmpmax = MPMax(tmpmax, positive[pend]*positive[pend-1]*positive[pend-2])
				}

				sum = sum * tmpmax
				total += 3

			}

		}

		Fprintln(out, sum)
	}
}

func MPMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}
func main() {
	MaxProduct(os.Stdin, os.Stdout)
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

type Int64 []int64

func (a Int64) Less(i, j int) bool {
	return a[i] < a[j]
}

func (a Int64) Len() int {
	return len(a)
}

func (a Int64) Swap(i, j int) {
	a[i], a[j] = a[j], a[i]
}

func maxProduct(a []int64, n int) int64 {
	sort.Sort(Int64(a))
	var ans, tempAns int64
	ans = a[n-1] * a[n-2] * a[n-3] * a[n-4] * a[n-5]
	tempAns = a[0] * a[1] * a[2] * a[3] * a[n-1]
	if tempAns > ans {
		ans = tempAns
	}
	tempAns = a[0] * a[1] * a[n-3] * a[n-4] * a[n-5]
	if tempAns > ans {
		ans = tempAns
	}
	return ans
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	var t, n int
	var ans int64
	fmt.Fscanln(reader, &t)
	for i := 0; i < t; i++ {
		fmt.Fscanln(reader, &n)
		a := make([]int64, n)
		for j := 0; j < n-1; j++ {
			fmt.Fscanf(reader, "%d ", &a[j])
		}
		fmt.Fscanf(reader, "%d\n", &a[n-1])
		ans = maxProduct(a, n)
		fmt.Fprintln(writer, ans)
	}
}


There are $$$n$$$ children, who study at the school №41. It is well-known that they are good mathematicians. Once at a break, they arranged a challenge for themselves. All children arranged in a row and turned heads either to the left or to the right.Children can do the following: in one second several pairs of neighboring children who are looking at each other can simultaneously turn the head in the opposite direction. For instance, the one who was looking at the right neighbor turns left and vice versa for the second child. Moreover, every second at least one pair of neighboring children performs such action. They are going to finish when there is no pair of neighboring children who are looking at each other. You are given the number $$$n$$$, the initial arrangement of children and the number $$$k$$$. You have to find a way for the children to act if they want to finish the process in exactly $$$k$$$ seconds. More formally, for each of the $$$k$$$ moves, you need to output the numbers of the children who turn left during this move.For instance, for the configuration shown below and $$$k = 2$$$ children can do the following steps:    At the beginning, two pairs make move: $$$(1, 2)$$$ and $$$(3, 4)$$$. After that, we receive the following configuration:    At the second move pair $$$(2, 3)$$$ makes the move. The final configuration is reached. Good job.   It is guaranteed that if the solution exists, it takes not more than $$$n^2$$$ "headturns".

The first line of input contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 3000$$$, $$$1 \le k \le 3000000$$$)  — the number of children and required number of moves. The next line contains a string of length $$$n$$$ and consists only of characters L and R, where L means that the child looks to the left and R means that the child looks to the right.

If there is no solution, print a single line with number $$$-1$$$. Otherwise, output $$$k$$$ lines. Each line has to start with a number $$$n_i$$$ ($$$1\le n_i \le \frac{n}{2}$$$)  — the number of pairs of children, who turn at this move. After that print $$$n_i$$$ distinct integers  — the numbers of the children who will turn left during this move.  After performing all "headturns", there can't be a pair of two neighboring children looking at each other. If there are many solutions, print any of them.

NoteThe first sample contains a pair of children who look at each other. After one move, they can finish the process.In the second sample, children can't make any move. As a result, they can't end in $$$k>0$$$ moves.The third configuration is described in the statement.

package main

import (
	"bufio"
	"container/list"
	"fmt"
	"os"
)

func main() {
	rd := bufio.NewReader(os.Stdin)
	wr := bufio.NewWriter(os.Stdout)
	var n, m, k, i, j, inv, l int //, y, z int
	var arr []int
	var arr1 [][]int
	var ch byte
	var s string
	var ls list.List
	var e, ep, en, enn *list.Element
	arr1 = make([][]int, 0)
	fmt.Fscanf(rd, "%d %d\n", &n, &k)
	fmt.Fscanf(rd, "%s", &s)
	ch = 'L'
	j = 0
	for i = 0; i < len(s); i++ {
		if ch == s[i] {
			j++
		} else {
			ls.PushBack(j)
			ch = s[i]
			j = 1
		}
	}
	ls.PushBack(j)
	e = ls.Back()
	if ch == 'R' {
		e = e.Prev()
	}
	ch = 'L'
	j = 0
	for ; e != nil; e = e.Prev() {
		if ch == 'L' {
			l, _ = e.Value.(int)
			j += l
			ch = 'R'
		} else {
			l, _ = e.Value.(int)
			inv += l * j
			ch = 'L'
		}
	}

	if k > inv {
		fmt.Fprintf(wr, "-1\n")
	} else {
		for ls.Len() > 2 {
			l = ls.Front().Value.(int)
			e = ls.Front().Next()
			for e != nil {
				en = e.Next()
				if en == nil {
					break
				}
				ep = e.Prev()
				enn = en.Next()
				i = e.Value.(int)
				arr = append(arr, l+i)
				m = en.Value.(int)
				if i == 1 {
					if m == 1 {
						ep.Value = ep.Value.(int) + 1
						ls.Remove(en)
						if enn != nil {
							enn.Value = enn.Value.(int) + 1
							ls.Remove(e)
						}
						l += 1
					} else {
						ep.Value = ep.Value.(int) + 1
						en.Value = en.Value.(int) - 1
						l += i + m
					}
				} else {
					if m == 1 {
						e.Value = e.Value.(int) - 1
						if enn != nil {
							enn.Value = enn.Value.(int) + 1
						} else {
							ls.InsertAfter(1, en)
						}
						l += i + m - 1
					} else {
						e.Value = e.Value.(int) - 1
						en.Value = en.Value.(int) - 1
						ls.InsertAfter(1, e)
						ls.InsertAfter(1, e)
						l += i + m
					}
				}
				inv--
				if inv < k {
					// fmt.Fprintf(wr, "%d ", len(arr))
					// for i = 0; i < len(arr); i++ {
					// 	fmt.Fprintf(wr, "%d ", arr[i])
					// }
					// fmt.Fprintf(wr, "\n")
					arr1 = append(arr1, arr)
					arr = make([]int, 0)
					k--
					if k == 0 {
						break
					}
				}
				e = enn
			}
			if k == 0 {
				break
			}
			if len(arr) > 0 {
				// fmt.Fprintf(wr, "%d ", len(arr))
				// for i = 0; i < len(arr); i++ {
				// 	fmt.Fprintf(wr, "%d ", arr[i])
				// }
				// fmt.Fprintf(wr, "\n")
				arr1 = append(arr1, arr)
				arr = make([]int, 0)
				k--
				if k == 0 {
					break
				}
			}
		}
		if k == 0 && inv == 0 {
			for i = 0; i < len(arr1); i++ {
				fmt.Fprintf(wr, "%d ", len(arr1[i]))
				for j = 0; j < len(arr1[i]); j++ {
					fmt.Fprintf(wr, "%d ", arr1[i][j])
				}
				fmt.Fprintf(wr, "\n")
			}
		} else {
			fmt.Fprintf(wr, "-1")
		}
	}
	wr.Flush()
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

const N = 3010
var n, k int
var s string
var ways [][]int
var ret [][]int
var t [N]int

func min(a int, b int) int {
	if a < b {
		return a
	}
	return b
}

func main()  {
	var reader = bufio.NewReader(os.Stdin)
	var writer = bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	fmt.Fscanf(reader, "%d %d\n", &n, &k)
	fmt.Fscanf(reader, "%s", &s)
	ways = make([][]int, 0)
	for i := 0; i < n; i++ {
		if s[i] == 'L' {
			t[i] = 1
		}
	}

	var total = 0
	for true {
		var move = make([]int, 0)

		for i := 0; i < n - 1; i++ {
			if t[i] == 0 && t[i + 1] == 1 {
				move = append(move, i+1)
				t[i], t[i+1] = t[i+1], t[i]
				i++
				total++
			}
		}
		if len(move) == 0 {
			break
		}

		ways = append(ways, move)
	}

	if total < k || k < len(ways) {
		fmt.Fprintf(writer, "-1")
		return
	}

	ret = make([][]int, 0)
	var gt = k - len(ways)

	for _, dt := range ways {
		var z = min(gt, len(dt) - 1)
		gt -= z
		for i := 0; i < z; i++ {
			ret = append(ret, dt[i:i + 1])
		}
		ret = append(ret, dt[z:])
	}

	for _, dt := range ret {
		fmt.Fprintf(writer, "%d ", len(dt))
		for _, z := range dt {
			fmt.Fprintf(writer, "%d ", z)
		}
		fmt.Fprintf(writer, "\n")
	}

}

package main

import (
	"bufio"
	"container/list"
	"fmt"
	"os"
)

func main() {
	rd := bufio.NewReader(os.Stdin)
	wr := bufio.NewWriter(os.Stdout)
	var n, m, k, i, j, inv, l, x int //, y, z int
	var arr []int
	var ch byte
	var s string
	var ls list.List
	var e, ep *list.Element
	fmt.Fscanf(rd, "%d %d\n", &n, &k)
	fmt.Fscanf(rd, "%s", &s)
	ch = 'L'
	j = 0
	for i = 0; i < len(s); i++ {
		if ch == s[i] {
			j++
		} else {
			ls.PushBack(j)
			ch = s[i]
			j = 1
		}
	}
	ls.PushBack(j)
	e = ls.Back()
	if ch == 'R' {
		e = e.Prev()
	}
	ch = 'L'
	j = 0
	for ; e != nil; e = e.Prev() {
		if ch == 'L' {
			l, _ = e.Value.(int)
			j += l
			ch = 'R'
		} else {
			l, _ = e.Value.(int)
			inv += l * j
			ch = 'L'
		}
	}

	if k > inv {
		fmt.Fprintf(wr, "-1\n")
	} else {
		for ls.Len() > 2 {
			j = 0
			l = 0
			for e = ls.Front(); e != nil; e = e.Next() {
				x, _ = e.Value.(int)
				if j%2 == 0 && j > 0 {
					i, _ = e.Value.(int)
					ep = e.Prev()
					m, _ = ep.Value.(int)
					ls.InsertAfter(1, ep)
					ls.InsertBefore(1, e)
					if i-1 == 0 {
						if e.Next() != nil {
							e.Prev().Value = e.Prev().Value.(int) + e.Next().Value.(int)
							ls.Remove(e.Next())
						}
						e = e.Prev()
						ls.Remove(e.Next())
						x = e.Value.(int)
						j--
					} else {
						e.Value = i - 1
					}
					if m-1 == 0 {
						if ep.Next() != nil {
							ep.Prev().Value = ep.Prev().Value.(int) + ep.Next().Value.(int)
							ls.Remove(ep.Next())
						}
						ls.Remove(ep)
					} else {
						ep.Value = m - 1
					}
					if inv > k {
						arr = append(arr, l)
						inv--
					} else if inv == k {
						arr = append(arr, l)
						inv--
						k--
						if len(arr) > 0 {
							fmt.Fprintf(wr, "%d ", len(arr))
							for i = 0; i < len(arr); i++ {
								fmt.Fprintf(wr, "%d ", arr[i])
							}
							fmt.Fprintf(wr, "\n")
							arr = make([]int, 0)
						}
					} else {
						fmt.Fprintf(wr, " error ")
					}
				}
				l += x
				j++
			}
			if len(arr) > 0 {
				fmt.Fprintf(wr, "%d ", len(arr))
				for i = 0; i < len(arr); i++ {
					fmt.Fprintf(wr, "%d ", arr[i])
				}
				fmt.Fprintf(wr, "\n")
				arr = make([]int, 0)
			}
			k--
		}
	}
	wr.Flush()
}

package main

import (
	"bufio"
	"container/list"
	"fmt"
	"os"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	wr := bufio.NewWriterSize(os.Stdout, 100*1024)
	var n, m, k, i, j, inv, l, x int //, y, z int
	var arr []int
	var ch byte
	var ls list.List
	var e, ep *list.Element
	sc.Scan()
	fmt.Sscanf(sc.Text(), "%d", &n)
	sc.Scan()
	fmt.Sscanf(sc.Text(), "%d", &k)
	sc.Scan()
	ch = 'L'
	j = 0
	for i = 0; i < len(sc.Bytes()); i++ {
		if ch == sc.Bytes()[i] {
			j++
		} else {
			ls.PushBack(j)
			ch = sc.Bytes()[i]
			j = 1
		}
	}
	ls.PushBack(j)
	e = ls.Back()
	if ch == 'R' {
		e = e.Prev()
	}
	ch = 'L'
	j = 0
	for ; e != nil; e = e.Prev() {
		if ch == 'L' {
			l, _ = e.Value.(int)
			j += l
			ch = 'R'
		} else {
			l, _ = e.Value.(int)
			inv += l * j
			ch = 'L'
		}
	}

	if k > inv {
		fmt.Fprintf(wr, "-1\n")
	} else {
		for ls.Len() > 2 {
			j = 0
			l = 0
			for e = ls.Front(); e != nil; e = e.Next() {
				x, _ = e.Value.(int)
				if j%2 == 0 && j > 0 {
					i, _ = e.Value.(int)
					ep = e.Prev()
					m, _ = ep.Value.(int)
					ls.InsertAfter(1, ep)
					ls.InsertBefore(1, e)
					if i-1 == 0 {
						if e.Next() != nil {
							e.Prev().Value = e.Prev().Value.(int) + e.Next().Value.(int)
							ls.Remove(e.Next())
						}
						e = e.Prev()
						ls.Remove(e.Next())
						x = e.Value.(int)
						j--
					} else {
						e.Value = i - 1
					}
					if m-1 == 0 {
						if ep.Next() != nil {
							ep.Prev().Value = ep.Prev().Value.(int) + ep.Next().Value.(int)
							ls.Remove(ep.Next())
						}
						ls.Remove(ep)
					} else {
						ep.Value = m - 1
					}
					// fmt.Fprintf(wr, "inv=%d k=%d\n", inv, k)
					if inv > k {
						arr = append(arr, l)
						inv--
					} else if inv == k {
						arr = append(arr, l)
						inv--
						k--
						if len(arr) > 0 {
							fmt.Fprintf(wr, "%d ", len(arr))
							for i = 0; i < len(arr); i++ {
								fmt.Fprintf(wr, "%d ", arr[i])
							}
							fmt.Fprintf(wr, "\n")
							arr = make([]int, 0)
						}
					} else {
						fmt.Fprintf(wr, " error ")
					}
				}
				l += x
				j++
			}
			if len(arr) > 0 {
				fmt.Fprintf(wr, "%d ", len(arr))
				for i = 0; i < len(arr); i++ {
					fmt.Fprintf(wr, "%d ", arr[i])
				}
				fmt.Fprintf(wr, "\n")
				arr = make([]int, 0)
			}
			k--
			// for e = ls.Front(); e != nil; e = e.Next() {
			// 	fmt.Fprintf(wr, "%d ", e.Value)
			// }
			// fmt.Fprintf(wr, "\n")
			wr.Flush()
		}
	}
	wr.Flush()
}

package main

import (
	"bufio"
	"container/list"
	"fmt"
	"os"
)

func main() {
	rd := bufio.NewReader(os.Stdin)
	wr := bufio.NewWriter(os.Stdout)
	var n, m, k, i, j, inv, l int //, y, z int
	var arr []int
	var ch byte
	var s string
	var ls list.List
	var e, ep, en, enn *list.Element
	fmt.Fscanf(rd, "%d %d\n", &n, &k)
	fmt.Fscanf(rd, "%s", &s)
	ch = 'L'
	j = 0
	for i = 0; i < len(s); i++ {
		if ch == s[i] {
			j++
		} else {
			ls.PushBack(j)
			ch = s[i]
			j = 1
		}
	}
	ls.PushBack(j)
	e = ls.Back()
	if ch == 'R' {
		e = e.Prev()
	}
	ch = 'L'
	j = 0
	for ; e != nil; e = e.Prev() {
		if ch == 'L' {
			l, _ = e.Value.(int)
			j += l
			ch = 'R'
		} else {
			l, _ = e.Value.(int)
			inv += l * j
			ch = 'L'
		}
	}

	if k > inv {
		fmt.Fprintf(wr, "-1\n")
	} else {
		for ls.Len() > 2 {
			l = ls.Front().Value.(int)
			e = ls.Front().Next()
			for e != nil {
				en = e.Next()
				if en == nil {
					break
				}
				ep = e.Prev()
				enn = en.Next()
				i = e.Value.(int)
				arr = append(arr, l+i)
				m = en.Value.(int)
				if i == 1 {
					if m == 1 {
						ep.Value = ep.Value.(int) + 1
						ls.Remove(en)
						if enn != nil {
							enn.Value = enn.Value.(int) + 1
							ls.Remove(e)
						}
						l += 1
					} else {
						ep.Value = ep.Value.(int) + 1
						en.Value = en.Value.(int) - 1
						l += i + m
					}
				} else {
					if m == 1 {
						e.Value = e.Value.(int) - 1
						if enn != nil {
							enn.Value = enn.Value.(int) + 1
						} else {
							ls.InsertAfter(1, en)
						}
						l += i + m - 1
					} else {
						e.Value = e.Value.(int) - 1
						en.Value = en.Value.(int) - 1
						ls.InsertAfter(1, e)
						ls.InsertAfter(1, e)
						l += i + m
					}
				}
				inv--
				if inv < k {
					fmt.Fprintf(wr, "%d ", len(arr))
					for i = 0; i < len(arr); i++ {
						fmt.Fprintf(wr, "%d ", arr[i])
					}
					fmt.Fprintf(wr, "\n")
					arr = make([]int, 0)
					k--
				}
				e = enn
			}
			if len(arr) > 0 {
				fmt.Fprintf(wr, "%d ", len(arr))
				for i = 0; i < len(arr); i++ {
					fmt.Fprintf(wr, "%d ", arr[i])
				}
				fmt.Fprintf(wr, "\n")
				arr = make([]int, 0)
				k--
			}
		}
	}
	wr.Flush()
}

package main

import (
	"bufio"
	"container/list"
	"fmt"
	"os"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	wr := bufio.NewWriterSize(os.Stdout, 1000*1024)
	var n, m, k, i, j, inv, l, x int //, y, z int
	var arr []int
	var ch byte
	var ls list.List
	var e, ep *list.Element
	sc.Scan()
	fmt.Sscanf(sc.Text(), "%d", &n)
	sc.Scan()
	fmt.Sscanf(sc.Text(), "%d", &k)
	sc.Scan()
	ch = 'L'
	j = 0
	for i = 0; i < len(sc.Bytes()); i++ {
		if ch == sc.Bytes()[i] {
			j++
		} else {
			ls.PushBack(j)
			ch = sc.Bytes()[i]
			j = 1
		}
	}
	ls.PushBack(j)
	e = ls.Back()
	if ch == 'R' {
		e = e.Prev()
	}
	ch = 'L'
	j = 0
	for ; e != nil; e = e.Prev() {
		if ch == 'L' {
			l, _ = e.Value.(int)
			j += l
			ch = 'R'
		} else {
			l, _ = e.Value.(int)
			inv += l * j
			ch = 'L'
		}
	}

	if k > inv {
		fmt.Fprintf(wr, "-1\n")
	} else {
		for ls.Len() > 2 {
			j = 0
			l = 0
			for e = ls.Front(); e != nil; e = e.Next() {
				x, _ = e.Value.(int)
				if j%2 == 0 && j > 0 {
					i, _ = e.Value.(int)
					ep = e.Prev()
					m, _ = ep.Value.(int)
					ls.InsertAfter(1, ep)
					ls.InsertBefore(1, e)
					if i-1 == 0 {
						if e.Next() != nil {
							e.Prev().Value = e.Prev().Value.(int) + e.Next().Value.(int)
							ls.Remove(e.Next())
						}
						e = e.Prev()
						ls.Remove(e.Next())
						x = e.Value.(int)
						j--
					} else {
						e.Value = i - 1
					}
					if m-1 == 0 {
						if ep.Next() != nil {
							ep.Prev().Value = ep.Prev().Value.(int) + ep.Next().Value.(int)
							ls.Remove(ep.Next())
						}
						ls.Remove(ep)
					} else {
						ep.Value = m - 1
					}
					// fmt.Fprintf(wr, "inv=%d k=%d\n", inv, k)
					if inv > k {
						arr = append(arr, l)
						inv--
					} else if inv == k {
						arr = append(arr, l)
						inv--
						k--
						if len(arr) > 0 {
							fmt.Fprintf(wr, "%d ", len(arr))
							for i = 0; i < len(arr); i++ {
								fmt.Fprintf(wr, "%d ", arr[i])
							}
							fmt.Fprintf(wr, "\n")
							arr = make([]int, 0)
						}
					} else {
						fmt.Fprintf(wr, " error ")
					}
				}
				l += x
				j++
			}
			if len(arr) > 0 {
				fmt.Fprintf(wr, "%d ", len(arr))
				for i = 0; i < len(arr); i++ {
					fmt.Fprintf(wr, "%d ", arr[i])
				}
				fmt.Fprintf(wr, "\n")
				arr = make([]int, 0)
			}
			k--
			// for e = ls.Front(); e != nil; e = e.Next() {
			// 	fmt.Fprintf(wr, "%d ", e.Value)
			// }
			// fmt.Fprintf(wr, "\n")
			wr.Flush()
		}
	}
	wr.Flush()
}

package main

import (
	"bufio"
	"container/list"
	"fmt"
	"os"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	wr := bufio.NewWriter(os.Stdout)
	var n, m, k, i, j, inv, l, x int //, y, z int
	var arr []int
	var ch byte
	var ls list.List
	var e, ep *list.Element
	sc.Scan()
	fmt.Sscanf(sc.Text(), "%d", &n)
	sc.Scan()
	fmt.Sscanf(sc.Text(), "%d", &k)
	sc.Scan()
	ch = 'L'
	j = 0
	for i = 0; i < len(sc.Bytes()); i++ {
		if ch == sc.Bytes()[i] {
			j++
		} else {
			ls.PushBack(j)
			ch = sc.Bytes()[i]
			j = 1
		}
	}
	ls.PushBack(j)
	e = ls.Back()
	if ch == 'R' {
		e = e.Prev()
	}
	ch = 'L'
	j = 0
	for ; e != nil; e = e.Prev() {
		if ch == 'L' {
			l, _ = e.Value.(int)
			j += l
			ch = 'R'
		} else {
			l, _ = e.Value.(int)
			inv += l * j
			ch = 'L'
		}
	}

	if k > inv {
		fmt.Fprint(wr, "-1")
	} else {
		for ls.Len() > 2 {
			j = 0
			l = 0
			for e = ls.Front(); e != nil; e = e.Next() {
				x, _ = e.Value.(int)
				if j%2 == 0 && j > 0 {
					i, _ = e.Value.(int)
					ep = e.Prev()
					m, _ = ep.Value.(int)
					ls.InsertAfter(1, ep)
					ls.InsertBefore(1, e)
					if i-1 == 0 {
						if e.Next() != nil {
							e.Prev().Value = e.Prev().Value.(int) + e.Next().Value.(int)
							ls.Remove(e.Next())
						}
						e = e.Prev()
						ls.Remove(e.Next())
						x = e.Value.(int)
						j--
					} else {
						e.Value = i - 1
					}
					if m-1 == 0 {
						if ep.Next() != nil {
							ep.Prev().Value = ep.Prev().Value.(int) + ep.Next().Value.(int)
							ls.Remove(ep.Next())
						}
						ls.Remove(ep)
					} else {
						ep.Value = m - 1
					}
					// fmt.Fprintf(wr, "inv=%d k=%d\n", inv, k)
					if inv > k {
						arr = append(arr, l)
						inv--
					} else if inv == k {
						arr = append(arr, l)
						inv--
						k--
						if len(arr) > 0 {
							fmt.Fprintf(wr, "%d ", len(arr))
							for i = 0; i < len(arr); i++ {
								fmt.Fprintf(wr, "%d ", arr[i])
							}
							fmt.Fprintf(wr, "\n")
							arr = make([]int, 0)
						}
					} else {
						fmt.Fprintf(wr, " error ")
					}
				}
				l += x
				j++
			}
			if len(arr) > 0 {
				fmt.Fprintf(wr, "%d ", len(arr))
				for i = 0; i < len(arr); i++ {
					fmt.Fprintf(wr, "%d ", arr[i])
				}
				fmt.Fprintf(wr, "\n")
				arr = make([]int, 0)
			}
			k--
			// for e = ls.Front(); e != nil; e = e.Next() {
			// 	fmt.Fprintf(wr, "%d ", e.Value)
			// }
			// fmt.Fprintf(wr, "\n")
			wr.Flush()
		}
	}
}

package main

import (
	"bufio"
	"container/list"
	"fmt"
	"os"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	wr := bufio.NewWriter(os.Stdout)
	var n, m, k, i, j, inv, l, x int //, y, z int
	var arr []int
	var ch byte
	var ls list.List
	var e, ep *list.Element
	sc.Scan()
	fmt.Sscanf(sc.Text(), "%d", &n)
	sc.Scan()
	fmt.Sscanf(sc.Text(), "%d", &k)
	sc.Scan()
	ch = 'L'
	j = 0
	for i = 0; i < len(sc.Bytes()); i++ {
		if ch == sc.Bytes()[i] {
			j++
		} else {
			ls.PushBack(j)
			ch = sc.Bytes()[i]
			j = 1
		}
	}
	ls.PushBack(j)
	e = ls.Back()
	if ch == 'R' {
		e = e.Prev()
	}
	ch = 'L'
	j = 0
	for ; e != nil; e = e.Prev() {
		if ch == 'L' {
			l, _ = e.Value.(int)
			j += l
			ch = 'R'
		} else {
			l, _ = e.Value.(int)
			inv += l * j
			ch = 'L'
		}
	}

	if k > inv {
		fmt.Fprintf(wr, "-1\n")
	} else {
		for ls.Len() > 2 {
			j = 0
			l = 0
			for e = ls.Front(); e != nil; e = e.Next() {
				x, _ = e.Value.(int)
				if j%2 == 0 && j > 0 {
					i, _ = e.Value.(int)
					ep = e.Prev()
					m, _ = ep.Value.(int)
					ls.InsertAfter(1, ep)
					ls.InsertBefore(1, e)
					if i-1 == 0 {
						if e.Next() != nil {
							e.Prev().Value = e.Prev().Value.(int) + e.Next().Value.(int)
							ls.Remove(e.Next())
						}
						e = e.Prev()
						ls.Remove(e.Next())
						x = e.Value.(int)
						j--
					} else {
						e.Value = i - 1
					}
					if m-1 == 0 {
						if ep.Next() != nil {
							ep.Prev().Value = ep.Prev().Value.(int) + ep.Next().Value.(int)
							ls.Remove(ep.Next())
						}
						ls.Remove(ep)
					} else {
						ep.Value = m - 1
					}
					// fmt.Fprintf(wr, "inv=%d k=%d\n", inv, k)
					if inv > k {
						arr = append(arr, l)
						inv--
					} else if inv == k {
						arr = append(arr, l)
						inv--
						k--
						if len(arr) > 0 {
							fmt.Fprintf(wr, "%d ", len(arr))
							for i = 0; i < len(arr); i++ {
								fmt.Fprintf(wr, "%d ", arr[i])
							}
							fmt.Fprintf(wr, "\n")
							arr = make([]int, 0)
						}
					} else {
						fmt.Fprintf(wr, " error ")
					}
				}
				l += x
				j++
			}
			if len(arr) > 0 {
				fmt.Fprintf(wr, "%d ", len(arr))
				for i = 0; i < len(arr); i++ {
					fmt.Fprintf(wr, "%d ", arr[i])
				}
				fmt.Fprintf(wr, "\n")
				arr = make([]int, 0)
			}
			k--
			// for e = ls.Front(); e != nil; e = e.Next() {
			// 	fmt.Fprintf(wr, "%d ", e.Value)
			// }
			// fmt.Fprintf(wr, "\n")
			wr.Flush()
		}
	}
	wr.Flush()
}

package main

import (
	"bufio"
	"container/list"
	"fmt"
	"os"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	wr := bufio.NewWriter(os.Stdout)
	var n, m, k, i, j, inv, l, x int //, y, z int
	var arr []int
	var ch byte
	var ls list.List
	var e, ep *list.Element
	sc.Scan()
	fmt.Sscanf(sc.Text(), "%d", &n)
	sc.Scan()
	fmt.Sscanf(sc.Text(), "%d", &k)
	sc.Scan()
	ch = 'L'
	j = 0
	for i = 0; i < len(sc.Bytes()); i++ {
		if ch == sc.Bytes()[i] {
			j++
		} else {
			ls.PushBack(j)
			ch = sc.Bytes()[i]
			j = 1
		}
	}
	ls.PushBack(j)
	e = ls.Back()
	if ch == 'R' {
		e = e.Prev()
	}
	ch = 'L'
	j = 0
	for ; e != nil; e = e.Prev() {
		if ch == 'L' {
			l, _ = e.Value.(int)
			j += l
			ch = 'R'
		} else {
			l, _ = e.Value.(int)
			inv += l * j
			ch = 'L'
		}
	}

	if k > inv {
		fmt.Fprintf(wr, "-1\n")
	} else {
		for ls.Len() > 2 {
			j = 0
			l = 0
			for e = ls.Front(); e != nil; e = e.Next() {
				x, _ = e.Value.(int)
				if j%2 == 0 && j > 0 {
					i, _ = e.Value.(int)
					ep = e.Prev()
					m, _ = ep.Value.(int)
					ls.InsertAfter(1, ep)
					ls.InsertBefore(1, e)
					if i-1 == 0 {
						if e.Next() != nil {
							e.Prev().Value = e.Prev().Value.(int) + e.Next().Value.(int)
							ls.Remove(e.Next())
						}
						e = e.Prev()
						ls.Remove(e.Next())
						x = e.Value.(int)
						j--
					} else {
						e.Value = i - 1
					}
					if m-1 == 0 {
						if ep.Next() != nil {
							ep.Prev().Value = ep.Prev().Value.(int) + ep.Next().Value.(int)
							ls.Remove(ep.Next())
						}
						ls.Remove(ep)
					} else {
						ep.Value = m - 1
					}
					// fmt.Fprintf(wr, "inv=%d k=%d\n", inv, k)
					if inv > k {
						arr = append(arr, l)
						inv--
					} else if inv == k {
						arr = append(arr, l)
						inv--
						k--
						if len(arr) > 0 {
							fmt.Fprintf(wr, "%d ", len(arr))
							for i = 0; i < len(arr); i++ {
								fmt.Fprintf(wr, "%d ", arr[i])
							}
							fmt.Fprintf(wr, "\n")
							arr = make([]int, 0)
						}
					} else {
						fmt.Fprintf(wr, " error ")
					}
				}
				l += x
				j++
			}
			if len(arr) > 0 {
				fmt.Fprintf(wr, "%d ", len(arr))
				for i = 0; i < len(arr); i++ {
					fmt.Fprintf(wr, "%d ", arr[i])
				}
				fmt.Fprintf(wr, "\n")
				arr = make([]int, 0)
			}
			k--
			// for e = ls.Front(); e != nil; e = e.Next() {
			// 	fmt.Fprintf(wr, "%d ", e.Value)
			// }
			// fmt.Fprintf(wr, "\n")
			wr.Flush()
		}
	}
}

package main

import (
	"bufio"
	"container/list"
	"fmt"
	"os"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	wr := bufio.NewWriter(os.Stdout)
	var n, m, k, i, j, inv, l, x int //, y, z int
	var arr []int
	var ch byte
	var ls list.List
	var e, ep *list.Element
	sc.Scan()
	fmt.Sscanf(sc.Text(), "%d", &n)
	sc.Scan()
	fmt.Sscanf(sc.Text(), "%d", &k)
	sc.Scan()
	ch = 'L'
	j = 0
	for i = 0; i < len(sc.Bytes()); i++ {
		if ch == sc.Bytes()[i] {
			j++
		} else {
			ls.PushBack(j)
			ch = sc.Bytes()[i]
			j = 1
		}
	}
	ls.PushBack(j)
	e = ls.Back()
	if ch == 'R' {
		e = e.Prev()
	}
	ch = 'L'
	j = 0
	for ; e != nil; e = e.Prev() {
		if ch == 'L' {
			l, _ = e.Value.(int)
			j += l
			ch = 'R'
		} else {
			l, _ = e.Value.(int)
			inv += l * j
			ch = 'L'
		}
	}

	if k > inv {
		fmt.Fprint(wr, "-1")
	} else {
		for ls.Len() > 2 {
			j = 0
			l = 0
			for e = ls.Front(); e != nil; e = e.Next() {
				x, _ = e.Value.(int)
				if j%2 == 0 && j > 0 {
					i, _ = e.Value.(int)
					ep = e.Prev()
					m, _ = ep.Value.(int)
					ls.InsertAfter(1, ep)
					ls.InsertBefore(1, e)
					if i-1 == 0 {
						if e.Next() != nil {
							e.Prev().Value = e.Prev().Value.(int) + e.Next().Value.(int)
							ls.Remove(e.Next())
						}
						e = e.Prev()
						ls.Remove(e.Next())
						x = e.Value.(int)
						j--
					} else {
						e.Value = i - 1
					}
					if m-1 == 0 {
						if ep.Next() != nil {
							ep.Prev().Value = ep.Prev().Value.(int) + ep.Next().Value.(int)
							ls.Remove(ep.Next())
						}
						ls.Remove(ep)
					} else {
						ep.Value = m - 1
					}
					// fmt.Fprintf(wr, "inv=%d k=%d\n", inv, k)
					if inv > k {
						arr = append(arr, l)
						inv--
					} else if inv == k {
						arr = append(arr, l)
						inv--
						k--
						if len(arr) > 0 {
							fmt.Fprintf(wr, "%d ", len(arr))
							for i = 0; i < len(arr); i++ {
								fmt.Fprintf(wr, "%d ", arr[i])
							}
							fmt.Fprintf(wr, "\n")
							arr = make([]int, 0)
						}
					} else {
						fmt.Fprintf(wr, " error ")
					}
				}
				l += x
				j++
			}
			if len(arr) > 0 {
				fmt.Fprintf(wr, "%d ", len(arr))
				for i = 0; i < len(arr); i++ {
					fmt.Fprintf(wr, "%d ", arr[i])
				}
				fmt.Fprintf(wr, "\n")
				arr = make([]int, 0)
			}
			k--
			// for e = ls.Front(); e != nil; e = e.Next() {
			// 	fmt.Fprintf(wr, "%d ", e.Value)
			// }
			// fmt.Fprintf(wr, "\n")
		}
	}
	wr.Flush()
}

package main

import (
	"bufio"
	"container/list"
	"fmt"
	"os"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	wr := bufio.NewWriter(os.Stdout)
	var n, m, k, i, j, inv, l, x int //, y, z int
	var arr []int
	var ch byte
	var ls list.List
	var e, ep *list.Element
	sc.Scan()
	fmt.Sscanf(sc.Text(), "%d", &n)
	sc.Scan()
	fmt.Sscanf(sc.Text(), "%d", &k)
	sc.Scan()
	ch = 'L'
	j = 0
	for i = 0; i < len(sc.Bytes()); i++ {
		if ch == sc.Bytes()[i] {
			j++
		} else {
			ls.PushBack(j)
			ch = sc.Bytes()[i]
			j = 1
		}
	}
	ls.PushBack(j)
	e = ls.Back()
	if ch == 'R' {
		e = e.Prev()
	}
	ch = 'L'
	j = 0
	for ; e != nil; e = e.Prev() {
		if ch == 'L' {
			l, _ = e.Value.(int)
			j += l
			ch = 'R'
		} else {
			l, _ = e.Value.(int)
			inv += l * j
			ch = 'L'
		}
	}

	if k > inv {
		fmt.Fprintf(wr, "-1\n")
	} else {
		for ls.Len() > 2 {
			j = 0
			l = 0
			for e = ls.Front(); e != nil; e = e.Next() {
				x, _ = e.Value.(int)
				if j%2 == 0 && j > 0 {
					i, _ = e.Value.(int)
					ep = e.Prev()
					m, _ = ep.Value.(int)
					ls.InsertAfter(1, ep)
					ls.InsertBefore(1, e)
					if i-1 == 0 {
						if e.Next() != nil {
							e.Prev().Value = e.Prev().Value.(int) + e.Next().Value.(int)
							ls.Remove(e.Next())
						}
						e = e.Prev()
						ls.Remove(e.Next())
						x = e.Value.(int)
						j--
					} else {
						e.Value = i - 1
					}
					if m-1 == 0 {
						if ep.Next() != nil {
							ep.Prev().Value = ep.Prev().Value.(int) + ep.Next().Value.(int)
							ls.Remove(ep.Next())
						}
						ls.Remove(ep)
					} else {
						ep.Value = m - 1
					}
					// fmt.Fprintf(wr, "inv=%d k=%d\n", inv, k)
					if inv > k {
						arr = append(arr, l)
						inv--
					} else if inv == k {
						arr = append(arr, l)
						inv--
						k--
						if len(arr) > 0 {
							fmt.Fprintf(wr, "%d ", len(arr))
							for i = 0; i < len(arr); i++ {
								fmt.Fprintf(wr, "%d ", arr[i])
								if wr.Available() < 50 {
									wr.Flush()
								}
							}
							fmt.Fprintf(wr, "\n")
							arr = make([]int, 0)
						}
					} else {
						fmt.Fprintf(wr, " error ")
					}
				}
				l += x
				j++
			}
			if len(arr) > 0 {
				fmt.Fprintf(wr, "%d ", len(arr))
				for i = 0; i < len(arr); i++ {
					fmt.Fprintf(wr, "%d ", arr[i])
					if wr.Available() < 50 {
						wr.Flush()
					}
				}
				fmt.Fprintf(wr, "\n")
				arr = make([]int, 0)
			}
			k--
			// for e = ls.Front(); e != nil; e = e.Next() {
			// 	fmt.Fprintf(wr, "%d ", e.Value)
			// }
			// fmt.Fprintf(wr, "\n")
			wr.Flush()
		}
	}
	wr.Flush()
}

package main

import (
	"bufio"
	"container/list"
	"fmt"
	"os"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	wr := bufio.NewWriter(os.Stdout)
	var n, m, k, i, j, inv, l, x int //, y, z int
	var arr []int
	var ch byte
	var ls list.List
	var e, ep *list.Element
	sc.Scan()
	fmt.Sscanf(sc.Text(), "%d", &n)
	sc.Scan()
	fmt.Sscanf(sc.Text(), "%d", &k)
	sc.Scan()
	ch = 'L'
	j = 0
	for i = 0; i < len(sc.Bytes()); i++ {
		if ch == sc.Bytes()[i] {
			j++
		} else {
			ls.PushBack(j)
			ch = sc.Bytes()[i]
			j = 1
		}
	}
	ls.PushBack(j)
	e = ls.Back()
	if ch == 'R' {
		e = e.Prev()
	}
	ch = 'L'
	j = 0
	for ; e != nil; e = e.Prev() {
		if ch == 'L' {
			l, _ = e.Value.(int)
			j += l
			ch = 'R'
		} else {
			l, _ = e.Value.(int)
			inv += l * j
			ch = 'L'
		}
	}

	if k > inv {
		fmt.Fprint(wr, "-1")
	} else {
		for ls.Len() > 2 {
			j = 0
			l = 0
			for e = ls.Front(); e != nil; e = e.Next() {
				x, _ = e.Value.(int)
				if j%2 == 0 && j > 0 {
					i, _ = e.Value.(int)
					ep = e.Prev()
					m, _ = ep.Value.(int)
					ls.InsertAfter(1, ep)
					ls.InsertBefore(1, e)
					if i-1 == 0 {
						if e.Next() != nil {
							e.Prev().Value = e.Prev().Value.(int) + e.Next().Value.(int)
							ls.Remove(e.Next())
						}
						e = e.Prev()
						ls.Remove(e.Next())
						x = e.Value.(int)
						j--
					} else {
						e.Value = i - 1
					}
					if m-1 == 0 {
						if ep.Next() != nil {
							ep.Prev().Value = ep.Prev().Value.(int) + ep.Next().Value.(int)
							ls.Remove(ep.Next())
						}
						ls.Remove(ep)
					} else {
						ep.Value = m - 1
					}
					// fmt.Fprintf(wr, "inv=%d k=%d\n", inv, k)
					if inv > k {
						arr = append(arr, l)
						inv--
					} else if inv == k {
						arr = append(arr, l)
						inv--
						k--
						if len(arr) > 0 {
							fmt.Fprintf(wr, "%d ", len(arr))
							for i = 0; i < len(arr); i++ {
								fmt.Fprintf(wr, "%d ", arr[i])
							}
							fmt.Fprintf(wr, "\n")
							arr = make([]int, 0)
						}
					} else {
						fmt.Fprintf(wr, " error ")
					}
				}
				l += x
				j++
			}
			if len(arr) > 0 {
				fmt.Fprintf(wr, "%d ", len(arr))
				for i = 0; i < len(arr); i++ {
					fmt.Fprintf(wr, "%d ", arr[i])
				}
				fmt.Fprintf(wr, "\n")
				arr = make([]int, 0)
			}
			// for e = ls.Front(); e != nil; e = e.Next() {
			// 	fmt.Fprintf(wr, "%d ", e.Value)
			// }
			// fmt.Fprintf(wr, "\n")
		}
	}
	wr.Flush()
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

const N = 3010
var n, k int
var s string
var ways [][]int
var ret [][]int
var t [N]int

func min(a int, b int) int {
	if a < b {
		return a
	}
	return b
}

func main()  {
	var reader = bufio.NewReader(os.Stdin)
	var writer = bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	fmt.Fscanf(reader, "%d %d\n", &n, &k)
	fmt.Fscanf(reader, "%s", &s)
	ways = make([][]int, 0)
	for i := 0; i < n; i++ {
		if s[i] == 'L' {
			t[i] = 1
		}
	}

	var total = 0
	for true {
		var move = make([]int, 0)

		for i := 0; i < n - 1; i++ {
			if t[i] == 0 && t[i + 1] == 1 {
				move = append(move, i+1)
				t[i], t[i+1] = t[i+1], t[i]
				i++
				total++
			}
		}
		if len(move) == 0 {
			break
		}

		ways = append(ways, move)
	}

	if total < k || k < len(ways) {
		fmt.Fprintf(writer, "-1")
		return
	}

	ret = make([][]int, 0)
	var gt = k - len(ways)

	for _, dt := range ways {
		var z = min(gt, len(dt) - 1)
		gt -= z
		for i := 0; i < z; i++ {
			ret = append(ret, dt[i:i])
		}
		ret = append(ret, dt[z:])
	}

	for _, dt := range ret {
		fmt.Fprintf(writer, "%d ", len(dt))
		for _, z := range dt {
			fmt.Fprintf(writer, "%d ", z)
		}
		fmt.Fprintf(writer, "\n")
	}

}