// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <iomanip>
#define dibs reserve
#define OVER9000 1234567890
#define patkan 9
#define tisic 47
#define soclose 10e-7
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define chocolate win
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):(x))
// mylittlepony
using namespace std;
struct info {
int x,y,id;
bool q;
info() {}
info(int a, int b, int t, int i) {q =(t > 0), x =a, y =b, id =i;}
bool operator<(const info &I) const {
return x < I.x;}
};
struct fin {
vector<int> T;
fin(int N) {T.resize(N+patkan,0);}
int lastone(int x) {return x&(x^(x-1));}
int get(int pos) {
int ret =0;
for(int i =pos+1; i > 0; i -=lastone(i)) ret +=T[i];
return ret;}
void put(int pos) {
for(int i =pos+1; i < T.size(); i +=lastone(i)) T[i]++;}
};
int main() {
cin.sync_with_stdio(0);
int N,a,b,c;
cin >> N;
vector<info> V;
map<int,int> M;
for(int i =0; i < N; i++) {
cin >> a >> b >> c;
M[a] =0; M[b] =0; M[c] =0;
if(a > b) swap(a,b);
if(a > c) swap(a,c);
if(b > c) swap(b,c);
V.push_back(info(b,a,0,i));
V.push_back(info(c,b,1,i));}
a =0;
ALL_THE(M,it) {it->ss =a; a++;}
sort(V.begin(),V.end());
vector<int> ans(N);
fin F(3*N);
for(int i =0; i < V.size(); i++) {
V[i].y =M[V[i].y];
if(!V[i].q) {
F.put(V[i].y);
continue;}
ans[V[i].id] =F.get(V[i].y);}
a =0;
for(int i =0; i < N; i++) if(ans[i] == N) a++;
cout << a << "\n";
for(int i =0; i < N; i++) if(ans[i] == N) {
cout << i+1;
a--;
if(a > 0) cout << " ";}
cout << "\n";
return 0;}
// look at my code
// my code is amazing
Ly8gaW9zdHJlYW0gaXMgdG9vIG1haW5zdHJlYW0KI2luY2x1ZGUgPGNzdGRpbz4KLy8gYml0Y2gg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