문제
Farmer John believes he has made a major breakthrough in algorithm design: he claims to have found a nearly linear time algorithm for the 3SUM problem, an algorithmic problem famous for the fact that no known solution exists running in substantially better than quadratic time. One formulation of the 3SUM problem is the following: given an array
To test Farmer John's claim, Bessie has provided an array
Unfortunately, Farmer John has just discovered a flaw in his algorithm. He is confident that he can fix the algorithm, but in the meantime, he asks that you help him pass Bessie's test!
SCORING:
Test cases 2-4 satisfy
N\le 500. Test cases 5-7 satisfy
N\le 2000. Test cases 8-15 satisfy no additional constraints.
Problem credits: Dhruv Rohatgi
입력
The first line contains two space-separated integers
It is guaranteed that
출력
The output should consist of
예제1
7 3
2 0 -1 1 -2 3 3
1 5
2 4
1 7
2
1
4
For the first query, the possible triples are