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

public class rgb_nn {

    static void solve() throws IOException {
        int n = nextInt();
        int toGet = nextInt();
        int[][][] a = new int[256][256][256];
        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();
            a[red[i]][green[i]][blue[i]]++;
        }
        for (int i = 0; i < 256; i++) {
            for (int j = 0; j < 256; j++) {
                for (int k = 1; k < 256; k++) {
                    a[i][j][k] += a[i][j][k - 1];
                }
            }
        }
        for (int i = 0; i < 256; i++) {
            for (int j = 1; j < 256; j++) {
                for (int k = 0; k < 256; k++) {
                    a[i][j][k] += a[i][j - 1][k];
                }
            }
        }
        for (int i = 1; i < 256; i++) {
            for (int j = 0; j < 256; j++) {
                for (int k = 0; k < 256; k++) {
                    a[i][j][k] += a[i - 1][j][k];
                }
            }
        }
        int l = -1;
        int r = 257;
        int ansI = -1;
        int ansJ = -1;
        int ansK = -1;
        all:
        while (l < r - 1) {
            int mid = l + r >> 1;
            for (int i = 0; i + mid <= 256; i++) {
                for (int j = 0; j + mid <= 256; j++) {
                    for (int k = 0; k + mid <= 256; k++) {
                        if (sum(a, i, i + mid, j, j + mid, k, k + mid) >= toGet) {
                            r = mid;
                            ansI = i;
                            ansJ = j;
                            ansK = k;
                            continue all;
                        }
                    }
                }
            }
            l = mid;
        }
        for (int i = 0; toGet > 0 && i < n; i++) {
            if (red[i] < ansI || red[i] >= ansI + r || green[i] < ansJ || green[i] >= ansJ + r || blue[i] < ansK || blue[i] >= ansK + r) {
                continue;
            }
            out.print(i + 1);
            --toGet;
            if (toGet != 0) {
                out.print(' ');
            }
        }
        out.println();
    }

    static int sum(int[][][] a, int x1, int x2, int y1, int y2, int z1, int z2) {
        return get(a, x2 - 1, y2 - 1, z2 - 1) - get(a, x1 - 1, y2 - 1, z2 - 1) - get(a, x2 - 1, y1 - 1, z2 - 1) - get(a, x2 - 1, y2 - 1, z1 - 1)
                + get(a, x1 - 1, y1 - 1, z2 - 1) + get(a, x1 - 1, y2 - 1, z1 - 1) + get(a, x2 - 1, y1 - 1, z1 - 1) - get(a, x1 - 1, y1 - 1, z1 - 1);
    }

    static int get(int[][][] a, int x, int y, int z) {
        if (x < 0 || y < 0 || z < 0) {
            return 0;
        }
        return a[x][y][z];
    }

    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());
    }
}
