#include <stdio.h>
#include <stdlib.h>
typedef struct 
{
    int power;
    int resistance;
    int flux;
    int index;
} Shield;
int compareShields(const void *a, const void *b) 
{
    Shield s1 = (Shield)a;
    Shield s2 = (Shield)b;
    if (s1->flux != s2->flux)
        return s1->flux - s2->flux; 
    if (s1->power != s2->power)
        return s2->power - s1->power; 
    return s1->index - s2->index; 
}
int main()
{
    int N, K;
    if (scanf("%d %d", &N, &K) != 2 || N < 1 || K < 1 || K > N) 
    {
        printf("Invalid input");
        return 0;
    }
    Shield shields = (Shield)malloc(N * sizeof(Shield));
    if (!shields) 
    {
        printf("Memory allocation failed");
        return 0;
    }
    for (int i = 0; i < N; i++) 
    {
        int p, r;
        if (scanf("%d %d", &p, &r) != 2 || p < 0 || r < 0) 
        {
            printf("Invalid input");
            free(shields);
            return 0;
        }
        shields[i].power = p;
        shields[i].resistance = r;
        shields[i].flux = p + r;
        shields[i].index = i + 1; 
    }
    qsort(shields, N, sizeof(Shield), compareShields);
    for (int i = 0; i < K; i++)
    {
        printf("%d", shields[i].index);
        if (i != K - 1) printf(" ");
    }
    free(shields);
    return 0;
}