// Arup Guha
// 4/26/2020
// Solution to 2020 FHSPS Problem: Board Game

import java.util.*;

public class boardgame {

	public static void main(String[] args) {
	
		Scanner stdin = new Scanner(System.in);
		int nC = stdin.nextInt();
		
		// Process cases.
		for (int loop=0; loop<nC; loop++) {
		
			// Get basic parameters.
			int numSq = stdin.nextInt();
			int numPlayers = stdin.nextInt();
			int moves = stdin.nextInt();
			
			// Stores where each player is.
			int[] loc = new int[numPlayers];
			
			// Stores the number of pieces on each square.
			int[] board = new int[numSq];
			board[0] = numPlayers;
			
			// Simulate each move.
			for (int i=0; i<moves; i++) {
			
				// Player moving.
				int player = i%numPlayers;
				
				// Get the next dice roll.
				int roll = stdin.nextInt();
				
				// Store how many squares we've moved and our current location.
				int turnMoves = 0, curPos = loc[player];
				
				// One less player at this position.
				board[curPos]--;
				
				// Simulate.
				while (turnMoves < roll) {
				
					// Advance.
					curPos = (curPos + 1)%numSq;
					
					// Add 1 if this is unoccupied.
					if (board[curPos] == 0) turnMoves++;
				}
				
				// Put the player here.
				loc[player] = curPos;
				board[curPos]++;
			}
			
			// This is what we need to print.
			for (int i=0; i<numPlayers; i++)
				System.out.println(loc[i]);
		}
	}
}