#include <bits/stdc++.h>
using namespace std;
inline int Set(int N, int pos) { return N = N | (1 << pos); }
inline int Reset(int N, int pos) { return N = N & ~(1 << pos); }
inline bool check(int N, int pos) { return (bool)(N & (1 << pos)); }
template <class T>
T gcd(T a, T b) {
  return (!b) ? a : gcd(b, a % b);
}
template <class T>
T lcm(T a, T b) {
  return (a / gcd(a, b)) * b;
}
map<pair<long long, long long>, vector<pair<long long, int> > > M;
vector<int> ans, cur;
long long x[10];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 3; j++) cin >> x[j];
    int idx = 0;
    for (int a = 0; a < 3; a++) {
      for (int j = 0; j < 3; j++) {
        if (a != j) {
          int k;
          for (int l = 0; l < 3; l++) {
            if (l != a && l != j) k = l;
          }
          M[make_pair(x[a], x[j])].push_back(make_pair(x[k], i));
          idx++;
        }
      }
    }
  }
  long long best = 0;
  for (map<pair<long long, long long>, vector<pair<long long, int> > >::iterator
           it = M.begin();
       it != M.end(); it++) {
    sort((M[it->first]).begin(), (M[it->first]).end(),
         greater<pair<long long, int> >());
    long long c = 0;
    int p = -1;
    for (int j = 0; j < M[it->first].size(); j++) {
      if (p == M[it->first][j].second) continue;
      c += M[it->first][j].first;
      cur.push_back(M[it->first][j].second);
      p = M[it->first][j].second;
      if (cur.size() == 2) break;
    }
    c = min(c, min(it->first.first, it->first.second));
    if (c == best && cur.size() < ans.size()) {
      ans.resize(cur.size());
      ans[0] = cur[0];
    } else if (c > best) {
      ans.resize(cur.size());
      for (int k = 0; k < cur.size(); k++) ans[k] = cur[k];
      best = c;
    }
    cur.clear();
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i] + 1 << ' ';
  }
  cout << endl;
  return 0;
}
