Dish

아직 제출이 없습니다시간 제한2초메모리 제한1024 MB

문제

The chef is preparing mm dishes, and each dish uses kk grams of ingredients. As a result, the chef has bought nn ingredients, and the ingredients are numbered 1,2,,n1, 2, \dots, n. The ii-th ingredient weighs d_id\_i grams. The sum of weights of all nn ingredients is exactly m×km \times k grams. d_id\_i and kk are positive integers.

An ingredient may be used in multiple dishes. However, each dish may use at most 2 ingredients. Now you are asked to decide if there exists a valid way to prepare the mm dishes. More formally, the final plan shall satisfy the following requirements:

  1. Prepare mm dishes in total.
  2. Each dish uses at most 2 ingredients.
  3. Each dish uses exactly kk grams of ingredients.
  4. For each ingredient used in a given dish, the amount used is a positive integer measured in grams.
  5. All of the nn ingredients will be completely utilized.

If there exists a feasible solution, you should output a detailed plan.

입력

In this problem, each test case may have multiple instances. The first line is an integer TT denoting the number of instances. For each instance, the first line contains three positive integers n,m,kn,m,k denoting the number of ingredients, the number of dishes to prepare, and the amount of ingredients each dish uses. The second line contains nn integers, and the ii-th integer denotes there are a_ia\_i grams of ingredient ii.

출력

For each instance, if there is no feasible solution, output -1. Otherwise, you need to output mm lines, and each line specifies the way to prepare a dish. Depending on the number of ingredients used in the dish, a line shall be in one of the following two formats:

  • a line containing two integers ii and xx denoting the dish will use xx grams of ingredient ii. Here, 1in1 \le i \le n and x=kx = k.
  • a line containing four integers i,x,j,yi,x,j,y denoting the dish will use xx grams of ingredient ii and yy grams of ingredient jj. Here, 1i,jn1 \le i,j \le niji \ne jx+y=kx+y = kx,y>0x, y > 0.

Your answer will be checked by a special judge. Therefore, if there are multiple feasible solutions, you may print any solution. You should make sure the output is in the correct format, and two adjacent integers in a line are separated by a single space. Finally, your output shall not contain any extra characters.

힌트

1T101 \le T \le 101n5001 \le n \le 500n2m5000n-2 \le m \le 5000m1m \ge 1, 1k50001 \le k \le 5000_i=1nd_i=m×k\sum\limits\_{i=1}^n d\_i = m \times k.