#include <bits/stdc++.h>
using namespace std;
int a[5010][2];
int cnt[5010];
int main() {
  int n;
  while (cin >> n) {
    for (int i = 0; i < n; i++) {
      scanf("%d%d", &a[i][0], &a[i][1]);
      if (a[i][0] > a[i][1]) swap(a[i][0], a[i][1]);
      cnt[i] = 0;
    }
    int x, y, z;
    for (int i = 0; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
        x = max(a[i][0], a[j][0]);
        y = min(a[i][1], a[j][1]);
        if (x < y) {
          cnt[i]++;
          cnt[j]++;
        }
      }
    }
    x = y = 0;
    for (int i = 0; i < n; i++) {
      if (cnt[i] == 1)
        x++;
      else if (cnt[i] > 1) {
        y++;
        z = i;
      }
    }
    if (y > 1)
      cout << 0 << endl;
    else if (y == 1) {
      cout << 1 << endl;
      cout << z + 1 << endl;
    } else {
      if (x == 0) {
        cout << n << endl;
        for (int i = 0; i < n; i++) {
          if (i) cout << " ";
          cout << i + 1;
        }
        cout << endl;
      } else if (x == 2) {
        cout << 2 << endl;
        bool flg = 0;
        for (int i = 0; i < n; i++) {
          if (cnt[i] == 1) {
            if (flg) cout << " ";
            cout << i + 1;
            flg = 1;
          }
        }
        cout << endl;
      } else {
        cout << 0 << endl;
      }
    }
  }
  return 0;
}
