#define TASKNAME "stock"
#include <cstdio>
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <ctime>
#include <cctype>
#include <cstdlib>
#include <cassert>
#include <functional>
#include <iomanip>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <vector>
 
#define EPS (1e-9)
#define INF (int(1e9))
#define INFLONG ((long long)(1e18))
#define sqr(a) ((a) * (a))
#define all(a) (a).begin(), (a).end()
#define zero(a) memset(a, 0, sizeof(a))
#define abs(a) (((a) < 0) ? -(a) : (a))
#define sz(a) (int)a.size()
#define fst first
#define snd second
#define y1 osrughosduvgarligybakrybrogvba
#define y0 aosfigdalrowgyalsouvgrlvygalri                               
#define mp make_pair
#define pb push_back
#define next dlkjdslfkdj
#define prev dsdflksdfjl
#define hash lkdfjldskfj
#define pi 3.1415926535897932384626433832795
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef vector <vi> vvi;
typedef vector <bool> vb;
typedef vector <ll> vll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <int, ll> pil;
typedef vector <pii> vpii;

const int maxn = 1e5;
const int maxval = 1e9;

struct seg
{
  int l, r, id;
  seg() {l = r = id = 0;}
  seg(int l, int r, int id) : l(l), r(r), id(id) {}
};                               

inline bool operator < (const seg &a, const seg &b) {return a.r < b.r || (a.r == b.r && a.l > b.l);}

int main()
{
  freopen(TASKNAME".in", "r", stdin);
  freopen(TASKNAME".out", "w", stdout);
  int n;
  assert(scanf("%d", &n) == 1);
  assert(1 <= n && n <= maxn);
  vector <seg> segs(n);
  for (int i = 0; i < n; i++)
  {
    assert(scanf("%d%d", &segs[i].l, &segs[i].r) == 2);
    segs[i].id = i;
    assert(1 <= segs[i].l && segs[i].l < segs[i].r && segs[i].r <= maxval);
  }
  sort(all(segs));

  vi dp(n, 1);
  vi pr(n, -1);
  for (int i = 0; i < n; i++)
  {
    dp[i] = (i ? dp[i - 1] : 1);
    pr[i] = (i ? pr[i - 1] : -1);
    for (int j = 0; j < i; j++)
      if (segs[j].r <= segs[i].l && dp[i] < dp[j] + 1)
        dp[i] = dp[j] + 1, pr[i] = j;
  }

  int idx = n - 1;
  vi ans;
  while (idx != -1)
  {
    ans.pb(idx);
    idx = pr[idx];
  }
  reverse(all(ans));
  printf("%d\n", sz(ans));
  for (int i = 0; i < sz(ans); i++)
    printf("%d%c", segs[ans[i]].id + 1, " \n"[i == sz(ans) - 1]);
  return 0;                                   
}

