#include <bits/stdc++.h>
using namespace std;
struct W {
long long a, b, c;
int idx; // 0-based index
};
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
if (!(cin >> n)) return 0;
vector<W> w(n);
for (int i = 0; i < n; ++i) {
cin >> w[i].a >> w[i].b >> w[i].c;
w[i].idx = i;
}
vector<char> canBeat(n, false);
// Pass 1: check (a_j < a_i) and (b_j < b_i)
{
auto v = w;
sort(v.begin(), v.end(), [](const W& x, const W& y){
if (x.a != y.a) return x.a < y.a;
return x.b < y.b; // tie-breaker not essential
});
long long bestB = LLONG_MAX; // min b among strictly smaller a's
for (int i = 0; i < n; ) {
int j = i;
long long groupMinB = LLONG_MAX;
while (j < n && v[j].a == v[i].a) {
if (bestB < v[j].b) canBeat[v[j].idx] = true;
groupMinB = min(groupMinB, v[j].b);
++j;
}
bestB = min(bestB, groupMinB);
i = j;
}
}
// Pass 2: check (a_j < a_i) and (c_j < c_i)
{
auto v = w;
sort(v.begin(), v.end(), [](const W& x, const W& y){
if (x.a != y.a) return x.a < y.a;
return x.c < y.c;
});
long long bestC = LLONG_MAX; // min c among strictly smaller a's
for (int i = 0; i < n; ) {
int j = i;
long long groupMinC = LLONG_MAX;
while (j < n && v[j].a == v[i].a) {
if (bestC < v[j].c) canBeat[v[j].idx] = true;
groupMinC = min(groupMinC, v[j].c);
++j;
}
bestC = min(bestC, groupMinC);
i = j;
}
}
// Pass 3: check (b_j < b_i) and (c_j < c_i)
{
auto v = w;
sort(v.begin(), v.end(), [](const W& x, const W& y){
if (x.b != y.b) return x.b < y.b;
return x.c < y.c;
});
long long bestC = LLONG_MAX; // min c among strictly smaller b's
for (int i = 0; i < n; ) {
int j = i;
long long groupMinC = LLONG_MAX;
while (j < n && v[j].b == v[i].b) {
if (bestC < v[j].c) canBeat[v[j].idx] = true;
groupMinC = min(groupMinC, v[j].c);
++j;
}
bestC = min(bestC, groupMinC);
i = j;
}
}
// Collect warriors that cannot beat anyone
vector<int> ans;
for (int i = 0; i < n; ++i)
if (!canBeat[i]) ans.push_back(i + 1); // 1-based indices
cout << ans.size() << "\n";
for (int i = 0; i < (int)ans.size(); ++i) {
if (i) cout << ' ';
cout << ans[i];
}
if (!ans.empty()) cout << '\n';
return 0;
}