Under construction

Still being built. Things may change

The Crow's Last Attack

Time limit2sMemory limit512 MB

Summary
Simulate a crow that attacks around a circular line of enemies, reversing on kills, and report which enemy takes the last attack.
Level

Easy3 of 10

Topics
Simulation, Implementation
Solved
No attempts yet

Problem

A hero summons a crow that attacks a line of enemies.

The line holds nn enemies, numbered 11 to nn from left to right. Enemy ii starts with hih_i hitpoints. The two ends of the line are connected. Moving right past enemy nn leads to enemy 11, and moving left past enemy 11 leads to enemy nn.

The crow starts on enemy 11 facing right. One attack subtracts CC hitpoints from the enemy the crow stands on. An enemy whose hitpoints drop to 00 or below is dead.

After every attack the crow follows these rules.

  1. If the attack killed the enemy, the crow immediately reverses its direction.
  2. The crow then moves in its current direction to the nearest enemy that is still alive, passing over dead enemies without attacking them.

The crow attacks n+5n + 5 times. If every enemy is dead before that count is reached, the crow stops attacking.

Print the number of the enemy that receives the crow's last attack.

Input

The first line contains the number of test cases TT (1≤T≤1001 \le T \le 100).

The first line of each test case contains two space-separated integers nn and CC, the number of enemies and the crow's damage (2≤n≤322 \le n \le 32, 32≤C≤12832 \le C \le 128). The next line contains nn integers h1,h2,…,hnh_1, h_2, \dots, h_n, the initial hitpoints of the enemies in order (1≤hi≤100001 \le h_i \le 10000).

Output

For each test case, print the number of the enemy that receives the crow's last attack on its own line.

Examples2

  1. Example 1

    Input
    2
    3 100
    200 150 200
    8 80
    200 100 100 100 100 80 160 200
    
    Expected output
    2
    3
    
  2. Example 2

    Input
    1
    2 128
    100 100
    
    Expected output
    2