#include <bits/stdc++.h>
using namespace std;
int dx4[] = {-1, 0, 1, 0};
int dy4[] = {0, 1, 0, -1};
int dx8[] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};
void Duxar(int _this_line) {}
bool AreEqual(double a, double b) { return (fabs(a - b) < 1e-10); }
template <class T>
bool GetNr(T &_value) {
  T _sign = 1;
  char ch;
  _value = 0;
  while (!isdigit(ch = getchar())) {
    if (ch == -1) {
      return false;
    }
    ch == '-' ? _sign = -1 : _sign = 1;
  }
  do {
    _value = _value * 10 + (ch - '0');
  } while (isdigit(ch = getchar()));
  _value *= _sign;
  return true;
}
class Rectangle {
 public:
  long long key;
  int id, val;
  Rectangle() {}
  Rectangle(long long key, int val, int id) {
    this->key = key;
    this->id = id;
    this->val = val;
  }
};
int N, best;
vector<int> ans, marbles;
vector<Rectangle> values;
void AddMarbles(vector<int> v, int id) {
  if (v[2] < min(v[0], v[1]))
    values.push_back(Rectangle((long long)v[0] * 1000000000 + v[1], v[2], id));
  if (v[0] < min(v[2], v[1]))
    values.push_back(Rectangle((long long)v[1] * 1000000000 + v[2], v[0], id));
  if (v[1] < min(v[0], v[2]))
    values.push_back(Rectangle((long long)v[0] * 1000000000 + v[2], v[1], id));
}
bool ByKey(Rectangle a, Rectangle b) { return a.key < b.key; }
bool ByPair(Rectangle a, Rectangle b) {
  return make_pair(a.key, a.val) < make_pair(b.key, b.val);
}
int main() {
  string fileInput = "sum";
  int i, j;
  GetNr(N);
  values.reserve(N * 3);
  marbles.resize(3);
  for (i = 0; i < N; ++i) {
    int vmin = 1000992299;
    for (j = 0; j < 3; ++j) {
      GetNr(marbles[j]);
      vmin = min(vmin, marbles[j]);
    }
    sort((marbles).begin(), (marbles).end());
    AddMarbles(marbles, i + 1);
    if (best < vmin) {
      best = vmin;
      ans.clear();
      ans.push_back(i + 1);
    }
  }
  sort((values).begin(), (values).end(), ByPair);
  for (i = 0; i < values.size(); ++i) {
    int nextp =
        (int)(upper_bound(values.begin() + i, values.end(), values[i], ByKey) -
              values.begin());
    --nextp;
    i = nextp;
    for (j = i - 1; j >= 0 && values[j].key == values[i].key; --j) {
      if (values[j].id != values[i].id) {
        int x, y;
        x = values[i].key % 1000000000;
        y = values[i].key / 1000000000;
        if (best < min(min(x, y), values[j].val + values[i].val)) {
          best = min(min(x, y), values[j].val + values[i].val);
          ans.clear();
          ans.push_back(values[j].id);
          ans.push_back(values[i].id);
          break;
        }
      }
    }
  }
  printf("%d\n", (int)ans.size());
  for (auto m : ans) {
    printf("%d ", m);
  }
  putchar('\n');
  ;
  return 0;
}
