import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; class Animal{ char name; int startZoo; int endZoo; public Animal(char t, int s, int d){ this.name = t; this.startZoo = s; this.endZoo = d; } } public class Solution { static int[] minimumZooNumbers(int m, int n, char[] t, int[] s, int[] d) { //for n: create new animal using t,s,d //sort animal[] List animals = new ArrayList(); for(int i = 0; i < n; i++){ animals.add(new Animal(t[i], s[i], d[i])); } // Return a list of length n consisting of the answers //order animals in [] according to starting zoos //[] for whether or not to try to pick up animal //for all posible [] ///zoo = 0 ///if has animal: check to try pick up ///try pick up: ////if has space & not afraid: pick up ///if animal in truck goes to zoo: drop off ///add one to total counter and log zoo to min zoo; } public static void main(String[] args) { Scanner in = new Scanner(System.in); int cases = in.nextInt(); for(int a0 = 0; a0 < cases; a0++){ int m = in.nextInt(); int n = in.nextInt(); char[] t = new char[n]; for(int t_i = 0; t_i < n; t_i++){ t[t_i] = in.next().charAt(0); } int[] s = new int[n]; for(int s_i = 0; s_i < n; s_i++){ s[s_i] = in.nextInt(); } int[] d = new int[n]; for(int d_i = 0; d_i < n; d_i++){ d[d_i] = in.nextInt(); } int[] result = minimumZooNumbers(m, n, t, s, d); for (int i = 0; i < result.length; i++) { System.out.print(result[i] + (i != result.length - 1 ? " " : "")); } System.out.println(""); } in.close(); } }