#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return a ? gcd(b % a, a) : b; }
int powmod(int a, int b, int m) {
  int res = 1;
  while (b)
    if (b & 1)
      res = (res * 1ll * a) % m, --b;
    else
      a = (a * 1ll * a) % m, b >>= 1;
  return res;
}
bool miller_rabin(int n) {
  int b = 2;
  for (int g; (g = gcd(n, b)) != 1; ++b)
    if (n > g) return false;
  int p = 0, q = n - 1;
  while ((q & 1) == 0) ++p, q >>= 1;
  int rem = powmod(b, q, n);
  if (rem == 1 || rem == n - 1) return true;
  for (int i = 1; i < p; ++i) {
    rem = (rem * 1ll * rem) % n;
    if (rem == n - 1) return true;
  }
  return false;
}
vector<vector<int>> dp;
long long binpow(long long n, long long s) {
  auto res = 1LL;
  while (s) {
    if (s & 1) res *= n;
    s >>= 1;
    n *= n;
  }
  return res;
}
const double PI = 3.141592653589793238463;
double log(long long n, long long k) { return log(n) / log(k); }
long long mod(long long a, int n) { return (a - floor((double)a / n) * n); }
long long mood = 1000000007;
stack<pair<char, int>> st;
string s;
bool comp(tuple<int, string, string> a, tuple<int, string, string> b) {
  if (get<1>(a).substr(3, 2) > get<1>(b).substr(3, 2))
    return 0;
  else if (get<1>(a).substr(3, 2) < get<1>(b).substr(3, 2))
    return 1;
  else if (get<1>(a).substr(0, 2) > get<1>(b).substr(0, 2))
    return 0;
  else if (get<1>(a).substr(0, 2) < get<1>(b).substr(0, 2))
    return 1;
  else
    return (get<2>(a) < get<2>(b));
}
long long bins(int n, long long m, long long l, long long r,
               vector<long long>& a) {
  long long prev = a[0];
  long long c = 0;
  long long k = (l + r) / 2;
  if (k == l) return k;
  for (auto i = 1; i < n; i++) {
    long long temp = (prev + a[i]) / k;
    prev = min(prev + a[i] - temp * k, a[i]);
    c += temp;
  }
  if (c >= m)
    return bins(n, m, k, r, a);
  else
    return bins(n, m, l, k, a);
}
vector<int> cols;
vector<pair<int, int>> vers;
vector<vector<int>> a;
map<int, int> b;
map<int, int> deass;
void rec(int v, int c) {
  if (b[v]) return;
  b[v] = c;
  cols[c]++;
  for (auto e : a[v]) {
    rec(e, c);
    if (vers[c].first == 0)
      if (vers[c].second) vers[c].first = deass[v];
  }
  if (vers[c].second == 0) vers[c].second = deass[v];
}
void solve() {
  int n;
  cin >> n;
  vector<pair<int, int>> a(n);
  vector<int> ans(n);
  for (auto i = 0; i < n; i++) {
    int c, d;
    cin >> c >> d;
    a[i] = {c, d};
  }
  for (auto i = 0; i < n; i++) {
    for (auto j = 0; j < n; j++) {
      if (i == j) continue;
      if ((a[i].first > a[j].first && a[i].first < a[j].second ||
           a[i].second > a[j].first && a[i].second < a[j].second) ||
          (a[j].first > a[i].first && a[j].first < a[i].second ||
           a[j].second > a[i].first && a[j].second < a[i].second))
        ans[i]++;
    }
  }
  int ones = 0;
  int max = 0;
  for (auto i = 0; i < n; i++) {
    if (ans[i] == 0) continue;
    if (ans[i] == 1)
      ones++;
    else if (max == 0)
      max = ans[i];
    else {
      cout << 0;
      return;
    }
  }
  if (max == 0) {
    if (ones == 0) {
      cout << n << endl;
      for (auto i = 0; i < n; i++) cout << i + 1 << endl;
    } else if (ones == 2) {
      cout << 2 << endl;
      for (auto i = 0; i < n; i++)
        if (ans[i] == 1) cout << i + 1 << endl;
    } else
      cout << 0;
    return;
  }
  if (ones == max) {
    cout << 1 << endl;
    for (auto i = 0; i < n; i++) {
      if (ans[i] == max) cout << i + 1;
    }
  } else
    cout << 0;
}
int main() {
  cin.tie(0);
  cout.tie(0);
  ios::sync_with_stdio(0);
  solve();
  return 0;
}
