31_C. Schedule
At the beginning of the new semester there is new schedule in the Berland State University. According to this schedule, n groups have lessons at the room 31. For each group the starting time of the lesson and the finishing time of the lesson are known. It has turned out that it is impossible to hold all lessons, because for some groups periods of their lessons intersect. If at some moment of time one groups finishes it's lesson, and the other group starts the lesson, their lessons don't intersect.

The dean wants to cancel the lesson in one group so that no two time periods of lessons of the remaining groups intersect. You are to find all ways to do that.

Input

The first line contains integer n (1 ≤ n ≤ 5000) — amount of groups, which have lessons in the room 31. Then n lines follow, each of them contains two integers li ri (1 ≤ li < ri ≤ 106) — starting and finishing times of lesson of the i-th group. It is possible that initially no two lessons intersect (see sample 1).

Output

Output integer k — amount of ways to cancel the lesson in exactly one group so that no two time periods of lessons of the remaining groups intersect. In the second line output k numbers — indexes of groups, where it is possible to cancel the lesson. Groups are numbered starting from 1 in the order that they were given in the input. Output the numbers in increasing order.

Examples

Input

3
3 10
20 30
1 3


Output

3
1 2 3 

Input

4
3 10
20 30
1 3
1 39


Output

1
4 

Input

3
1 5
2 6
3 7


Output

0
```python
from operator import add
import sys
from array import array  # noqa: F401
from typing import TypeVar, Generic, Callable, List
T = TypeVar('T')


class SegmentTree(Generic[T]):
    __slots__ = ["size", "tree", "identity", "op", "update_op"]

    def __init__(self, size: int, identity: T, op: Callable[[T, T], T],
                 update_op: Callable[[T, T], T]) -> None:
        self.size = size
        self.tree = [identity] * (size * 2)
        self.identity = identity
        self.op = op
        self.update_op = update_op

    def build(self, a: List[T]) -> None:
        tree = self.tree
        tree[self.size:self.size + len(a)] = a

        for i in range(self.size - 1, 0, -1):
            tree[i] = self.op(tree[i << 1], tree[(i << 1) + 1])

    def find(self, left: int, right: int) -> T:
        left += self.size
        right += self.size
        tree, result, op = self.tree, self.identity, self.op

        while left < right:
            if left & 1:
                result = op(tree[left], result)
                left += 1
            if right & 1:
                result = op(tree[right - 1], result)
            left, right = left >> 1, right >> 1

        return result

    def update(self, i: int, value: T) -> None:
        op, tree = self.op, self.tree
        i = self.size + i
        tree[i] = self.update_op(tree[i], value)

        while i > 1:
            i >>= 1
            tree[i] = op(tree[i << 1], tree[(i << 1) + 1])


def input():
    return sys.stdin.buffer.readline().decode('utf-8')


n = int(input())
a = [tuple(map(int, input().split())) for _ in range(n)]
max_n = 10**6 + 10
imos = [0] * max_n
for l, r in a:
    imos[l] += 1
    imos[r] -= 1

for i in range(max_n - 5):
    imos[i + 1] += imos[i]

segt = SegmentTree[int](max_n, 0, max, add)
segt.build(imos)

ans = []

for i, (l, r) in enumerate(a, start=1):
    if segt.find(0, l) <= 1 and segt.find(l, r) <= 2 and segt.find(r, max_n) <= 1:
        ans.append(i)

print(len(ans))
print(*ans)

```