Problem: Petya recently found a game "Choose a Square". In this game, there are n points numbered from 1 to n on an infinite field. The i-th point has coordinates (x_i, y_i) and cost c_i.

You have to choose a square such that its sides are parallel to coordinate axes, the lower left and upper right corners belong to the line y = x, and all corners have integer coordinates.

The score you get is the sum of costs of the points covered by the selected square minus the length of the side of the square. Note that the length of the side can be zero.

Petya asks you to calculate the maximum possible score in the game that can be achieved by placing exactly one square.

Input

The first line of the input contains one integer n (1 ≤ n ≤ 5 ⋅ 10^5) — the number of points on the field.

Each of the following n lines contains three integers x_i, y_i, c_i (0 ≤ x_i, y_i ≤ 10^9, -10^6 ≤ c_i ≤ 10^6) — coordinates of the i-th point and its cost, respectively.

Output

In the first line print the maximum score Petya can achieve.

In the second line print four integers x_1, y_1, x_2, y_2 (0 ≤ x_1, y_1, x_2, y_2 ≤ 2 ⋅ 10^9, x_1 = y_1, x_2 = y_2, x_1 ≤ x_2) separated by spaces — the coordinates of the lower left and upper right corners of the square which Petya has to select in order to achieve the maximum score.

Examples

Input


6
0 0 2
1 0 -5
1 1 3
2 3 4
1 4 -4
3 1 -1


Output


4
1 1 3 3


Input


5
3 3 0
3 3 -3
0 2 -1
3 1 3
0 0 -2


Output


0
1 1 1 1

Note

The field corresponding to the first example: <image>

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int P = 1e9 + 7, INF = 0x3f3f3f3f;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long qpow(long long a, long long n) {
  long long r = 1 % P;
  for (a %= P; n; a = a * a % P, n >>= 1)
    if (n & 1) r = r * a % P;
  return r;
}
long long inv(long long first) {
  return first <= 1 ? 1 : inv(P % first) * (P - P / first) % P;
}
inline int rd() {
  int first = 0;
  char p = getchar();
  while (p < '0' || p > '9') p = getchar();
  while (p >= '0' && p <= '9') first = first * 10 + p - '0', p = getchar();
  return first;
}
const int N = 1e6 + 50;
int n, b[N];
struct _ {
  int first, second;
  long long v;
  bool operator<(const _ &rhs) const {
    int ma = max(first, second), ma2 = max(rhs.first, rhs.second);
    if (ma != ma2) return ma < ma2;
    int mi = min(first, second), mi2 = min(rhs.first, rhs.second);
    return mi > mi2;
  }
} a[N], ff[N];
int ID(int first) { return lower_bound(b + 1, b + 1 + *b, first) - b; }
struct node {
  long long v, tag;
  int pos;
  void upd(long long first) { tag += first, v += first; }
  node operator+(const node &rhs) const {
    node ret;
    ret.v = max(v, rhs.v);
    ret.pos = ret.v == v ? pos : rhs.pos;
    ret.tag = 0;
    return ret;
  }
} tr[N << 2];
void build(int o, int l, int r) {
  if (l == r)
    tr[o].v = b[l], tr[o].pos = b[l];
  else
    build((o << 1), l, ((l + r) >> 1)),
        build(((o << 1) | 1), ((l + r) >> 1) + 1, r),
        tr[o] = tr[(o << 1)] + tr[((o << 1) | 1)];
}
void pd(int o) {
  if (tr[o].tag) {
    tr[(o << 1)].upd(tr[o].tag);
    tr[((o << 1) | 1)].upd(tr[o].tag);
    tr[o].tag = 0;
  }
}
void upd(int o, int l, int r, int ql, int qr, long long v) {
  if (ql <= l && r <= qr) return tr[o].upd(v);
  pd(o);
  if (((l + r) >> 1) >= ql) upd((o << 1), l, ((l + r) >> 1), ql, qr, v);
  if (((l + r) >> 1) < qr)
    upd(((o << 1) | 1), ((l + r) >> 1) + 1, r, ql, qr, v);
  tr[o] = tr[(o << 1)] + tr[((o << 1) | 1)];
}
node qry(int o, int l, int r, int ql, int qr) {
  if (ql <= l && r <= qr) return tr[o];
  pd(o);
  long long ans = -1e18;
  if (((l + r) >> 1) >= qr) return qry((o << 1), l, ((l + r) >> 1), ql, qr);
  if (((l + r) >> 1) < ql)
    return qry(((o << 1) | 1), ((l + r) >> 1) + 1, r, ql, qr);
  node L = qry((o << 1), l, ((l + r) >> 1), ql, qr),
       R = qry(((o << 1) | 1), ((l + r) >> 1) + 1, r, ql, qr);
  if (L.v > R.v) return L;
  return R;
}
int Ma(int i) { return max(a[i].first, a[i].second); }
int Mi(int i) { return min(a[i].first, a[i].second); }
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d%lld", &a[i].first, &a[i].second, &a[i].v);
    b[++*b] = a[i].first, b[++*b] = a[i].second;
  }
  sort(b + 1, b + 1 + *b), *b = unique(b + 1, b + 1 + *b) - b - 1;
  for (int i = 1; i <= n; ++i)
    a[i].first = ID(a[i].first), a[i].second = ID(a[i].second);
  build(1, 1, *b);
  sort(a + 1, a + 1 + n);
  int top = 0;
  for (int i = 1; i <= n; ++i) {
    if (!top)
      ff[++top] = a[i];
    else {
      if (ff[top].first == a[i].first && ff[top].second == a[i].second)
        ff[top].v += a[i].v;
      else
        ff[++top] = a[i];
    }
  }
  n = top;
  for (int i = 1; i <= n; ++i) a[i] = ff[i];
  long long ans = 0;
  int posl = 2e9, posr = 2e9;
  for (int i = 1; i <= n; ++i) {
    int j = i;
    while (j < n && Ma(j + 1) == Ma(i)) ++j;
    int R = -b[Ma(i)];
    for (int k = i; k <= j; ++k) {
      upd(1, 1, *b, 1, Mi(k), a[k].v);
    }
    node pp = qry(1, 1, *b, 1, Ma(i));
    long long ret = R + pp.v;
    if (ret > ans) {
      ans = ret;
      posl = pp.pos, posr = b[Ma(i)];
    }
    i = j;
  }
  printf("%lld\n", ans);
  printf("%d %d %d %d\n", posl, posl, posr, posr);
}