import java.io.*;
import java.util.*;

public class rgb_nn_tl1 {

    static void solve() throws IOException {
        int n = nextInt();
        int toGet = nextInt();
        int[] red = new int[n];
        int[] green = new int[n];
        int[] blue = new int[n];
        for (int i = 0; i < n; i++) {
            red[i] = nextInt();
            green[i] = nextInt();
            blue[i] = nextInt();
        }
        int answer = Integer.MAX_VALUE;
        int ansMask = -1;
        for (int mask = 0; mask < 1 << n; mask++) {
            if (Integer.bitCount(mask) != toGet) continue;
            int current = 0;
            for (int i = 0; i < n; i++) {
                if (((mask >> i) & 1) == 0) continue;
                for (int j = i + 1; j < n; j++) {
                    if (((mask >> j) & 1) == 0) continue;
                    current = Math.max(current, Math.abs(red[i] - red[j]));
                    current = Math.max(current, Math.abs(green[i] - green[j]));
                    current = Math.max(current, Math.abs(blue[i] - blue[j]));
                }
            }
            if (current < answer) {
                answer = current;
                ansMask = mask;
            }
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            if (((ansMask >> i) & 1) == 1) {
                sb.append(i + 1).append(' ');
            }
        }
        sb.setLength(sb.length() - 1);
        out.println(sb);
    }

    static StringTokenizer tokenizer;
    static BufferedReader reader;
    static PrintWriter out;

    public static void main(String[] args) throws IOException {
        reader = new BufferedReader(new FileReader("rgb.in"));
        out = new PrintWriter("rgb.out");
        solve();
        out.close();
        reader.close();
    }

    static String next() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            String line = reader.readLine();
            if (line == null) {
                return null;
            }
            tokenizer = new StringTokenizer(line);
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
}
