# Считывание данных
n = int(input())
t = int(input())
games = []
for i in range(1, n + 1):
    l, r = map(int, input().split())
    games.append([i, l, r])

# Решение задачи без учёта перерыва с начала
games_sorted_end = sorted(games, key = lambda elem: elem[2])
min_end_time = [0]
min_end_game = [0]
prev_game = [0] * (n + 1)
for i, l, r in games_sorted_end:
    if l >= min_end_time[-1]:
        prev_game[i] = min_end_game[-1]
        min_end_time.append(r)
        min_end_game.append(i)

# Решение задачи без учёта перерыва с конца
INF = 2 * 10**9
games_sorted_beg = sorted(games, key = lambda elem: elem[1], reverse=True)
max_begin_time = [INF]
max_begin_game = [0]
next_game = [0] * (n + 1)
for i, l, r in games_sorted_beg:
    if r <= max_begin_time[-1]:
        next_game[i] = max_begin_game[-1]
        max_begin_time.append(l)
        max_begin_game.append(i)

# Нахождение ответа
ans_m = -1
game_before_break = 0
game_after_break = 0
# i - количество просмотренных матчей до перерыва
# j - количество просмотренных матчей после перерыва
j = len(max_begin_time) - 1
for i in range(1, len(min_end_time)):
    while max_begin_time[j] - min_end_time[i] < t:
        j -= 1
    if j > 0 and i + j > ans_m:
        ans_m = i + j
        game_before_break = min_end_game[i]
        game_after_break = max_begin_game[j]

# Восстановление набора матчей
# и вывод ответа
print(ans_m)
if ans_m > 0:
    ans = []
    curr = game_before_break
    while curr:
        ans.append(curr)
        curr = prev_game[curr]
    ans = ans[::-1]
    curr = game_after_break
    while curr:
        ans.append(curr)
        curr = next_game[curr]
    print(" ".join(map(str, ans)))
