import java.io.*;
import java.text.*;
import java.util.*;
import java.math.*;
public class template {
	public static void main(String[] args) throws Exception {
		new template().run();
	}
	public void run() throws Exception {
		FastScanner f = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int asdf = f.nextInt();
		while(asdf-->0) {
			int n = f.nextInt(), k = f.nextInt();
			int[] a = new int[n], b = new int[n];
			for(int i = 0; i < n; i++) {
				a[i] = f.nextInt();
				b[i] = f.nextInt();
			}
			int best = -1;
			int[] bmoves = new int[0];
			int[] temp = new int[4];
			for(int end = 0; end < n; end++) {
				int[] moves = new int[2*n-k];
				int mc = 0;
				ArrayList<Pair> al = new ArrayList<>();
				int ans = 0;
				boolean[] used = new boolean[n];
				used[end] = true;
				for(int qwer = 0;qwer < n-1; qwer++) {
					int min = -1;
					for(int i = 0; i < n; i++) {
						if(used[i]) continue;
						if(min == -1) min = i;
						else {
							int v1, v2;
							{
								v1 = a[min]+a[i]+b[min];
								temp[0] = a[min];
								temp[1] = a[i]+b[min];
								if(al.size() >= 1) temp[2] = al.get(0).a+b[i]+b[min];
								else temp[2] = 2147483647;
								if(al.size() >= 2) temp[3] = al.get(1).a+b[i]+b[min];
								else temp[3] = 2147483647;
								Arrays.sort(temp);
								for(int j = 0; al.size()+2-j >= k; j++)
									v1 -= temp[j];
							}
							{
								v2 = a[min]+a[i]+b[i];
								temp[0] = a[min]+b[i];
								temp[1] = a[i];
								if(al.size() >= 1) temp[2] = al.get(0).a+b[i]+b[min];
								else temp[2] = 2147483647;
								if(al.size() >= 2) temp[3] = al.get(1).a+b[i]+b[min];
								else temp[3] = 2147483647;
								Arrays.sort(temp);
								for(int j = 0; al.size()+2-j >= k; j++)
									v2 -= temp[j];
							}
							if(v2 < v1) min = i;
						}
					}
					used[min] = true;
					moves[mc++] = min+1;
					boolean add = false;
					for(int i = 0; i < al.size(); i++) {
						if(!add && al.get(i).a+b[min] > a[min]) {
							al.add(i,new Pair(a[min],min));
							add = true;
						}
						else al.get(i).a += b[min];
					}
					if(!add) al.add(new Pair(a[min],min));
					ans += a[min] + (al.size()-1)*b[min];
					if(al.size() >= k) {
						Pair p = al.remove(0);
						moves[mc++] = -(p.b+1);
						ans -= p.a;
					}
				}
				ans += a[end] + (k-1)*b[end];
				moves[mc] = end+1;
				if(ans > best) {
					best = ans;
					bmoves = moves;
				}
			}
			out.println(bmoves.length);
			for(int i : bmoves)
				out.print(i + " ");
			out.println();
		}
		out.flush();
	}
	class Pair implements Comparable<Pair> {
		int a, b;
		public Pair(int a, int b) {
			this.a = a;
			this.b = b;
		}
		public int compareTo(Pair p) {
			return Integer.compare(a, p.a);
		}
		public String toString() {
			return a + "," + b;
		}
	}
    static class FastScanner {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        public FastScanner() {
            reader = new BufferedReader(new InputStreamReader(System.in), 32768);
            tokenizer = null;
        }
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
        	return Long.parseLong(next());
        }
        public double nextDouble() {
        	return Double.parseDouble(next());
        }
        public String nextLine() {
        	try {
        		return reader.readLine();
        	} catch(IOException e) {
        		throw new RuntimeException(e);
        	}
        }
    }
}