package com.huawei.test.ercikaoshi;
import java.util.*;
/*
*
* 2025年8月14日10:04:48 性能基线超了
*
* */
public class HJ48 {
/*public static void main(String[] args) {
Scanner in = new Scanner(System.in);
HashMap<Long, Long> map = new HashMap<>();
while (in.hasNextLong()) {
Long i = in.nextLong(); //支持粉丝数
Long y = in.nextLong(); //送礼粉丝个数
for (int j = 1; j <= i; j++) {
map.put((long) j, in.nextLong() + in.nextLong() * 2);
}
//将entrySet放入到list集合里进行排序
ArrayList<Map.Entry<Long, Long>> arrayList = new ArrayList<>
(map.entrySet());
//
Collections.sort(arrayList, new Comparator<Map.Entry<Long, Long>>() {
@Override
public int compare(Map.Entry<Long, Long> o1,
Map.Entry<Long, Long> o2) {
// Value 降序:e2 与 e1 比较
int valueCompare = o2.getValue().compareTo(o1.getValue());
if (valueCompare != 0) {
return valueCompare;
}
// Value 相同时,Key 升序
return o1.getKey().compareTo(Long.valueOf(o2.getKey()));
}
});
//转换成linkedHashMap 保持顺序输出
LinkedHashMap<Long, Long> hashMap = new LinkedHashMap<>();
for (Map.Entry<Long, Long> entry : map.entrySet()) {
hashMap.put(entry.getKey(), entry.getValue());
}
int count = 0;
ArrayList<Long> list = new ArrayList<>();
for (Map.Entry<Long, Long> entry : arrayList) {
if (count < y) {
list.add(entry.getKey());
count++;
} else {
break;
}
}
Collections.sort(list);
for (Long l : list) {
System.out.print(l + " ");
}
}
}*/
static class Fan {
int id;
int x;
int y;
int score;
public Fan(int id, int x, int y) {
this.id = id;
this.x = x;
this.y = y;
this.score = x + 2 * y;
}
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int k = scanner.nextInt();
Fan[] fans = new Fan[n];
for (int i = 0; i < n; i++) {
int x = scanner.nextInt();
int y = scanner.nextInt();
fans[i] = new Fan(i + 1, x, y);
}
Arrays.sort(fans, new Comparator<Fan>() {
@Override
public int compare(Fan f1, Fan f2) {
// Value 降序:e2 与 e1 比较
if (f1.score != f2.score) {
return Integer.compare(f2.score, f1.score);
}
// Value 相同时,Key 升序
return Integer.compare(f1.id, f2.id);
}
});
List<Integer> selectedIds = new ArrayList<>();
for (int i = 0; i < k; i++) {
selectedIds.add(fans[i].id);
}
Collections.sort(selectedIds);
for (int i = 0; i < selectedIds.size(); i++) {
System.out.print(selectedIds.get(i));
if (i < selectedIds.size() - 1) {
System.out.print(" ");
}
}
}
}