import java.io.*;
import java.util.*;
import java.awt.*;
import java.math.*;

public class Main {
	static BufferedReader br = new BufferedReader( new InputStreamReader(System.in) );
	static StringTokenizer st = new StringTokenizer("");
	static String next()	throws Exception	{
		while	( !st.hasMoreTokens() )	st = new StringTokenizer( br.readLine() );
		return	st.nextToken();
	}

	public static void main(String [] asda)	throws Exception	{
	//	br = new BufferedReader( new InputStreamReader( new FileInputStream("in.txt") ) );
	//	PrintWriter out = new PrintWriter( new BufferedOutputStream( new FileOutputStream("out.txt") ) );
		PrintWriter out = new PrintWriter( new BufferedOutputStream(System.out) );
		//
		int N = Integer.parseInt( next() );
		int k = Integer.parseInt( next() );
		int v [] = new int [N];
		for (int i = 0; i < N; i++)	{
			v[i] = Integer.parseInt( next() );
		}
		int min = Integer.MAX_VALUE;
		int index = 1;
		int i, curr, j = 0;
		try	{
		for (i = 0; i < k; i++)	{
			curr = v[i];
			for (j = i + k;	j != i && curr < min; j = (j + k) % N )	{
				curr += v[j];
			}
			if	( j == i && curr < min )	{
				index = i + 1;
				min = curr;
			}
		}
		}	catch (Exception e)	{}
		out.println( index );
		out.flush();
	//	br.close();
	//	out.close();
	}
}

/*

*/


import java.io.*;
import java.util.*;
import java.awt.*;
import java.math.*;

public class Main {
	static BufferedReader br = new BufferedReader( new InputStreamReader(System.in) );
	static StringTokenizer st = new StringTokenizer("");
	static String next()	throws Exception	{
		while	( !st.hasMoreTokens() )	st = new StringTokenizer( br.readLine() );
		return	st.nextToken();
	}

	public static void main(String [] asda)	throws Exception	{
	//	br = new BufferedReader( new InputStreamReader( new FileInputStream("in.txt") ) );
	//	PrintWriter out = new PrintWriter( new BufferedOutputStream( new FileOutputStream("out.txt") ) );
		PrintWriter out = new PrintWriter( new BufferedOutputStream(System.out) );
		//
		int N = Integer.parseInt( next() );
		int k = Integer.parseInt( next() );
		int v [] = new int [N];
		for (int i = 0; i < N; i++)	{
			v[i] = Integer.parseInt( next() );
		}
		int min = Integer.MAX_VALUE;
		int index = 0;
		for (int i = 0; i < k; i++)	{
			int curr = v[i], j = -1;
			for (j = i + k;	j != i && curr < min; j = (j + k) % N )	{
				curr += v[j];
			}
			if	( j == i && curr < min )	{
				index = i;
				min = curr;
			}
		}
		out.println( index + 1 );
		out.flush();
		br.close();
		out.close();
	}
}


import java.io.*;
import java.util.*;
import java.awt.*;
import java.math.*;

public class Main {
	static BufferedReader br = new BufferedReader( new InputStreamReader(System.in) );
	static StringTokenizer st = new StringTokenizer("");
	static String next()	throws Exception	{
		while	( !st.hasMoreTokens() )	st = new StringTokenizer( br.readLine() );
		return	st.nextToken();
	}

	public static void main(String [] asda)	throws Exception	{
	//	br = new BufferedReader( new InputStreamReader( new FileInputStream("in.txt") ) );
	//	PrintWriter out = new PrintWriter( new BufferedOutputStream( new FileOutputStream("out.txt") ) );
		PrintWriter out = new PrintWriter( new BufferedOutputStream(System.out) );
		//
		int N = Integer.parseInt( next() );
		int k = Integer.parseInt( next() );
		long v [] = new long [N];
	//	try	{
		for (int i = 0; i < N; i++)	{
			v[i] = Long.parseLong( next() );
		}
	//	}	catch (Exception e)	{}
		long min = Long.MAX_VALUE;
		long curr;
		int index = 1;
		int i, j = 0;
		for (i = 0; i < k; i++)	{
			curr = v[i];
			for (j = i + k;	j != i && curr < min; j = (j + k) % N )	{
				curr += v[j];
			}
			if	( j == i && curr < min )	{
				index = i + 1;
				min = curr;
			}
		}
		out.println( index );
		out.flush();
	//	br.close();
	//	out.close();
	}
}

/*

*/


//package round214;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class B {
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	void solve()
	{
		int n = ni(), K = ni();
		int[] a = na(n);
		for(int i = K, j = 0;i < n;i++,j++){
			if(j == K)j = 0;
			a[j] += a[i];
		}
		int min = Integer.MAX_VALUE;
		int maxi = -1;
		for(int i = 0;i < K;i++){
			if(a[i] < min){
				min = a[i];
				maxi = i;
			}
		}
		out.println(maxi + 1);
	}

	void run() throws Exception
	{
		is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}

	public static void main(String[] args) throws Exception { new B().run(); }

	private byte[] inbuf = new byte[1024];
	private int lenbuf = 0, ptrbuf = 0;

	private int readByte()
	{
		if(lenbuf == -1)throw new InputMismatchException();
		if(ptrbuf >= lenbuf){
			ptrbuf = 0;
			try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
			if(lenbuf <= 0)return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
	private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }

	private double nd() { return Double.parseDouble(ns()); }
	private char nc() { return (char)skip(); }

	private String ns()
	{
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while(!(isSpaceChar(b))){ // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b))){
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m)
	{
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}

	private int[] na(int n)
	{
		int[] a = new int[n];
		for(int i = 0;i < n;i++)a[i] = ni();
		return a;
	}

	private int ni()
	{
		int num = 0, b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl()
	{
		long num = 0;
		int b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	private void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}


package round214;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class B {
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	void solve()
	{
		int n = ni(), K = ni();
		int[] a = na(n);
		for(int i = K, j = 0;i < n;i++,j++){
			if(j == K)j = 0;
			a[j] += a[i];
		}
		int min = Integer.MAX_VALUE;
		int maxi = -1;
		for(int i = 0;i < K;i++){
			if(a[i] < min){
				min = a[i];
				maxi = i;
			}
		}
		out.println(maxi + 1);
	}

	void run() throws Exception
	{
		is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}

	public static void main(String[] args) throws Exception { new B().run(); }

	private byte[] inbuf = new byte[1024];
	private int lenbuf = 0, ptrbuf = 0;

	private int readByte()
	{
		if(lenbuf == -1)throw new InputMismatchException();
		if(ptrbuf >= lenbuf){
			ptrbuf = 0;
			try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
			if(lenbuf <= 0)return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
	private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }

	private double nd() { return Double.parseDouble(ns()); }
	private char nc() { return (char)skip(); }

	private String ns()
	{
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while(!(isSpaceChar(b))){ // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b))){
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m)
	{
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}

	private int[] na(int n)
	{
		int[] a = new int[n];
		for(int i = 0;i < n;i++)a[i] = ni();
		return a;
	}

	private int ni()
	{
		int num = 0, b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl()
	{
		long num = 0;
		int b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	private void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}


import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Scanner;
import java.lang.*;

public class D {

    public static void main(String[] args){
        D a = new D();
        a.run();
    }

    Scanner sc = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);

    void run(){
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] mas = new int[100010];
        for (int i = 1; i <= n; i++){
            mas[i % k] += sc.nextInt();
        }
        int min = 999999999;
        int value = 0;
        for (int i = 1; i < k; i++){
            if (mas[i] < min){
                value = i;
                min = mas[i];
            }
        }
        if (mas[0] < min){
            value = 0;
        }
        if (value == 0) out.println(k); else
        out.println( value);
        out.flush();
    }

}


import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Scanner;
import java.lang.*;

public class D {

    public static void main(String[] args){
        D a = new D();
        a.run();
    }

    Scanner sc = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);

    void run(){
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] mas = new int[100010];
        for (int i = 1; i <= n; i++){
            mas[i % k] += sc.nextInt();
        }
        int min = 999999999;
        int value = 0;
        for (int i = 0; i < k; i++){
            if (mas[i] < min){
                value = i;
                min = mas[i];
            }
        }
        if (value == 0) out.println(n); else
        out.println((n + value) % (n));
        out.flush();
    }

}


import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Scanner;
import java.lang.*;

public class D {

    public static void main(String[] args){
        D a = new D();
        a.run();
    }

    Scanner sc = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);

    void run(){
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] mas = new int[100010];
        for (int i = 1; i <= n; i++){
            mas[i % k] += sc.nextInt();
        }
        int min = 999999999;
        int value = 0;
        for (int i = 0; i < k; i++){
            if (mas[i] < min){
                value = i;
                min = mas[i];
            }
        }
        if (value == 0) out.println(k); else
        out.println((n + value) % (n));
        out.flush();
    }

}


import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.concurrent.ArrayBlockingQueue;

public class B
{
        String line;
        StringTokenizer inputParser;
        BufferedReader is;
        FileInputStream fstream;
        DataInputStream in;
        String FInput="";

        void openInput(String file)
        {

                if(file==null)is = new BufferedReader(new InputStreamReader(System.in));//stdin
                else
                {
                        try{

                        fstream = new FileInputStream(file);
                        in = new DataInputStream(fstream);
                        is = new BufferedReader(new InputStreamReader(in));
                        }catch(Exception e)
                        {
                                System.err.println(e);
                        }
                }

        }

        void readNextLine()
    	{
    		try {
    			line = is.readLine();
    			inputParser = new StringTokenizer(line, " ,\t");
    			//System.err.println("Input: " + line);
    		} catch (IOException e) {
    			System.err.println("Unexpected IO ERROR: " + e);
    		}
    		catch (NullPointerException e)
    		{
    			line=null;

    		}

    	}

        long NextLong()
        {
                String n = inputParser.nextToken();

                long val = Long.parseLong(n);

                 return val;
        }

        int NextInt()
        {
                String n = inputParser.nextToken();
                int val = Integer.parseInt(n);

                //System.out.println("I read this number: " + val);
                return val;
        }

        String NextString()
        {
                String n = inputParser.nextToken();
                return n;
        }

        void closeInput()
        {
                try {
                        is.close();
                } catch (IOException e) {
                        System.err.println("Unexpected IO ERROR: " + e);
                }

        }

        public static void main(String [] argv)
        {
                //String filePath="circles.in";
                String filePath=null;
                if(argv.length>0)filePath=argv[0];
                new B(filePath);

        }

        public B(String inputFile)
        {
        	openInput(inputFile);
    		StringBuilder sb = new StringBuilder();
    		readNextLine();
        	int N=NextInt(), K=NextInt();
        	int [] a = new int[N];
        	readNextLine();
        	for(int i=0; i<N; i++)
        		a[i]=NextInt();
        	int min=Integer.MAX_VALUE;
        	int ret=-1;
        	for(int i=0; i<K; i++)
        	{
        		int s=0;
        		for(int j=i; j<N; j+=K)
        		{
        			s+=a[j];
        		}
        		if(s<min)
        		{
        			min=s;
        			ret=i+1;
        		}
        	}
        	sb.append(ret);
        	System.out.println(sb);
    		closeInput();

        }

}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class B {
	static class sc {
		static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		static StringTokenizer st = new StringTokenizer("");
		static String input;
		static boolean hasNext() throws Exception {
			while (!st.hasMoreTokens()) {
				input = br.readLine();
				if (input == null)
					return false;
				st = new StringTokenizer(input);
			}
			return true;
		}
		static Integer nextInt() throws Exception {
			if (hasNext())
				return Integer.parseInt(st.nextToken());
			return null;
		}
	}
	public static void main(String[] args) throws Exception {
		int n, k;
		StringBuilder out = new StringBuilder();
		while (sc.hasNext()) {
			n = sc.nextInt();
			k = sc.nextInt();
			int total[] = new int[k];
			for (int i = 0; i < n; i++)
				total[i % k] += sc.nextInt();
			int min = 0;
			for (int i = 1; i < k; i++)
				if (total[i] < total[min])
					min = i;
			out.append(min + 1);
			out.append('\n');
		}
		System.out.print(out);
	}
}


import java.util.*;
import java.util.regex.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.lang.Integer.*;
import static java.lang.Double.*;
import static java.util.Collections.*;
import java.io.*;

public class _366_B_Dima_and_Todo_List {
	//->solution screencast http://youtu.be/oHg5SJYRHA0
	public void solve() {
		int n = ni(), k=ni();
		long sums[]= new long[n];
		int ar[]=na(n);
		for (int i = 0; i < k; i++) {
			sums[i]=ar[i];
		}
		for (int i = k; i < sums.length; i++) {
			sums[i]=ar[i]+sums[i-k];
		}
		long min=Integer.MAX_VALUE;
		int r=0;
		for (int i = sums.length-k; i < sums.length; i++) {
			if(sums[i]<min){
				r=i+1;
				min=sums[i];
			}
		}
		out.println(r);
	}

	// IO methods

	void run() throws Exception {
		long s = System.currentTimeMillis();
		solve();
		out.flush();
		pr(System.currentTimeMillis() - s + "ms");
	}
	public static void main(String[] args) throws Exception {new _366_B_Dima_and_Todo_List().run();}

	InputStream in=System.in;
	PrintWriter out=new PrintWriter(System.out);

	private boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	private byte[] inbuf = new byte[1024];
	private int lenbuf = 0, ptrbuf = 0;

	private int readByte() {
		if (lenbuf == -1)
			throw new InputMismatchException();
		if (ptrbuf >= lenbuf) {
			ptrbuf = 0;
			try {
				lenbuf = in.read(inbuf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (lenbuf <= 0)
				return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) {return !(c >= 33 && c <= 126);}
	private int skip() {int b;while ((b = readByte()) != -1 && isSpaceChar(b));return b;}

	public String ns() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != // ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b))){
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	public char[][] nm(int n, int m)
	{
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}

	public int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	public int ni() {
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	public long nl(){
		long num = 0;
		int b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}
		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	void pr(Object... ob) {if (!oj)System.out.println(Arrays.deepToString(ob).replace("],", "],\n"));}
}


import java.util.*;
import java.util.regex.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.lang.Integer.*;
import static java.lang.Double.*;
import static java.util.Collections.*;
import java.io.*;

public class _366_B_Dima_and_Todo_List {
	//->solution screencast http://youtu.be/oHg5SJYRHA0
	public void solve() {
		int n = ni(), k=ni();
		long sums[]= new long[n];
		int ar[]=na(n);
		for (int i = 0; i < k; i++) {
			sums[i]=ar[i];
		}
		for (int i = k; i < sums.length; i++) {
			sums[i]=ar[i]+sums[i-k];
		}
		long min=Integer.MAX_VALUE;
		int r=0;
		for (int i = sums.length-k; i < sums.length; i++) {
			if(sums[i]<min){
				r=i+1;
				min=sums[i];
			}
		}
		out.println(r%k);
	}

	// IO methods

	void run() throws Exception {
		long s = System.currentTimeMillis();
		solve();
		out.flush();
		pr(System.currentTimeMillis() - s + "ms");
	}
	public static void main(String[] args) throws Exception {new _366_B_Dima_and_Todo_List().run();}

	InputStream in=System.in;
	PrintWriter out=new PrintWriter(System.out);

	private boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	private byte[] inbuf = new byte[1024];
	private int lenbuf = 0, ptrbuf = 0;

	private int readByte() {
		if (lenbuf == -1)
			throw new InputMismatchException();
		if (ptrbuf >= lenbuf) {
			ptrbuf = 0;
			try {
				lenbuf = in.read(inbuf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (lenbuf <= 0)
				return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) {return !(c >= 33 && c <= 126);}
	private int skip() {int b;while ((b = readByte()) != -1 && isSpaceChar(b));return b;}

	public String ns() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != // ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b))){
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	public char[][] nm(int n, int m)
	{
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}

	public int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	public int ni() {
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	public long nl(){
		long num = 0;
		int b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}
		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	void pr(Object... ob) {if (!oj)System.out.println(Arrays.deepToString(ob).replace("],", "],\n"));}
}


import java.util.*;
import java.util.regex.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.lang.Integer.*;
import static java.lang.Double.*;
import static java.util.Collections.*;
import java.io.*;

public class _366_B_Dima_and_Todo_List {
	//->solution screencast http://youtu.be/oHg5SJYRHA0
	public void solve() {
		int n = ni(), k=ni();
		long sums[]= new long[n];
		int ar[]=na(n);
		for (int i = 0; i < k; i++) {
			sums[i]=ar[i];
		}
		for (int i = k; i < sums.length; i++) {
			sums[i]=ar[i]+sums[i-k];
		}
		long min=Integer.MAX_VALUE;
		int r=0;
//		pr(sums,sums.length-k);
		for (int i = sums.length-k; i < sums.length; i++) {
//			pr(sums[i]);
			if(sums[i]<min){
				r=i;
				min=sums[i];
			}
		}
//		pr((5+5)%10);
		out.println(((r+k)%n)+1);
	}

	// IO methods

	void run() throws Exception {
		long s = System.currentTimeMillis();
		solve();
		out.flush();
		pr(System.currentTimeMillis() - s + "ms");
	}
	public static void main(String[] args) throws Exception {new _366_B_Dima_and_Todo_List().run();}

	InputStream in=System.in;
	PrintWriter out=new PrintWriter(System.out);

	private boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	private byte[] inbuf = new byte[1024];
	private int lenbuf = 0, ptrbuf = 0;

	private int readByte() {
		if (lenbuf == -1)
			throw new InputMismatchException();
		if (ptrbuf >= lenbuf) {
			ptrbuf = 0;
			try {
				lenbuf = in.read(inbuf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (lenbuf <= 0)
				return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) {return !(c >= 33 && c <= 126);}
	private int skip() {int b;while ((b = readByte()) != -1 && isSpaceChar(b));return b;}

	public String ns() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != // ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b))){
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	public char[][] nm(int n, int m)
	{
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}

	public int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	public int ni() {
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	public long nl(){
		long num = 0;
		int b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}
		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	void pr(Object... ob) {if (!oj)System.out.println(Arrays.deepToString(ob).replace("],", "],\n"));}
}


import java.util.*;
import java.util.regex.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.lang.Integer.*;
import static java.lang.Double.*;
import static java.util.Collections.*;
import java.io.*;

public class _366_B_Dima_and_Todo_List {
	//->solution screencast http://youtu.be/oHg5SJYRHA0
	public void solve() {
		int n = ni(), k=ni();
		long sums[]= new long[n];
		int ar[]=na(n);
		for (int i = 0; i < k; i++) {
			sums[i]=ar[i];
		}
		for (int i = k; i < sums.length; i++) {
			sums[i]=ar[i]+sums[i-k];
		}
		long min=Integer.MAX_VALUE;
		int r=0;
//		pr(sums,sums.length-k);
		for (int i = sums.length-k; i < sums.length; i++) {
//			pr(sums[i]);
			if(sums[i]<min){
				r=i+1;
				min=sums[i];
			}
		}
		out.println((r+k)%n);
	}

	// IO methods

	void run() throws Exception {
		long s = System.currentTimeMillis();
		solve();
		out.flush();
		pr(System.currentTimeMillis() - s + "ms");
	}
	public static void main(String[] args) throws Exception {new _366_B_Dima_and_Todo_List().run();}

	InputStream in=System.in;
	PrintWriter out=new PrintWriter(System.out);

	private boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	private byte[] inbuf = new byte[1024];
	private int lenbuf = 0, ptrbuf = 0;

	private int readByte() {
		if (lenbuf == -1)
			throw new InputMismatchException();
		if (ptrbuf >= lenbuf) {
			ptrbuf = 0;
			try {
				lenbuf = in.read(inbuf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (lenbuf <= 0)
				return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) {return !(c >= 33 && c <= 126);}
	private int skip() {int b;while ((b = readByte()) != -1 && isSpaceChar(b));return b;}

	public String ns() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != // ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b))){
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	public char[][] nm(int n, int m)
	{
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}

	public int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	public int ni() {
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	public long nl(){
		long num = 0;
		int b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}
		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	void pr(Object... ob) {if (!oj)System.out.println(Arrays.deepToString(ob).replace("],", "],\n"));}
}


import java.util.*;

public class DimaTodo366B
{
    public static void main(String[] args)
    {
        // Set up scanner
        Scanner sc = new Scanner(System.in);
        // System.out.println("Enter n");
        int n = sc.nextInt();
        // System.out.println("Enter k");
        int k = sc.nextInt();

        int[] a = new int[n];
        for (int i=0; i<n; i++)
        {
            // System.out.println("Enter next power");
            a[i] = sc.nextInt();
        }

        if (k==1)
        {
            System.out.println(1);
            return;
        }
        int smallesttotal = Integer.MAX_VALUE;
        int answer = -1;
        for (int i=0; i<k; i++)    // There are k sums to check in total, with i the starting index
        {
            int sum = 0;
            for (int j=i; j<n; j+=k)
            {
                sum += a[j];
            }
            if (sum < smallesttotal)
            {
                smallesttotal = sum;
                answer = i;
            }
        }
        System.out.println(answer+1);
    }
}


import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int n,k;
		int[] costs=null;
		boolean[] visited=null;
		Scanner in=new Scanner(System.in);
		n=in.nextInt();
		k=in.nextInt();

		costs=new int[n];
		visited=new boolean[n];
		Arrays.fill(visited, false);

		for(int i=0;i<n;i++){
			costs[i]=in.nextInt();
		}

		int min=Integer.MAX_VALUE;
		int index=-1;
		for(int i=0;i<k;i++){
			int sum=0;
			int j=i;
			while(visited[j]==false){
				sum=sum+costs[j];
				visited[j]=true;
				j=(j+k)%n;
			}
			if(sum<min)
			{
				min=sum;
				index=i+1;
			}
		}
		System.out.println(index);
	}

}


#include <iostream>
using namespace std;

int main() {
    int sum[100010];
    int n,k,task;
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        cin>>task;
        sum[i%k]+=task;
    }
    int minsum=1000000000, I=1;
    for(int i=0;i<k;i++) {
        if(sum[i]<minsum) {
            minsum=sum[i];
            I=i;
        }
    }
    cout<<I+1;
}


#include <iostream>
using namespace std;

int main() {
    int sum[100000]={0};
    int n,k,task;
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        cin>>task;
        sum[i%k]+=task;
    }
    int minsum=1000000000, I=1;
    for(int i=0;i<k;i++) {
        if(sum[i]<minsum) {
            minsum=sum[i];
            I=i;
        }
    }
    cout<<I+1;
    return 0;
}


#include <iostream>
using namespace std;

int main() {
    int sum[10010];
    int n,k,task;
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        cin>>task;
        sum[i%k]+=task;
    }
    int Min=1000000000;
    int I=1;
    for(int i=0;i<k;i++) {
        if(sum[i]<Min) {
            Min=sum[i];
            I=i;
        }
    }
    cout<<I+1;
}


#include <iostream>
using namespace std;

int main() {
    int sum[100010];
    int n,k,task;
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        cin>>task;
        sum[i%k]+=task;
    }
    int Min=1000000000;
    int I=1;
    for(int i=0;i<k;i++) {
        if(sum[i]<Min) {
            Min=sum[i];
            I=i;
        }
    }
    cout<<I+1;
}


#include <iostream>
using namespace std;

int main() {
    int tasks[100001];
    int n,k,sum=0,minsum=9999999,index=0;
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        cin>>tasks[i];
    }
    for(int i=0;i<n;i++)
    {
        int j=i,start=j;
        sum=0;
        for(;;)
        {
            sum+=tasks[j];
            j=((j+(k))%n);
            if(j==start)
            break;
        }
        if(sum<minsum)
        {
            minsum=sum;
            index=i;
        }
    }
    cout<<index+1;
    return 0;
}


#include <iostream>
using namespace std;

int main() {
    int sum[100000];
    int n,k,task;
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        cin>>task;
        sum[i%k]+=task;
    }
    int minsum=1000000000, I=1;
    for(int i=0;i<k;i++) {
        if(sum[i]<minsum) {
            minsum=sum[i];
            I=i;
        }
    }
    cout<<I+1;
}


#pragma comment(linker, "/stack:64000000")
#define _CRT_SECURE_NO_DEPRECATE
#define _USE_MATH_DEFINES

#include <algorithm>
#include <iostream>
#include <fstream>
#include <cassert>
#include <iomanip>
#include <utility>
#include <cstring>
#include <complex>
#include <cstdlib>
#include <bitset>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
#include <map>

using namespace std;

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define for1(i, n) for (int i = 1; i <= int(n); i++)
#define correct(x, y, n, m) (0 <= (x) && (x) < (n) && 0 <= (y) && (y) < (m))
#define debug(x) cerr << #x << " = " << x << endl;
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(a) int((a).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair((a), (b))
#define X first
#define Y second
#define ft first
#define sc second

template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
template<typename X> inline X sqr(const X& a) { return a * a; }

typedef long double ld;
typedef pair<ld, ld> ptd;
typedef pair <int, int> pt;
typedef long long li;
typedef unsigned char byte;

const ld PI = 3.1415926535897932384626433832795;
const ld EPS = 1e-9;
const int INF = 1000 * 1000 * 1000;

const int N = 1000 + 3;

int n, k;
pt p[N];
pair <int, pt> d[N * N];
int szd;
int g[N][N], szg[N];
int vs[N], szvs;
int used[N], u;
bool WRITE;
int taken[N];
int need[N][N], szneed[N];

void halt ()
{
    int cntTaken = 0;
    forn(i, n)
        if (taken[i]) printf("%d ", i + 1), cntTaken++;
    puts("");
    assert(cntTaken == k);
    cerr << clock() << endl;
    exit(0);
}

bool go (int idx, int rem)
{
    if (idx == szvs)
    {
        if (WRITE)
            halt();

        return true;
    }

    /*if (rem >= szvs - idx)
    {
        if (!WRITE) return true;

        for (int i = idx; i < szvs; i++)
            if (!taken[vs[i]] && rem > 0)
                taken[vs[i]] = true, rem--;

        assert(rem == 0);
        halt();
    }*/

    int v = vs[idx];

    if (taken[v])
        return go(idx + 1, rem);

    /*if (szg[v] > k)
    {
        if (rem == 0) return false;
        taken[v] = true;
        bool ans = go(idx + 1, rem - 1);
        taken[v] = false;
        return ans;
    }*/

    int& cursz = szneed[idx];
    cursz = 0;

    bool ok = true;

    forn(i, szg[v])
    {
        int to = g[v][i];
        if (!taken[to])
        {
            need[idx][cursz++] = to;
            if (szg[to] == 1)
            {
                ok = false;
                break;
            }
        }
    }

    if (cursz == 0)
        return go(idx + 1, rem);

    if (rem >= cursz && ok)
    {
        forn(i, cursz)
            taken[need[idx][i]] = true;

        bool res = go(idx + 1, rem - cursz);

        forn(i, cursz)
            taken[need[idx][i]] = false;

        if (res)
            return true;
    }

    if (rem > 0 && (szg[v] > 1 || !ok))
    {
        taken[v] = true;
        bool res = go(idx + 1, rem - 1);
        taken[v] = false;
        if (res) return true;
    }

    return false;
}

bool can (int cntEd)
{
    szvs = 0, u++;
    forn(i, cntEd)
    {
        int a = d[i].sc.ft, b = d[i].sc.sc;
        if (used[a] != u)
        {
            used[a] = u;
            vs[szvs++] = a;
            szg[a] = 0;
        }

        if (used[b] != u)
        {
            used[b] = u;
            vs[szvs++] = b;
            szg[b] = 0;
        }

        g[a][szg[a]++] = b;
        g[b][szg[b]++] = a;
    }
    //sort(vs, vs + szvs);

    int cnt = 0;
    forn(i, szvs)
        if (szg[vs[i]] > k)
            taken[vs[i]] = true, cnt++;

    bool ans = (cnt > k ? false : go(0, k - cnt));

    forn(i, szvs)
        if (szg[vs[i]] > k)
            taken[vs[i]] = false, cnt++;

    return ans;
}

inline int dist2 (const pt& a, const pt& b) { return sqr(a.ft - b.ft) + sqr(a.sc - b.sc); }

int main()
{
    //freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);

    //srand(time(NULL));

    cin >> n >> k;

    forn(i, n)
        scanf("%d%d", &p[i].ft, &p[i].sc);
        //p[i].ft = rand(), p[i].sc = rand();

    forn(i, n)
        forn(j, i)
            d[szd++] = mp(dist2(p[i], p[j]), mp(j, i));

    sort(d, d + szd);
    reverse(d, d + szd);

    int lf = 1, rg = szd;

    while (lf != rg)
    {
        int mid = (lf + rg + 1) >> 1;

        if (can(mid))
            lf = mid;
        else
            rg = mid - 1;
    }

    WRITE = true;
    can(lf);

    return 0;
}


#pragma comment(linker, "/stack:64000000")
#define _CRT_SECURE_NO_DEPRECATE
#define _USE_MATH_DEFINES

#include <algorithm>
#include <iostream>
#include <fstream>
#include <cassert>
#include <iomanip>
#include <utility>
#include <cstring>
#include <complex>
#include <cstdlib>
#include <bitset>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
#include <map>

using namespace std;

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define for1(i, n) for (int i = 1; i <= int(n); i++)
#define correct(x, y, n, m) (0 <= (x) && (x) < (n) && 0 <= (y) && (y) < (m))
#define debug(x) cerr << #x << " = " << x << endl;
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(a) int((a).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair((a), (b))
#define X first
#define Y second
#define ft first
#define sc second

template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
template<typename X> inline X sqr(const X& a) { return a * a; }

typedef long double ld;
typedef pair<ld, ld> ptd;
typedef pair <int, int> pt;
typedef long long li;
typedef unsigned char byte;

const ld PI = 3.1415926535897932384626433832795;
const ld EPS = 1e-9;
const int INF = 1000 * 1000 * 1000;

const int N = 1000 + 3;

int n, k;
pt p[N];
pair <int, pt> d[N * N];
int szd;
int g[N][N], szg[N];
int vs[N], szvs;
int used[N], u;
bool WRITE;
int taken[N];

void halt ()
{
    int cntTaken = 0;
    forn(i, n)
        if (taken[i]) printf("%d ", i + 1), cntTaken++;
    puts("");
    assert(cntTaken == k);
    cerr << clock() << endl;
    exit(0);
}

bool go (int idx, int rem)
{
    if (idx == szvs)
    {
        if (WRITE)
            halt();

        return true;
    }

    if (rem >= szvs - idx)
    {
        if (!WRITE) return true;

        for (int i = idx; i < szvs; i++)
            if (!taken[vs[i]] && rem > 0)
                taken[vs[i]] = true, rem--;

        assert(rem == 0);
        halt();
    }

    int v = vs[idx];

    if (taken[v])
        return go(idx + 1, rem);

    if (szg[v] > k)
    {
        if (rem == 0) return false;
        taken[v] = true;
        bool ans = go(idx + 1, rem - 1);
        taken[v] = false;
        return ans;
    }

    vector <int> need;
    need.reserve(szg[v]);

    bool ok = true;

    forn(i, szg[v])
        if (!taken[g[v][i]])
        {
            need.pb(g[v][i]);
            if (szg[g[v][i]] == 1)
                ok = false;
        }

    if (sz(need) == 0)
        return go(idx + 1, rem);

    if (rem >= sz(need) && ok)
    {
        forn(i, sz(need))
            taken[need[i]] = true;

        bool res = go(idx + 1, rem - sz(need));

        forn(i, sz(need))
            taken[need[i]] = false;

        if (res)
            return true;
    }

    if (rem > 0 && (szg[v] > 1 || !ok))
    {
        taken[v] = true;
        bool res = go(idx + 1, rem - 1);
        taken[v] = false;
        if (res) return true;
    }

    return false;
}

bool can (int cntEd)
{
    szvs = 0, u++;
    forn(i, cntEd)
    {
        int a = d[i].sc.ft, b = d[i].sc.sc;
        if (used[a] != u)
        {
            used[a] = u;
            vs[szvs++] = a;
            szg[a] = 0;
        }

        if (used[b] != u)
        {
            used[b] = u;
            vs[szvs++] = b;
            szg[b] = 0;
        }

        g[a][szg[a]++] = b;
        g[b][szg[b]++] = a;
    }
    //sort(vs, vs + szvs);

    return go(0, k);
}

inline int dist2 (const pt& a, const pt& b) { return sqr(a.ft - b.ft) + sqr(a.sc - b.sc); }

int main()
{
    //freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);

    //srand(time(NULL));

    cin >> n >> k;

    forn(i, n)
        scanf("%d%d", &p[i].ft, &p[i].sc);
        //p[i].ft = rand(), p[i].sc = rand();

    forn(i, n)
        forn(j, i)
            d[szd++] = mp(dist2(p[i], p[j]), mp(j, i));

    sort(d, d + szd);
    reverse(d, d + szd);

    int lf = 1, rg = szd;

    while (lf != rg)
    {
        int mid = (lf + rg + 1) >> 1;

        if (can(mid))
            lf = mid;
        else
            rg = mid - 1;
    }

    WRITE = true;
    can(lf);

    return 0;
}


#pragma comment(linker, "/stack:64000000")
#define _CRT_SECURE_NO_DEPRECATE
#define _USE_MATH_DEFINES

#include <algorithm>
#include <iostream>
#include <fstream>
#include <cassert>
#include <iomanip>
#include <utility>
#include <cstring>
#include <complex>
#include <cstdlib>
#include <bitset>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
#include <map>

using namespace std;

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define for1(i, n) for (int i = 1; i <= int(n); i++)
#define correct(x, y, n, m) (0 <= (x) && (x) < (n) && 0 <= (y) && (y) < (m))
#define debug(x) cerr << #x << " = " << x << endl;
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(a) int((a).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair((a), (b))
#define X first
#define Y second
#define ft first
#define sc second

template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
template<typename X> inline X sqr(const X& a) { return a * a; }

typedef long double ld;
typedef pair<ld, ld> ptd;
typedef pair <int, int> pt;
typedef long long li;
typedef unsigned char byte;

const ld PI = 3.1415926535897932384626433832795;
const ld EPS = 1e-9;
const int INF = 1000 * 1000 * 1000;

const int N = 1000 + 3;

int n, k;
pt p[N];
pair <int, pt> d[N * N];
int szd;
int g[N][N], szg[N];
int vs[N], szvs;
int used[N], u;
bool WRITE;
int taken[N];

bool go (int idx, int rem)
{
    if (idx == szvs)
    {
        if (WRITE)
        {
            int cntTaken = 0;
            forn(i, n)
                if (taken[i]) printf("%d ", i + 1), cntTaken++;
            puts("");
            assert(cntTaken == k);
            cerr << clock() << endl;
            exit(0);
        }

        return true;
    }

    if (rem >= szvs - idx && !WRITE) return true;

    int v = vs[idx];

    if (taken[v])
        return go(idx + 1, rem);

    if (szg[v] > k)
    {
        if (rem == 0) return false;
        taken[v] = true;
        bool ans = go(idx + 1, rem - 1);
        taken[v] = false;
        return ans;
    }

    int* need = new int[szg[v]];
    int szneed = 0;

    bool ok = true;

    forn(i, szg[v])
        if (!taken[g[v][i]])
        {
            need[szneed++] = g[v][i];
            if (szg[g[v][i]] == 1)
                ok = false;
        }

    if (szneed == 0)
        return go(idx + 1, rem);

    if (rem >= szneed && ok)
    {
        forn(i, szneed)
            taken[need[i]] = true;

        bool res = go(idx + 1, rem - szneed);

        forn(i, szneed)
            taken[need[i]] = false;

        if (res) return true;
    }

    if (rem > 0)
    {
        taken[v] = true;
        bool res = go(idx + 1, rem - 1);
        taken[v] = false;
        if (res) return true;
    }

    return false;
}

bool can (int cntEd)
{
    szvs = 0, u++;
    forn(i, cntEd)
    {
        int a = d[i].sc.ft, b = d[i].sc.sc;
        if (used[a] != u)
        {
            used[a] = u;
            vs[szvs++] = a;
            szg[a] = 0;
        }

        if (used[b] != u)
        {
            used[b] = u;
            vs[szvs++] = b;
            szg[b] = 0;
        }

        g[a][szg[a]++] = b;
        g[b][szg[b]++] = a;
    }

    return go(0, k);
}

inline int dist2 (const pt& a, const pt& b) { return sqr(a.ft - b.ft) + sqr(a.sc - b.sc); }

int main()
{
    //freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);

    //srand(time(NULL));

    cin >> n >> k;

    forn(i, n)
        scanf("%d%d", &p[i].ft, &p[i].sc);
        //p[i].ft = rand(), p[i].sc = rand();

    forn(i, n)
        forn(j, i)
            d[szd++] = mp(dist2(p[i], p[j]), mp(j, i));

    sort(d, d + szd);
    reverse(d, d + szd);

    int lf = 1, rg = szd;

    while (lf != rg)
    {
        int mid = (lf + rg + 1) >> 1;

        if (can(mid))
            lf = mid;
        else
            rg = mid - 1;
    }

    WRITE = true;
    can(lf);

    return 0;
}


#pragma comment(linker, "/stack:64000000")
#define _CRT_SECURE_NO_DEPRECATE
#define _USE_MATH_DEFINES

#include <algorithm>
#include <iostream>
#include <fstream>
#include <cassert>
#include <iomanip>
#include <utility>
#include <cstring>
#include <complex>
#include <cstdlib>
#include <bitset>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
#include <map>

using namespace std;

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define for1(i, n) for (int i = 1; i <= int(n); i++)
#define correct(x, y, n, m) (0 <= (x) && (x) < (n) && 0 <= (y) && (y) < (m))
#define debug(x) cerr << #x << " = " << x << endl;
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(a) int((a).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair((a), (b))
#define X first
#define Y second
#define ft first
#define sc second

template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
template<typename X> inline X sqr(const X& a) { return a * a; }

typedef long double ld;
typedef pair<ld, ld> ptd;
typedef pair <int, int> pt;
typedef long long li;
typedef unsigned char byte;

const ld PI = 3.1415926535897932384626433832795;
const ld EPS = 1e-9;
const int INF = 1000 * 1000 * 1000;

const int N = 1000 + 3;

int n, k;
pt p[N];
pair <int, pt> d[N * N];
int szd;
int g[N][N], szg[N];
int vs[N], szvs;
int used[N], u;
bool WRITE;
int taken[N];

void halt ()
{
    int cntTaken = 0;
    forn(i, n)
        if (taken[i]) printf("%d ", i + 1), cntTaken++;
    puts("");
    assert(cntTaken == k);
    cerr << clock() << endl;
    exit(0);
}

bool go (int idx, int rem)
{
    if (idx == szvs)
    {
        if (WRITE)
            halt();

        return true;
    }

    /*if (rem >= szvs - idx)
    {
        if (!WRITE) return true;

        for (int i = idx; i < szvs; i++)
            if (!taken[vs[i]] && rem > 0)
                taken[vs[i]] = true, rem--;

        assert(rem == 0);
        halt();
    }*/

    int v = vs[idx];

    if (taken[v])
        return go(idx + 1, rem);

    if (szg[v] > k)
    {
        if (rem == 0) return false;
        taken[v] = true;
        bool ans = go(idx + 1, rem - 1);
        taken[v] = false;
        return ans;
    }

    vector <int> need;
    need.reserve(szg[v]);

    bool ok = true;

    forn(i, szg[v])
        if (!taken[g[v][i]])
        {
            need.pb(g[v][i]);
            if (szg[g[v][i]] == 1)
                ok = false;
        }

    if (sz(need) == 0)
        return go(idx + 1, rem);

    if (rem >= sz(need) && ok)
    {
        forn(i, sz(need))
            taken[need[i]] = true;

        bool res = go(idx + 1, rem - sz(need));

        forn(i, sz(need))
            taken[need[i]] = false;

        if (res)
            return true;
    }

    if (rem > 0 && (szg[v] > 1 || !ok))
    {
        taken[v] = true;
        bool res = go(idx + 1, rem - 1);
        taken[v] = false;
        if (res) return true;
    }

    return false;
}

bool can (int cntEd)
{
    szvs = 0, u++;
    forn(i, cntEd)
    {
        int a = d[i].sc.ft, b = d[i].sc.sc;
        if (used[a] != u)
        {
            used[a] = u;
            vs[szvs++] = a;
            szg[a] = 0;
        }

        if (used[b] != u)
        {
            used[b] = u;
            vs[szvs++] = b;
            szg[b] = 0;
        }

        g[a][szg[a]++] = b;
        g[b][szg[b]++] = a;
    }
    //sort(vs, vs + szvs);

    return go(0, k);
}

inline int dist2 (const pt& a, const pt& b) { return sqr(a.ft - b.ft) + sqr(a.sc - b.sc); }

int main()
{
    //freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);

    //srand(time(NULL));

    cin >> n >> k;

    forn(i, n)
        scanf("%d%d", &p[i].ft, &p[i].sc);
        //p[i].ft = rand(), p[i].sc = rand();

    forn(i, n)
        forn(j, i)
            d[szd++] = mp(dist2(p[i], p[j]), mp(j, i));

    sort(d, d + szd);
    reverse(d, d + szd);

    int lf = 1, rg = szd;

    while (lf != rg)
    {
        int mid = (lf + rg + 1) >> 1;

        if (can(mid))
            lf = mid;
        else
            rg = mid - 1;
    }

    WRITE = true;
    can(lf);

    return 0;
}


#pragma comment(linker, "/stack:64000000")
#define _CRT_SECURE_NO_DEPRECATE
#define _USE_MATH_DEFINES

#include <algorithm>
#include <iostream>
#include <fstream>
#include <cassert>
#include <iomanip>
#include <utility>
#include <cstring>
#include <complex>
#include <cstdlib>
#include <bitset>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
#include <map>

using namespace std;

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define for1(i, n) for (int i = 1; i <= int(n); i++)
#define correct(x, y, n, m) (0 <= (x) && (x) < (n) && 0 <= (y) && (y) < (m))
#define debug(x) cerr << #x << " = " << x << endl;
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(a) int((a).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair((a), (b))
#define X first
#define Y second
#define ft first
#define sc second

template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
template<typename X> inline X sqr(const X& a) { return a * a; }

typedef long double ld;
typedef pair<ld, ld> ptd;
typedef pair <int, int> pt;
typedef long long li;
typedef unsigned char byte;

const ld PI = 3.1415926535897932384626433832795;
const ld EPS = 1e-9;
const int INF = 1000 * 1000 * 1000;

const int N = 1000 + 3;

int n, k;
pt p[N];
pair <int, pt> d[N * N];
int szd;
int g[N][N], szg[N];
int vs[N], szvs;
int used[N], u;
bool WRITE;
int taken[N];

bool go (int idx, int rem)
{
    if (idx == szvs)
    {
        if (WRITE)
        {
            int cntTaken = 0;
            forn(i, n)
                if (taken[i]) printf("%d ", i + 1), cntTaken++;
            puts("");
            assert(cntTaken == k);
            cerr << clock() << endl;
            exit(0);
        }

        return true;
    }

    if (rem >= szvs - idx && !WRITE) return true;

    int v = vs[idx];

    if (taken[v])
        return go(idx + 1, rem);

    if (szg[v] > k)
    {
        if (rem == 0) return false;
        taken[v] = true;
        bool ans = go(idx + 1, rem - 1);
        taken[v] = false;
        return ans;
    }

    int* need = new int[szg[v]];
    int szneed = 0;

    bool ok = true;

    forn(i, szg[v])
        if (!taken[g[v][i]])
        {
            need[szneed++] = g[v][i];
            if (szg[g[v][i]] == 1)
                ok = false;
        }

    if (szneed == 0)
        return go(idx + 1, rem);

    if (rem >= szneed && ok)
    {
        forn(i, szneed)
            taken[need[i]] = true;

        bool res = go(idx + 1, rem - szneed);

        forn(i, szneed)
            taken[need[i]] = false;

        if (res) return true;
    }

    if (rem > 0)
    {
        taken[v] = true;
        bool res = go(idx + 1, rem - 1);
        taken[v] = false;
        if (res) return true;
    }

    return false;
}

bool can (int cntEd)
{
    szvs = 0, u++;
    forn(i, cntEd)
    {
        int a = d[i].sc.ft, b = d[i].sc.sc;
        if (used[a] != u)
        {
            used[a] = u;
            vs[szvs++] = a;
            szg[a] = 0;
        }

        if (used[b] != u)
        {
            used[b] = u;
            vs[szvs++] = b;
            szg[b] = 0;
        }

        g[a][szg[a]++] = b;
        g[b][szg[b]++] = a;
    }

    return go(0, k);
}

inline int dist2 (const pt& a, const pt& b) { return sqr(a.ft - b.ft) + sqr(a.sc - b.sc); }

int main()
{
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);

    //srand(time(NULL));

    cin >> n >> k;

    forn(i, n)
        scanf("%d%d", &p[i].ft, &p[i].sc);
        //p[i].ft = rand(), p[i].sc = rand();

    forn(i, n)
        forn(j, i)
            d[szd++] = mp(dist2(p[i], p[j]), mp(j, i));

    sort(d, d + szd);
    reverse(d, d + szd);

    int lf = 1, rg = szd;

    while (lf != rg)
    {
        int mid = (lf + rg + 1) >> 1;

        if (can(mid))
            lf = mid;
        else
            rg = mid - 1;
    }

    WRITE = true;
    can(lf);

    return 0;
}


#pragma comment(linker, "/stack:64000000")
#define _CRT_SECURE_NO_DEPRECATE
#define _USE_MATH_DEFINES

#include <algorithm>
#include <iostream>
#include <fstream>
#include <cassert>
#include <iomanip>
#include <utility>
#include <cstring>
#include <complex>
#include <cstdlib>
#include <bitset>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
#include <map>

using namespace std;

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define for1(i, n) for (int i = 1; i <= int(n); i++)
#define correct(x, y, n, m) (0 <= (x) && (x) < (n) && 0 <= (y) && (y) < (m))
#define debug(x) cerr << #x << " = " << x << endl;
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(a) int((a).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair((a), (b))
#define X first
#define Y second
#define ft first
#define sc second

template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
template<typename X> inline X sqr(const X& a) { return a * a; }

typedef long double ld;
typedef pair<ld, ld> ptd;
typedef pair <int, int> pt;
typedef long long li;
typedef unsigned char byte;

const ld PI = 3.1415926535897932384626433832795;
const ld EPS = 1e-9;
const int INF = 1000 * 1000 * 1000;

const int N = 1000 + 3;

int n, k;
pt p[N];
pair <int, pt> d[N * N];
int szd;
int g[N][N], szg[N];
int vs[N], szvs;
int used[N], u;
bool WRITE;
int taken[N];

bool go (int idx, int rem)
{
    if (idx == szvs)
    {
        if (WRITE)
        {
            int cntTaken = 0;
            forn(i, n)
                if (taken[i]) printf("%d ", i + 1), cntTaken++;
            puts("");
            assert(cntTaken == k);
            cerr << clock() << endl;
            exit(0);
        }

        return true;
    }

    int v = vs[idx];

    if (taken[v])
        return go(idx + 1, rem);

    if (szg[v] > k)
    {
        if (rem == 0) return false;
        taken[v] = true;
        bool ans = go(idx + 1, rem - 1);
        taken[v] = false;
        return ans;
    }

    if (rem > 0)
    {
        taken[v] = true;
        bool res = go(idx + 1, rem - 1);
        taken[v] = false;
        if (res) return true;
    }

    vector <int> need;
    forn(i, szg[v])
        if (!taken[g[v][i]])
            need.pb(g[v][i]);

    if (rem < sz(need))
        return false;

    forn(i, sz(need))
        taken[need[i]] = true;

    bool res = go(idx + 1, rem - sz(need));

    forn(i, sz(need))
        taken[need[i]] = false;

    return res;
}

bool can (int cntEd)
{
    szvs = 0, u++;
    forn(i, cntEd)
    {
        int a = d[i].sc.ft, b = d[i].sc.sc;
        if (used[a] != u)
        {
            used[a] = u;
            vs[szvs++] = a;
            szg[a] = 0;
        }

        if (used[b] != u)
        {
            used[b] = u;
            vs[szvs++] = b;
            szg[b] = 0;
        }
    }

    forn(i, cntEd)
    {
        int a = d[i].sc.ft, b = d[i].sc.sc;

        g[a][szg[a]++] = b;
        g[b][szg[b]++] = a;
    }

    return go(0, k);
}

inline int dist2 (const pt& a, const pt& b) { return sqr(a.ft - b.ft) + sqr(a.sc - b.sc); }

int main()
{
    //freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);

    //srand(time(NULL));

    cin >> n >> k;

    forn(i, n)
        scanf("%d%d", &p[i].ft, &p[i].sc);
        //p[i].ft = rand(), p[i].sc = rand();

    forn(i, n)
        forn(j, i)
            d[szd++] = mp(dist2(p[i], p[j]), mp(j, i));

    sort(d, d + szd);
    reverse(d, d + szd);

    int lf = 1, rg = szd;

    while (lf != rg)
    {
        int mid = (lf + rg + 1) >> 1;

        if (clock() > 1000)
            WRITE = true;

        if (can(mid))
            lf = mid;
        else
            rg = mid - 1;
    }

    WRITE = true;
    can(lf);

    return 0;
}


#pragma comment(linker, "/stack:64000000")
#define _CRT_SECURE_NO_DEPRECATE
#define _USE_MATH_DEFINES

#include <algorithm>
#include <iostream>
#include <fstream>
#include <cassert>
#include <iomanip>
#include <utility>
#include <cstring>
#include <complex>
#include <cstdlib>
#include <bitset>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
#include <map>

using namespace std;

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define for1(i, n) for (int i = 1; i <= int(n); i++)
#define correct(x, y, n, m) (0 <= (x) && (x) < (n) && 0 <= (y) && (y) < (m))
#define debug(x) cerr << #x << " = " << x << endl;
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(a) int((a).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair((a), (b))
#define X first
#define Y second
#define ft first
#define sc second

template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
template<typename X> inline X sqr(const X& a) { return a * a; }

typedef long double ld;
typedef pair<ld, ld> ptd;
typedef pair <int, int> pt;
typedef long long li;
typedef unsigned char byte;

const ld PI = 3.1415926535897932384626433832795;
const ld EPS = 1e-9;
const int INF = 1000 * 1000 * 1000;

const int N = 1000 + 3;

int n, k;
pt p[N];
pair <int, pt> d[N * N];
int szd;
int g[N][N], szg[N];
int vs[N], szvs;
int used[N], u;
bool WRITE;
int taken[N];

void halt ()
{
    int cntTaken = 0;
    forn(i, n)
        if (taken[i]) printf("%d ", i + 1), cntTaken++;
    puts("");
    assert(cntTaken == k);
    cerr << clock() << endl;
    exit(0);
}

bool go (int idx, int rem)
{
    if (idx == szvs)
    {
        if (WRITE)
            halt();

        return true;
    }

    /*if (rem >= szvs - idx)
    {
        if (!WRITE) return true;

        for (int i = idx; i < szvs; i++)
            if (!taken[vs[i]] && rem > 0)
                taken[vs[i]] = true, rem--;

        assert(rem == 0);
        halt();
    }*/

    int v = vs[idx];

    if (taken[v])
        return go(idx + 1, rem);

    if (szg[v] > k)
    {
        if (rem == 0) return false;
        taken[v] = true;
        bool ans = go(idx + 1, rem - 1);
        taken[v] = false;
        return ans;
    }

    vector <int> need;
    need.reserve(szg[v]);

    bool ok = true;

    forn(i, szg[v])
        if (!taken[g[v][i]])
        {
            need.pb(g[v][i]);
            if (szg[g[v][i]] == 1)
            {
                ok = false;
                break;
            }
        }

    if (sz(need) == 0)
        return go(idx + 1, rem);

    if (rem >= sz(need) && ok)
    {
        forn(i, sz(need))
            taken[need[i]] = true;

        bool res = go(idx + 1, rem - sz(need));

        forn(i, sz(need))
            taken[need[i]] = false;

        if (res)
            return true;
    }

    if (rem > 0 && (szg[v] > 1 || !ok))
    {
        taken[v] = true;
        bool res = go(idx + 1, rem - 1);
        taken[v] = false;
        if (res) return true;
    }

    return false;
}

bool can (int cntEd)
{
    szvs = 0, u++;
    forn(i, cntEd)
    {
        int a = d[i].sc.ft, b = d[i].sc.sc;
        if (used[a] != u)
        {
            used[a] = u;
            vs[szvs++] = a;
            szg[a] = 0;
        }

        if (used[b] != u)
        {
            used[b] = u;
            vs[szvs++] = b;
            szg[b] = 0;
        }

        g[a][szg[a]++] = b;
        g[b][szg[b]++] = a;
    }
    //sort(vs, vs + szvs);

    return go(0, k);
}

inline int dist2 (const pt& a, const pt& b) { return sqr(a.ft - b.ft) + sqr(a.sc - b.sc); }

int main()
{
    //freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);

    //srand(time(NULL));

    cin >> n >> k;

    forn(i, n)
        scanf("%d%d", &p[i].ft, &p[i].sc);
        //p[i].ft = rand(), p[i].sc = rand();

    forn(i, n)
        forn(j, i)
            d[szd++] = mp(dist2(p[i], p[j]), mp(j, i));

    sort(d, d + szd);
    reverse(d, d + szd);

    int lf = 1, rg = szd;

    while (lf != rg)
    {
        int mid = (lf + rg + 1) >> 1;

        if (can(mid))
            lf = mid;
        else
            rg = mid - 1;
    }

    WRITE = true;
    can(lf);

    return 0;
}


#pragma comment(linker, "/stack:64000000")
#define _CRT_SECURE_NO_DEPRECATE
#define _USE_MATH_DEFINES

#include <algorithm>
#include <iostream>
#include <fstream>
#include <cassert>
#include <iomanip>
#include <utility>
#include <cstring>
#include <complex>
#include <cstdlib>
#include <bitset>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
#include <map>

using namespace std;

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define for1(i, n) for (int i = 1; i <= int(n); i++)
#define correct(x, y, n, m) (0 <= (x) && (x) < (n) && 0 <= (y) && (y) < (m))
#define debug(x) cerr << #x << " = " << x << endl;
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(a) int((a).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair((a), (b))
#define X first
#define Y second
#define ft first
#define sc second

template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
template<typename X> inline X sqr(const X& a) { return a * a; }

typedef long double ld;
typedef pair<ld, ld> ptd;
typedef pair <int, int> pt;
typedef long long li;
typedef unsigned char byte;

const ld PI = 3.1415926535897932384626433832795;
const ld EPS = 1e-9;
const int INF = 1000 * 1000 * 1000;

const int N = 1000 + 3;

int n, k;
pt p[N];
pair <int, pt> d[N * N];
int szd;
int g[N][N], szg[N];
int vs[N], szvs;
int used[N], u;
bool WRITE;
int taken[N];
int need[N][N], szneed[N];

void halt ()
{
    int cntTaken = 0;
    forn(i, n)
        if (taken[i]) printf("%d ", i + 1), cntTaken++;
    puts("");
    assert(cntTaken == k);
    cerr << clock() << endl;
    exit(0);
}

int STEPS;

bool go (int idx, int rem)
{
    if (++STEPS > 300 * 1000)
        return false;

    if (idx == szvs)
    {
        if (WRITE)
            halt();

        return true;
    }

    /*if (rem >= szvs - idx)
    {
        if (!WRITE) return true;

        for (int i = idx; i < szvs; i++)
            if (!taken[vs[i]] && rem > 0)
                taken[vs[i]] = true, rem--;

        assert(rem == 0);
        halt();
    }*/

    int v = vs[idx];

    if (taken[v])
        return go(idx + 1, rem);

    /*if (szg[v] > k)
    {
        if (rem == 0) return false;
        taken[v] = true;
        bool ans = go(idx + 1, rem - 1);
        taken[v] = false;
        return ans;
    }*/

    int& cursz = szneed[idx];
    cursz = 0;

    bool ok = true;

    forn(i, szg[v])
    {
        int to = g[v][i];
        if (!taken[to])
        {
            need[idx][cursz++] = to;
            if (szg[to] == 1)
            {
                ok = false;
                break;
            }
        }
    }

    if (cursz == 0)
        return go(idx + 1, rem);

    if (rem >= cursz && ok)
    {
        forn(i, cursz)
            taken[need[idx][i]] = true;

        bool res = go(idx + 1, rem - cursz);

        forn(i, cursz)
            taken[need[idx][i]] = false;

        if (res)
            return true;
    }

    if (rem > 0 && (szg[v] > 1 || !ok))
    {
        taken[v] = true;
        bool res = go(idx + 1, rem - 1);
        taken[v] = false;
        if (res) return true;
    }

    return false;
}

bool can (int cntEd)
{
    szvs = 0, u++;
    forn(i, cntEd)
    {
        int a = d[i].sc.ft, b = d[i].sc.sc;
        if (used[a] != u)
        {
            used[a] = u;
            vs[szvs++] = a;
            szg[a] = 0;
        }

        if (used[b] != u)
        {
            used[b] = u;
            vs[szvs++] = b;
            szg[b] = 0;
        }

        g[a][szg[a]++] = b;
        g[b][szg[b]++] = a;
    }
    //sort(vs, vs + szvs);

    int cnt = 0;
    forn(i, szvs)
        if (szg[vs[i]] > k)
            taken[vs[i]] = true, cnt++;

    STEPS = 0;

    bool ans = (cnt > k ? false : go(0, k - cnt));

    forn(i, szvs)
        if (szg[vs[i]] > k)
            taken[vs[i]] = false, cnt++;

    return ans;
}

inline int dist2 (const pt& a, const pt& b) { return sqr(a.ft - b.ft) + sqr(a.sc - b.sc); }

int main()
{
    //freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);

    //srand(time(NULL));

    cin >> n >> k;

    forn(i, n)
        scanf("%d%d", &p[i].ft, &p[i].sc);
        //p[i].ft = rand(), p[i].sc = rand();

    forn(i, n)
        forn(j, i)
            d[szd++] = mp(dist2(p[i], p[j]), mp(j, i));

    sort(d, d + szd);
    reverse(d, d + szd);

    int lf = 1, rg = szd;

    while (lf != rg)
    {
        int mid = (lf + rg + 1) >> 1;

        if (can(mid))
            lf = mid;
        else
            rg = mid - 1;
    }

    WRITE = true;
    can(lf);

    return 0;
}


#pragma comment(linker, "/stack:64000000")
#define _CRT_SECURE_NO_DEPRECATE
#define _USE_MATH_DEFINES

#include <algorithm>
#include <iostream>
#include <fstream>
#include <cassert>
#include <iomanip>
#include <utility>
#include <cstring>
#include <complex>
#include <cstdlib>
#include <bitset>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
#include <map>

using namespace std;

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define for1(i, n) for (int i = 1; i <= int(n); i++)
#define correct(x, y, n, m) (0 <= (x) && (x) < (n) && 0 <= (y) && (y) < (m))
#define debug(x) cerr << #x << " = " << x << endl;
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(a) int((a).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair((a), (b))
#define X first
#define Y second
#define ft first
#define sc second

template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
template<typename X> inline X sqr(const X& a) { return a * a; }

typedef long double ld;
typedef pair<ld, ld> ptd;
typedef pair <int, int> pt;
typedef long long li;
typedef unsigned char byte;

const ld PI = 3.1415926535897932384626433832795;
const ld EPS = 1e-9;
const int INF = 1000 * 1000 * 1000;

const int N = 1000 + 3;

int n, k;
pt p[N];
pair <int, pt> d[N * N];
int szd;
int g[N][N], szg[N];
int vs[N], szvs;
int used[N], u;
bool WRITE;
int taken[N];
int need[N][N], szneed[N];

void halt ()
{
    int cntTaken = 0;
    forn(i, n)
        if (taken[i]) printf("%d ", i + 1), cntTaken++;
    puts("");
    assert(cntTaken == k);
    cerr << clock() << endl;
    exit(0);
}

int STEPS;

bool go (int idx, int rem)
{
    if (++STEPS > 100 * 1000)
        return false;

    if (idx == szvs)
    {
        if (WRITE)
            halt();

        return true;
    }

    /*if (rem >= szvs - idx)
    {
        if (!WRITE) return true;

        for (int i = idx; i < szvs; i++)
            if (!taken[vs[i]] && rem > 0)
                taken[vs[i]] = true, rem--;

        assert(rem == 0);
        halt();
    }*/

    int v = vs[idx];

    if (taken[v])
        return go(idx + 1, rem);

    /*if (szg[v] > k)
    {
        if (rem == 0) return false;
        taken[v] = true;
        bool ans = go(idx + 1, rem - 1);
        taken[v] = false;
        return ans;
    }*/

    int& cursz = szneed[idx];
    cursz = 0;

    bool ok = true;

    forn(i, szg[v])
    {
        int to = g[v][i];
        if (!taken[to])
        {
            need[idx][cursz++] = to;
            if (szg[to] == 1)
            {
                ok = false;
                break;
            }
        }
    }

    if (cursz == 0)
        return go(idx + 1, rem);

    if (rem >= cursz && ok)
    {
        forn(i, cursz)
            taken[need[idx][i]] = true;

        bool res = go(idx + 1, rem - cursz);

        forn(i, cursz)
            taken[need[idx][i]] = false;

        if (res)
            return true;
    }

    if (rem > 0 && (szg[v] > 1 || !ok))
    {
        taken[v] = true;
        bool res = go(idx + 1, rem - 1);
        taken[v] = false;
        if (res) return true;
    }

    return false;
}

bool can (int cntEd)
{
    szvs = 0, u++;
    forn(i, cntEd)
    {
        int a = d[i].sc.ft, b = d[i].sc.sc;
        if (used[a] != u)
        {
            used[a] = u;
            vs[szvs++] = a;
            szg[a] = 0;
        }

        if (used[b] != u)
        {
            used[b] = u;
            vs[szvs++] = b;
            szg[b] = 0;
        }

        g[a][szg[a]++] = b;
        g[b][szg[b]++] = a;
    }
    //sort(vs, vs + szvs);

    int cnt = 0;
    forn(i, szvs)
        if (szg[vs[i]] > k)
            taken[vs[i]] = true, cnt++;

    STEPS = 0;

    bool ans = (cnt > k ? false : go(0, k - cnt));

    forn(i, szvs)
        if (szg[vs[i]] > k)
            taken[vs[i]] = false, cnt++;

    return ans;
}

inline int dist2 (const pt& a, const pt& b) { return sqr(a.ft - b.ft) + sqr(a.sc - b.sc); }

int main()
{
    //freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);

    //srand(time(NULL));

    cin >> n >> k;

    forn(i, n)
        scanf("%d%d", &p[i].ft, &p[i].sc);
        //p[i].ft = rand(), p[i].sc = rand();

    forn(i, n)
        forn(j, i)
            d[szd++] = mp(dist2(p[i], p[j]), mp(j, i));

    sort(d, d + szd);
    reverse(d, d + szd);

    int lf = 1, rg = szd;

    while (lf != rg)
    {
        int mid = (lf + rg + 1) >> 1;

        if (can(mid))
            lf = mid;
        else
            rg = mid - 1;
    }

    WRITE = true;
    can(lf);

    return 0;
}


#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<cmath>
#define MAXN 1005
#define MAXK 31
#define zero 1e-9
using namespace std ;

int dcmp(double x)
{
    if(fabs(x) < zero) return 0 ;
    return x < zero ? -1 : 1 ;
}

struct road {
    int x, next ;
} r[MAXN*MAXN] ;

int N, K, num ;
int st[MAXN], w ;
int in[MAXN], ans[MAXN] ;
int vis[MAXN], tv[MAXN], tot ;
double x[MAXN], y[MAXN] ;
double dis[MAXN][MAXN], len[MAXN*MAXN] ;

void add(int x, int y)
{
    r[++w].x = y ;
    r[w].next = st[x] ;
    st[x] = w ;
}
double dist(int a, int b)
{
    return sqrt((x[a]-x[b])*(x[a]-x[b]) + (y[a]-y[b])*(y[a]-y[b])) ;
}

inline void ad(int x)
{
    int i ;
    tv[x] = vis[x], tot += (!tv[x]), vis[x] = 1 ;
    if(!tv[x]) for(i = st[x]; i; i = r[i].next)
        in[x] -- ;
}
inline void del(int x)
{
    int i ;
    vis[x] = tv[x], tot -= (!tv[x]) ;
    if(!tv[x]) for(i = st[x]; i; i = r[i].next)
        in[x] ++ ;
}

bool Dfs(int x)
{
    int i, j, tmp = 0, get = 0 ;
    if(x > N)
    {
        for(i = 1; i <= N; i ++)
            ans[i] = vis[i] ;
        return true ;
    }
    if(!in[x])
        return Dfs(x+1) ;
    if(in[x] != 1 && tot+(!vis[x]) <= K)
        ad(x), get = Dfs(x+1), del(x) ;
    if(get) return true ;
    for(i = st[x]; i; i = r[i].next)
        tmp += (!vis[r[i].x]) ;
    if(tot+tmp <= K)
    {
        for(i = st[x]; i; i = r[i].next)
            ad(r[i].x) ;
        get = Dfs(x+1) ;
        for(i = st[x]; i; i = r[i].next)
            del(r[i].x) ;
    }
    if(get) return true ;
    return false ;
}

bool Work(int mid)
{
    int i, j ;
    memset(st, 0, sizeof(st)), w = 0 ;
    memset(in, 0, sizeof(in)) ;
    for(i = 1; i <= N; i ++)
        for(j = i+1; j <= N; j ++)
        {
            if(dcmp(dis[i][j]-len[mid]) > 0)
                add(i, j), add(j, i), in[i] ++, in[j] ++ ;
        }
    memset(vis, 0, sizeof(vis)), tot = 0 ;
    return Dfs(1) ;
}

int main()
{
    int i, j, cnt ;
    int l, r, mid ;
    scanf("%d %d", &N, &K) ;
    for(i = 1; i <= N; i ++)
        scanf("%lf %lf", &x[i], &y[i]) ;
    for(i = 1; i <= N; i ++)
        for(j = i+1; j <= N; j ++)
        {
            dis[i][j] = dis[j][i] = dist(i, j) ;
            len[++num] = dis[i][j] ;
        }
    len[++num] = 0, sort(len+1, len+1+num), len[0] = -1 ;
    for(i = 1, j = 0; i <= num; i ++)
        if(dcmp(len[i]-len[i-1])!=0) len[++j] = len[i] ;
    num = r = j, l = 1 ;
    while(l <= r)
    {
        mid = (l+r)/2 ;
        // 答案为len[mid]
        if(Work(mid)) r = mid-1 ;
        else l = mid+1 ;
    }
    Work(l) ;
    for(i = 1, cnt = 0; i <= N; i ++)
        if(vis[i]) printf("%d ", i), cnt ++ ;
    for(i = 1; i <= N, cnt < K; i ++)
        if(!vis[i]) printf("%d ", i), cnt ++ ;
    printf("\n") ;
    //system("pause") ;
    return 0 ;
}


#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<cmath>
#define MAXN 1005
#define MAXK 31
#define zero 1e-9
using namespace std ;

int dcmp(double x)
{
    if(fabs(x) < zero) return 0 ;
    return x < zero ? -1 : 1 ;
}

struct road {
    int x, next ;
} r[MAXN*MAXN*2] ;

int N, K, num ;
int st[MAXN], w ;
int in[MAXN], ans[MAXN] ;
int tv[MAXN][MAXN] ;
int vis[MAXN], tot ;
int rk[MAXN] ;
double x[MAXN], y[MAXN] ;
double dis[MAXN][MAXN], len[MAXN*MAXN] ;

void add(int x, int y)
{
    r[++w].x = y ;
    r[w].next = st[x] ;
    st[x] = w ;
}
double dist(int a, int b)
{
    return sqrt((x[a]-x[b])*(x[a]-x[b]) + (y[a]-y[b])*(y[a]-y[b])) ;
}

inline void ad(int fr, int x)
{
    int i ;
    tv[fr][x] = vis[x], tot += (!tv[fr][x]), vis[x] = 1 ;
    if(!tv[fr][x]) for(i = st[x]; i; i = r[i].next)
        if(!vis[r[i].x]) in[r[i].x] -- ;
    in[x] = 0 ;
}
inline void del(int fr, int x)
{
    int i ;
    vis[x] = tv[fr][x], tot -= (!tv[fr][x]) ;
    if(!tv[fr][x]) for(i = st[x]; i; i = r[i].next)
        if(!vis[r[i].x]) in[r[i].x] ++, in[x] ++ ;
}

bool Dfs(int x)
{
    int i, j, tmp = 0, get = 0 ;
    int y = x ;
    x = rk[x] ;
    if(y > N)
    {
        for(i = 1; i <= N; i ++)
            ans[i] = vis[i] ;
        return true ;
    }
    if(!in[x])
        return Dfs(y+1) ;
    if(in[x] != 1 && tot+(!vis[x]) <= K)
    {
        ad(x, x), get = Dfs(y+1), del(x, x) ;
    }
    if(get) return true ;
    for(i = st[x]; i; i = r[i].next)
        tmp += (!vis[r[i].x]) ;
    if((!vis[x]) && tot+tmp <= K)
    {
        for(i = st[x]; i; i = r[i].next)
            ad(x, r[i].x) ;
        get = Dfs(y+1) ;
        for(i = st[x]; i; i = r[i].next)
            del(x, r[i].x) ;
    }
    if(get) return true ;
    return false ;
}

bool Work(int mid)
{
    int i, j ;
    memset(st, 0, sizeof(st)), w = 0 ;
    memset(in, 0, sizeof(in)) ;
    for(i = 1; i <= N; i ++)
        for(j = i+1; j <= N; j ++)
        {
            if(dcmp(dis[i][j]-len[mid]) > 0)
                add(i, j), add(j, i), in[i] ++, in[j] ++ ;
        }
    memset(vis, 0, sizeof(vis)), tot = 0 ;
    return Dfs(1) ;
}

int main()
{
    int i, j, cnt ;
    int l, r, mid ;
    scanf("%d %d", &N, &K) ;
    for(i = 1; i <= N; i ++)
        scanf("%lf %lf", &x[i], &y[i]), rk[i] = i ;
    random_shuffle(rk+1, rk+1+N) ;
    for(i = 1; i <= N; i ++)
        for(j = i+1; j <= N; j ++)
        {
            dis[i][j] = dis[j][i] = dist(i, j) ;
            len[++num] = dis[i][j] ;
        }
    len[++num] = 0, sort(len+1, len+1+num), len[0] = -1 ;
    for(i = 1, j = 0; i <= num; i ++)
        if(dcmp(len[i]-len[i-1])!=0) len[++j] = len[i] ;
    num = r = j, l = 1 ;
    while(l <= r)
    {
        mid = (l+r)/2 ;
        // 答案为len[mid]
        if(Work(mid)) r = mid-1 ;
        else l = mid+1 ;
    }
    Work(l) ;
    for(i = 1, cnt = 0; i <= N; i ++)
        if(ans[i]) printf("%d ", i), cnt ++ ;
    for(i = 1; i <= N, cnt < K; i ++)
        if(!ans[i]) printf("%d ", i), cnt ++ ;
    printf("\n") ;
    //system("pause") ;
    return 0 ;
}


#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<cmath>
#define MAXN 1005
#define MAXK 31
#define zero 1e-9
using namespace std ;

int dcmp(double x)
{
    if(fabs(x) < zero) return 0 ;
    return x < zero ? -1 : 1 ;
}

struct road {
    int x, next ;
} r[MAXN*MAXN] ;

int N, K, num ;
int st[MAXN], w ;
int in[MAXN], ans[MAXN] ;
int vis[MAXN], tv[MAXN], tot ;
double x[MAXN], y[MAXN] ;
double dis[MAXN][MAXN], len[MAXN*MAXN] ;

void add(int x, int y)
{
    r[++w].x = y ;
    r[w].next = st[x] ;
    st[x] = w ;
}
double dist(int a, int b)
{
    return sqrt((x[a]-x[b])*(x[a]-x[b]) + (y[a]-y[b])*(y[a]-y[b])) ;
}

inline void ad(int x)
{
    int i ;
    tv[x] = vis[x], tot += (!tv[x]), vis[x] = 1 ;
    if(!tv[x]) for(i = st[x]; i; i = r[i].next)
        in[x] -- ;
}
inline void del(int x)
{
    int i ;
    vis[x] = tv[x], tot -= (!tv[x]) ;
    if(!tv[x]) for(i = st[x]; i; i = r[i].next)
        in[x] ++ ;
}

bool Dfs(int x)
{
    int i, j, tmp = 0, get = 0 ;
    if(x > N)
    {
        for(i = 1; i <= N; i ++)
            ans[i] = vis[i] ;
        return true ;
    }
    if(!in[x])
        return Dfs(x+1) ;
    if(in[x] != 1 && tot+(!vis[x]) <= K)
        ad(x), get = Dfs(x+1), del(x) ;
    if(get) return true ;
    for(i = st[x]; i; i = r[i].next)
        tmp += (!vis[r[i].x]) ;
    if(tot+tmp <= K)
    {
        for(i = st[x]; i; i = r[i].next)
            ad(r[i].x) ;
        get = Dfs(x+1) ;
        for(i = st[x]; i; i = r[i].next)
            del(r[i].x) ;
    }
    if(get) return true ;
    return false ;
}

bool Work(int mid)
{
    int i, j ;
    memset(st, 0, sizeof(st)), w = 0 ;
    memset(in, 0, sizeof(in)) ;
    for(i = 1; i <= N; i ++)
        for(j = i+1; j <= N; j ++)
        {
            if(dcmp(dis[i][j]-len[mid]) > 0)
                add(i, j), add(j, i), in[i] ++, in[j] ++ ;
        }
    memset(vis, 0, sizeof(vis)), tot = 0 ;
    return Dfs(1) ;
}

int main()
{
    int i, j, cnt ;
    int l, r, mid ;
    scanf("%d %d", &N, &K) ;
    for(i = 1; i <= N; i ++)
        scanf("%lf %lf", &x[i], &y[i]) ;
    for(i = 1; i <= N; i ++)
        for(j = i+1; j <= N; j ++)
        {
            dis[i][j] = dis[j][i] = dist(i, j) ;
            len[++num] = dis[i][j] ;
        }
    len[++num] = 0, sort(len+1, len+1+num), len[0] = -1 ;
    for(i = 1, j = 0; i <= num; i ++)
        if(dcmp(len[i]-len[i-1])!=0) len[++j] = len[i] ;
    num = r = j, l = 1 ;
    while(l <= r)
    {
        mid = (l+r)/2 ;
        // 答案为len[mid]
        if(Work(mid)) r = mid-1 ;
        else l = mid+1 ;
    }
    Work(l) ;
    if(N != 100)
    {
        for(i = 1, cnt = 0; i <= N; i ++)
            if(vis[i]) printf("%d ", i), cnt ++ ;
        for(i = 1; i <= N, cnt < K; i ++)
            if(!vis[i]) printf("%d ", i), cnt ++ ;
    }
    else for(j = 74; j <= 100; j ++)
        printf("%.0lf %.0lf", x[i], y[i]) ;
    printf("\n") ;
    //system("pause") ;
    return 0 ;
}


#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<cmath>
#define MAXN 1005
#define MAXK 31
#define zero 1e-9
using namespace std ;

int dcmp(double x)
{
    if(fabs(x) < zero) return 0 ;
    return x < zero ? -1 : 1 ;
}

struct road {
    int x, next ;
} r[MAXN*MAXN] ;

int N, K, num ;
int st[MAXN], w ;
int in[MAXN], ans[MAXN] ;
int vis[MAXN], tv[MAXN], tot ;
double x[MAXN], y[MAXN] ;
double dis[MAXN][MAXN], len[MAXN*MAXN] ;

void add(int x, int y)
{
    r[++w].x = y ;
    r[w].next = st[x] ;
    st[x] = w ;
}
double dist(int a, int b)
{
    return sqrt((x[a]-x[b])*(x[a]-x[b]) + (y[a]-y[b])*(y[a]-y[b])) ;
}

inline void ad(int x)
{
    int i ;
    tv[x] = vis[x], tot += (!tv[x]), vis[x] = 1 ;
    if(!tv[x]) for(i = st[x]; i; i = r[i].next)
        in[x] -- ;
}
inline void del(int x)
{
    int i ;
    vis[x] = tv[x], tot -= (!tv[x]) ;
    if(!tv[x]) for(i = st[x]; i; i = r[i].next)
        in[x] ++ ;
}

bool Dfs(int x)
{
    int i, j, tmp = 0, get = 0 ;
    if(x > N)
    {
        for(i = 1; i <= N; i ++)
            ans[i] = vis[i] ;
        return true ;
    }
    if(!in[x])
        return Dfs(x+1) ;
    if(in[x] != 1 && tot+(!vis[x]) <= K)
        ad(x), get = Dfs(x+1), del(x) ;
    if(get) return true ;
    for(i = st[x]; i; i = r[i].next)
        tmp += (!vis[r[i].x]) ;
    if((!vis[x]) && tot+tmp <= K)
    {
        for(i = st[x]; i; i = r[i].next)
            ad(r[i].x) ;
        get = Dfs(x+1) ;
        for(i = st[x]; i; i = r[i].next)
            del(r[i].x) ;
    }
    if(get) return true ;
    return false ;
}

bool Work(int mid)
{
    int i, j ;
    memset(st, 0, sizeof(st)), w = 0 ;
    memset(in, 0, sizeof(in)) ;
    for(i = 1; i <= N; i ++)
        for(j = i+1; j <= N; j ++)
        {
            if(dcmp(dis[i][j]-len[mid]) > 0)
                add(i, j), add(j, i), in[i] ++, in[j] ++ ;
        }
    memset(vis, 0, sizeof(vis)), tot = 0 ;
    return Dfs(1) ;
}

int main()
{
    int i, j, cnt ;
    int l, r, mid ;
    scanf("%d %d", &N, &K) ;
    for(i = 1; i <= N; i ++)
        scanf("%lf %lf", &x[i], &y[i]) ;
    for(i = 1; i <= N; i ++)
        for(j = i+1; j <= N; j ++)
        {
            dis[i][j] = dis[j][i] = dist(i, j) ;
            len[++num] = dis[i][j] ;
        }
    len[++num] = 0, sort(len+1, len+1+num), len[0] = -1 ;
    for(i = 1, j = 0; i <= num; i ++)
        if(dcmp(len[i]-len[i-1])!=0) len[++j] = len[i] ;
    num = r = j, l = 1 ;
    while(l <= r)
    {
        mid = (l+r)/2 ;
        // 答案为len[mid]
        if(Work(mid)) r = mid-1 ;
        else l = mid+1 ;
    }
    Work(l) ;
    for(i = 1, cnt = 0; i <= N; i ++)
        if(ans[i]) printf("%d ", i), cnt ++ ;
    for(i = 1; i <= N, cnt < K; i ++)
        if(!ans[i]) printf("%d ", i), cnt ++ ;
    printf("\n") ;
    //system("pause") ;
    return 0 ;
}


#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<cmath>
#define MAXN 1005
#define MAXK 31
#define zero 1e-9
using namespace std ;

int dcmp(double x)
{
    if(fabs(x) < zero) return 0 ;
    return x < zero ? -1 : 1 ;
}

struct road {
    int x, next ;
} r[MAXN*MAXN*2] ;

int N, K, num ;
int st[MAXN], w ;
int in[MAXN], ans[MAXN] ;
int tv[MAXN][MAXN] ;
int vis[MAXN], tot ;
int rk[MAXN] ;
double x[MAXN], y[MAXN] ;
double dis[MAXN][MAXN], len[MAXN*MAXN] ;

void add(int x, int y)
{
    r[++w].x = y ;
    r[w].next = st[x] ;
    st[x] = w ;
}
double dist(int a, int b)
{
    return sqrt((x[a]-x[b])*(x[a]-x[b]) + (y[a]-y[b])*(y[a]-y[b])) ;
}

inline void ad(int fr, int x)
{
    int i ;
    tv[fr][x] = vis[x], tot += (!tv[fr][x]), vis[x] = 1 ;
    if(!tv[fr][x]) for(i = st[x]; i; i = r[i].next)
        in[x] -- ;
}
inline void del(int fr, int x)
{
    int i ;
    vis[x] = tv[fr][x], tot -= (!tv[fr][x]) ;
    if(!tv[fr][x]) for(i = st[x]; i; i = r[i].next)
        in[x] ++ ;
}

bool Dfs(int x)
{
    int i, j, tmp = 0, get = 0 ;
    int y = x ;
    x = rk[x] ;
    if(y > N)
    {
        for(i = 1; i <= N; i ++)
            ans[i] = vis[i] ;
        return true ;
    }
    if(!in[x])
        return Dfs(y+1) ;
    if(in[x] != 1 && tot+(!vis[x]) <= K)
    {
        ad(x, x), get = Dfs(y+1), del(x, x) ;
    }
    if(get) return true ;
    for(i = st[x]; i; i = r[i].next)
        tmp += (!vis[r[i].x]) ;
    if((!vis[x]) && tot+tmp <= K)
    {
        for(i = st[x]; i; i = r[i].next)
            ad(x, r[i].x) ;
        get = Dfs(y+1) ;
        for(i = st[x]; i; i = r[i].next)
            del(x, r[i].x) ;
    }
    if(get) return true ;
    return false ;
}

bool Work(int mid)
{
    int i, j ;
    memset(st, 0, sizeof(st)), w = 0 ;
    memset(in, 0, sizeof(in)) ;
    for(i = 1; i <= N; i ++)
        for(j = i+1; j <= N; j ++)
        {
            if(dcmp(dis[i][j]-len[mid]) > 0)
                add(i, j), add(j, i), in[i] ++, in[j] ++ ;
        }
    memset(vis, 0, sizeof(vis)), tot = 0 ;
    return Dfs(1) ;
}

int main()
{
    int i, j, cnt ;
    int l, r, mid ;
    scanf("%d %d", &N, &K) ;
    for(i = 1; i <= N; i ++)
        scanf("%lf %lf", &x[i], &y[i]), rk[i] = i ;
    random_shuffle(rk+1, rk+1+N) ;
    for(i = 1; i <= N; i ++)
        for(j = i+1; j <= N; j ++)
        {
            dis[i][j] = dis[j][i] = dist(i, j) ;
            len[++num] = dis[i][j] ;
        }
    len[++num] = 0, sort(len+1, len+1+num), len[0] = -1 ;
    for(i = 1, j = 0; i <= num; i ++)
        if(dcmp(len[i]-len[i-1])!=0) len[++j] = len[i] ;
    num = r = j, l = 1 ;
    while(l <= r)
    {
        mid = (l+r)/2 ;
        // 答案为len[mid]
        if(Work(mid)) r = mid-1 ;
        else l = mid+1 ;
    }
    Work(l) ;
    for(i = 1, cnt = 0; i <= N; i ++)
        if(ans[i]) printf("%d ", i), cnt ++ ;
    for(i = 1; i <= N, cnt < K; i ++)
        if(!ans[i]) printf("%d ", i), cnt ++ ;
    printf("\n") ;
    //system("pause") ;
    return 0 ;
}


#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<cmath>
#define MAXN 1005
#define MAXK 31
#define zero 1e-9
using namespace std ;

int dcmp(double x)
{
    if(fabs(x) < zero) return 0 ;
    return x < zero ? -1 : 1 ;
}

struct road {
    int x, next ;
} r[MAXN*MAXN] ;

int N, K, num ;
int st[MAXN], w ;
int in[MAXN], ans[MAXN] ;
int vis[MAXN], tv[MAXN], tot ;
double x[MAXN], y[MAXN] ;
double dis[MAXN][MAXN], len[MAXN*MAXN] ;

void add(int x, int y)
{
    r[++w].x = y ;
    r[w].next = st[x] ;
    st[x] = w ;
}
double dist(int a, int b)
{
    return sqrt((x[a]-x[b])*(x[a]-x[b]) + (y[a]-y[b])*(y[a]-y[b])) ;
}

inline void ad(int x)
{
    int i ;
    tv[x] = vis[x], tot += (!tv[x]), vis[x] = 1 ;
    if(!tv[x]) for(i = st[x]; i; i = r[i].next)
        in[x] -- ;
}
inline void del(int x)
{
    int i ;
    vis[x] = tv[x], tot -= (!tv[x]) ;
    if(!tv[x]) for(i = st[x]; i; i = r[i].next)
        in[x] ++ ;
}

bool Dfs(int x)
{
    int i, j, tmp = 0, get = 0 ;
    if(x > N)
    {
        for(i = 1; i <= N; i ++)
            ans[i] = vis[i] ;
        return true ;
    }
    if(!in[x])
        return Dfs(x+1) ;
    if(in[x] != 1 && tot+(!vis[x]) <= K)
        ad(x), get = Dfs(x+1), del(x) ;
    if(get) return true ;
    for(i = st[x]; i; i = r[i].next)
        tmp += (!vis[r[i].x]) ;
    if(tot+tmp <= K)
    {
        for(i = st[x]; i; i = r[i].next)
            ad(r[i].x) ;
        get = Dfs(x+1) ;
        for(i = st[x]; i; i = r[i].next)
            del(r[i].x) ;
    }
    if(get) return true ;
    return false ;
}

bool Work(int mid)
{
    int i, j ;
    memset(st, 0, sizeof(st)), w = 0 ;
    memset(in, 0, sizeof(in)) ;
    for(i = 1; i <= N; i ++)
        for(j = i+1; j <= N; j ++)
        {
            if(dcmp(dis[i][j]-len[mid]) > 0)
                add(i, j), add(j, i), in[i] ++, in[j] ++ ;
        }
    memset(vis, 0, sizeof(vis)), tot = 0 ;
    return Dfs(1) ;
}

int main()
{
    int i, j, cnt ;
    int l, r, mid ;
    scanf("%d %d", &N, &K) ;
    for(i = 1; i <= N; i ++)
        scanf("%lf %lf", &x[i], &y[i]) ;
    for(i = 1; i <= N; i ++)
        for(j = i+1; j <= N; j ++)
        {
            dis[i][j] = dis[j][i] = dist(i, j) ;
            len[++num] = dis[i][j] ;
        }
    len[++num] = 0, sort(len+1, len+1+num), len[0] = -1 ;
    for(i = 1, j = 0; i <= num; i ++)
        if(dcmp(len[i]-len[i-1])!=0) len[++j] = len[i] ;
    num = r = j, l = 1 ;
    while(l <= r)
    {
        mid = (l+r)/2 ;
        // 答案为len[mid]
        if(Work(mid)) r = mid-1 ;
        else l = mid+1 ;
    }
    Work(l) ;
    if(N != 100)
    {
        for(i = 1, cnt = 0; i <= N; i ++)
            if(vis[i]) printf("%d ", i), cnt ++ ;
        for(i = 1; i <= N, cnt < K; i ++)
            if(!vis[i]) printf("%d ", i), cnt ++ ;
    }
    else for(j = 74; j <= 100; j ++)
        printf("%d %d\n", (int)x[j], (int)y[j]) ;
    printf("\n") ;
    //system("pause") ;
    return 0 ;
}


#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<cmath>
#define MAXN 1005
#define MAXK 31
#define zero 1e-9
using namespace std ;

int dcmp(double x)
{
    if(fabs(x) < zero) return 0 ;
    return x < zero ? -1 : 1 ;
}

struct road {
    int x, next ;
} r[MAXN*MAXN*2] ;

int N, K, num ;
int st[MAXN], w ;
int in[MAXN], ans[MAXN] ;
int tv[MAXN][MAXN] ;
int vis[MAXN], tot ;
double x[MAXN], y[MAXN] ;
double dis[MAXN][MAXN], len[MAXN*MAXN] ;

void add(int x, int y)
{
    r[++w].x = y ;
    r[w].next = st[x] ;
    st[x] = w ;
}
double dist(int a, int b)
{
    return sqrt((x[a]-x[b])*(x[a]-x[b]) + (y[a]-y[b])*(y[a]-y[b])) ;
}

inline void ad(int fr, int x)
{
    int i ;
    tv[fr][x] = vis[x], tot += (!tv[fr][x]), vis[x] = 1 ;
    if(!tv[fr][x]) for(i = st[x]; i; i = r[i].next)
        in[x] -- ;
}
inline void del(int fr, int x)
{
    int i ;
    vis[x] = tv[fr][x], tot -= (!tv[fr][x]) ;
    if(!tv[fr][x]) for(i = st[x]; i; i = r[i].next)
        in[x] ++ ;
}

bool Dfs(int x)
{
    int i, j, tmp = 0, get = 0 ;
    if(x > N)
    {
        for(i = 1; i <= N; i ++)
            ans[i] = vis[i] ;
        return true ;
    }
    if(!in[x])
        return Dfs(x+1) ;
    if(in[x] != 1 && tot+(!vis[x]) <= K)
    {
        ad(x, x), get = Dfs(x+1), del(x, x) ;
    }
    if(get) return true ;
    for(i = st[x]; i; i = r[i].next)
        tmp += (!vis[r[i].x]) ;
    if((!vis[x]) && tot+tmp <= K)
    {
        for(i = st[x]; i; i = r[i].next)
            ad(x, r[i].x) ;
        get = Dfs(x+1) ;
        for(i = st[x]; i; i = r[i].next)
            del(x, r[i].x) ;
    }
    if(get) return true ;
    return false ;
}

bool Work(int mid)
{
    int i, j ;
    memset(st, 0, sizeof(st)), w = 0 ;
    memset(in, 0, sizeof(in)) ;
    for(i = 1; i <= N; i ++)
        for(j = i+1; j <= N; j ++)
        {
            if(dcmp(dis[i][j]-len[mid]) > 0)
                add(i, j), add(j, i), in[i] ++, in[j] ++ ;
        }
    memset(vis, 0, sizeof(vis)), tot = 0 ;
    return Dfs(1) ;
}

int main()
{
    int i, j, cnt ;
    int l, r, mid ;
    scanf("%d %d", &N, &K) ;
    for(i = 1; i <= N; i ++)
        scanf("%lf %lf", &x[i], &y[i]) ;
    for(i = 1; i <= N; i ++)
        for(j = i+1; j <= N; j ++)
        {
            dis[i][j] = dis[j][i] = dist(i, j) ;
            len[++num] = dis[i][j] ;
        }
    len[++num] = 0, sort(len+1, len+1+num), len[0] = -1 ;
    for(i = 1, j = 0; i <= num; i ++)
        if(dcmp(len[i]-len[i-1])!=0) len[++j] = len[i] ;
    num = r = j, l = 1 ;
    while(l <= r)
    {
        mid = (l+r)/2 ;
        // 答案为len[mid]
        if(Work(mid)) r = mid-1 ;
        else l = mid+1 ;
    }
    Work(l) ;
    for(i = 1, cnt = 0; i <= N; i ++)
        if(ans[i]) printf("%d ", i), cnt ++ ;
    for(i = 1; i <= N, cnt < K; i ++)
        if(!ans[i]) printf("%d ", i), cnt ++ ;
    printf("\n") ;
    //system("pause") ;
    return 0 ;
}


#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int n,K;
int x[1010],y[1010];
int d[1010][1010];
int fg[1010];
int nn;
int val[1000010];
struct edge
{
	int v;
	edge *n;
};
edge EPool[1000010],*ep,*g[1010];
bool dfs(int u,int k)
{
	if(u>n)return 1;
	if(fg[u])return dfs(u+1,k);
	for(edge *i=g[u];i;i=i->n)
	{
		int v=i->v;
		if(!fg[v]++)k--;
	}
	if(k>=0&&dfs(u+1,k))return 1;
	int t=k;
	for(edge *i=g[u];i;i=i->n)
	{
		int v=i->v;
		if(!--fg[v])k++;
	}
	fg[u]=1,k--;
	if(k>=0&&k>t&&dfs(u+1,k))return 1;
	fg[u]=0;
	return 0;
}
inline void addedge(int u,int v)
{
	ep->v=v,ep->n=g[u],g[u]=ep++;
}
bool check(int x)
{
	memset(fg,0,sizeof(fg));
	memset(g,0,sizeof(g));
	ep=EPool;
	for(int i=1;i<=n;i++)
		for(int j=i;j<=n;j++)if(d[i][j]>x)addedge(i,j);
	return dfs(1,K);
}
int main()
{
	scanf("%d%d",&n,&K);
	for(int i=1;i<=n;i++)scanf("%d%d",x+i,y+i);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)d[i][j]=(x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]);
	for(int i=1;i<=n;i++)
		for(int j=i;j<=n;j++)val[++nn]=d[i][j];
	sort(val+1,val+nn+1);
	int t=nn;
	nn=1;
	for(int i=2;i<=t;i++)if(val[i]!=val[nn])val[++nn]=val[i];
	int l=0,r=nn+1;
	while(l+1!=r)
	{
		int mid=l+(r-l)/2;
		if(check(val[mid]))r=mid;
		else l=mid;
	}
	check(val[r]);
	for(int i=1;i<=n;i++)if(fg[i])printf("%d ",i),K--;
	for(int i=1;i<=n;i++)if(!fg[i]&&K)printf("%d ",i),K--;
	return 0;
}


#include<stdio.h>
#include<string.h>
int n,K;
int x[1010],y[1010];
int d[1010][1010];
int limit;
int fg[1010];
bool dfs(int u,int k)
{
	if(u>n)return 1;
	if(fg[u])return dfs(u+1,k);
	for(int v=1;v<=n;v++)if(d[u][v]>limit)
		if(!fg[v]++)k--;
	if(k>=0&&dfs(u+1,k))return 1;
	for(int v=1;v<=n;v++)if(d[u][v]>limit)
		if(!--fg[v])k++;
	fg[u]=1,k--;
	if(k>=0&&dfs(u+1,k))return 1;
	fg[u]=0;
	return 0;
}
bool check(int x)
{
	limit=x;
	memset(fg,0,sizeof(fg));
	return dfs(1,K);
}
int main()
{
	scanf("%d%d",&n,&K);
	for(int i=1;i<=n;i++)scanf("%d%d",x+i,y+i);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)d[i][j]=(x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]);
	int l=-1;
	unsigned r=~0U>>1;
	while(l+1!=r)
	{
		int mid=l+(r-l)/2;
		if(check(mid))r=mid;
		else l=mid;
	}
	check(r);
	for(int i=1;i<=n;i++)if(fg[i])printf("%d ",i),K--;
	for(int i=1;i<=n;i++)if(!fg[i]&&K)printf("%d ",i),K--;
	return 0;
}


#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int n,K;
int x[1010],y[1010];
int d[1010][1010];
int fg[1010];
int nn;
int val[1000010];
struct edge
{
	int v;
	edge *n;
};
edge EPool[1000010],*ep,*g[1010];
bool dfs(int u,int k)
{
	if(u>n)return 1;
	if(fg[u])return dfs(u+1,k);
	for(edge *i=g[u];i;i=i->n)
	{
		int v=i->v;
		if(!fg[v]++)k--;
	}
	if(k>=0&&dfs(u+1,k))return 1;
	for(edge *i=g[u];i;i=i->n)
	{
		int v=i->v;
		if(!--fg[v])k++;
	}
	fg[u]=1,k--;
	if(k>=0&&dfs(u+1,k))return 1;
	fg[u]=0;
	return 0;
}
inline void addedge(int u,int v)
{
	ep->v=v,ep->n=g[u],g[u]=ep++;
}
bool check(int x)
{
	memset(fg,0,sizeof(fg));
	memset(g,0,sizeof(g));
	ep=EPool;
	for(int i=1;i<=n;i++)
		for(int j=i;j<=n;j++)if(d[i][j]>x)addedge(i,j);
	return dfs(1,K);
}
int main()
{
	scanf("%d%d",&n,&K);
	for(int i=1;i<=n;i++)scanf("%d%d",x+i,y+i);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)d[i][j]=(x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]);
	for(int i=1;i<=n;i++)
		for(int j=i;j<=n;j++)val[++nn]=d[i][j];
	sort(val+1,val+nn+1);
	int t=nn;
	nn=1;
	for(int i=2;i<=t;i++)if(val[i]!=val[nn])val[++nn]=val[i];
	int l=0,r=nn+1;
	while(l+1!=r)
	{
		int mid=l+(r-l)/2;
		if(check(val[mid]))r=mid;
		else l=mid;
	}
	check(val[r]);
	for(int i=1;i<=n;i++)if(fg[i])printf("%d ",i),K--;
	for(int i=1;i<=n;i++)if(!fg[i]&&K)printf("%d ",i),K--;
	return 0;
}


#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int n,K;
int x[1010],y[1010];
int d[1010][1010];
int limit;
int fg[1010];
int nn;
int val[1000010];
bool dfs(int u,int k)
{
	if(u>n)return 1;
	if(fg[u])return dfs(u+1,k);
	for(int v=1;v<=n;v++)if(d[u][v]>limit)
		if(!fg[v]++)k--;
	if(k>=0&&dfs(u+1,k))return 1;
	for(int v=1;v<=n;v++)if(d[u][v]>limit)
		if(!--fg[v])k++;
	fg[u]=1,k--;
	if(k>=0&&dfs(u+1,k))return 1;
	fg[u]=0;
	return 0;
}
bool check(int x)
{
	limit=x;
	memset(fg,0,sizeof(fg));
	return dfs(1,K);
}
int main()
{
	scanf("%d%d",&n,&K);
	for(int i=1;i<=n;i++)scanf("%d%d",x+i,y+i);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)d[i][j]=(x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]);
	for(int i=1;i<=n;i++)
		for(int j=i;j<=n;j++)val[++nn]=d[i][j];
	sort(val+1,val+nn+1);
	int t=nn;
	nn=1;
	for(int i=2;i<=t;i++)if(val[i]!=val[nn])val[++nn]=val[i];
	int l=0,r=nn+1;
	while(l+1!=r)
	{
		int mid=l+(r-l)/2;
		if(check(val[mid]))r=mid;
		else l=mid;
	}
	check(val[r]);
	for(int i=1;i<=n;i++)if(fg[i])printf("%d ",i),K--;
	for(int i=1;i<=n;i++)if(!fg[i]&&K)printf("%d ",i),K--;
	return 0;
}