#include <bits/stdc++.h>
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  std::cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  std::cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
std::pair<int, int> operator+(std::pair<int, int> a, std::pair<int, int> b) {
  return {a.first + b.first, a.second + b.second};
}
std::pair<long long, long long> operator+(std::pair<long long, long long> a,
                                          std::pair<long long, long long> b) {
  return {a.first + b.first, a.second + b.second};
}
std::ostream& operator<<(std::ostream& out, std::pair<int, int> a) {
  out << a.first << " " << a.second << "\n";
  return out;
}
std::ostream& operator<<(std::ostream& out, std::pair<long long, long long> a) {
  out << a.first << " " << a.second << "\n";
  return out;
}
std::istream& operator>>(std::istream& in, std::pair<int, int>& a) {
  in >> a.first >> a.second;
  return in;
}
std::istream& operator>>(std::istream& in, std::pair<long long, long long>& a) {
  in >> a.first >> a.second;
  return in;
}
long long bpow(long long x, long long v) {
  if (v == 0) return 1 % 1000000007;
  if (v % 2 == 1) return (x * bpow(x, v - 1)) % 1000000007;
  long long r = bpow(x, v / 2);
  return (r * r) % 1000000007;
}
using namespace std;
int change[1000005];
void solve() {
  int n, mxr = 0, ov = 0, c, start = -1, end = -1, mnl = 1000005;
  cin >> n;
  pair<int, int> p1[n];
  int ans = 0;
  std::vector<int> v;
  for (int i = 0; i < n; ++i) {
    cin >> p1[i].first >> p1[i].second;
    c = 0;
    p1[i].second--;
    for (int j = p1[i].first; j <= p1[i].second; j++) {
      change[j]++;
      if (change[j] == 2) c++;
    }
    if (c > 0) ov++;
    mxr = max(mxr, p1[i].second);
    mnl = min(mnl, p1[i].first);
  }
  for (int i = mnl + 1; i < mxr; ++i) {
    if (change[i] == 2) end = i;
    if (change[i] > 2) {
      cout << 0;
      exit(0);
    }
  }
  for (int i = mnl; i <= mxr; ++i) {
    if (change[i] == 2) {
      start = i;
      break;
    }
  }
  if (ov > 0) {
    for (int j = 0; j < n; j++) {
      if (p1[j].first <= start && p1[j].second >= end) {
        v.push_back(j + 1);
      }
    }
  } else {
    ans = 1;
  }
  if (ans == 1) {
    cout << n << "\n";
    for (int i = 1; i <= n; ++i) {
      cout << i << " ";
    }
  } else {
    sort(v.begin(), v.end());
    cout << v.size() << "\n";
    for (auto i : v) cout << i << " ";
  }
}
int main() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) solve();
}
