#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> l(n), r(n);
  for (int i = 0; i < n; i++) {
    cin >> l[i] >> r[i];
  }
  int a = -1, b = -1;
  bool ok = true;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (!((l[i] <= l[j] && r[i] <= r[j]) || (l[j] <= l[i] && r[j] <= l[i]))) {
        if (a == -1) {
          a = i;
          b = j;
        } else {
          if (a == i && j == b)
            continue;
          else if (a == j && b == i)
            continue;
          else if (i == a && j != b) {
            b = -1;
          } else if (i == b && j != a) {
            a = i;
            b = -1;
          } else if (j == a && i != b) {
            b = -1;
          } else if (j == b && i != a) {
            a = j;
            b = -1;
          } else {
            ok = false;
          }
        }
      }
    }
  }
  if (!ok)
    cout << "0\n";
  else if (a == -1 && b == -1) {
    cout << n << "\n";
    for (int i = 0; i < n; i++) {
      cout << i + 1 << " ";
    }
    cout << "\n";
  } else if (b == -1) {
    cout << "1\n" << a + 1 << "\n";
  } else {
    if (a > b) swap(a, b);
    cout << "2\n" << a + 1 << " " << b + 1 << "\n";
  }
}
