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 N = 1e6 + 10;
const long long INF = 1e18;
const int limit = (int)1e9 + 1;
int n, m;
int xx[N], yy[N], P[N << 2];
long long Max[N << 2], c[N], Tag[N << 2], b[N];
vector<pair<int, int> > q[N];
template <typename T>
inline void chkmax(T &x, T y) {
  x = max(x, y);
}
template <typename T>
inline void chkmin(T &x, T y) {
  x = min(x, y);
}
template <typename T>
inline void read(T &x) {
  T f = 1;
  x = 0;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -f;
  for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + c - '0';
  x *= f;
}
inline void pushup(int now) {
  if (Max[now << 1] > Max[now << 1 | 1])
    Max[now] = Max[now << 1], P[now] = P[now << 1];
  else
    Max[now] = Max[now << 1 | 1], P[now] = P[now << 1 | 1];
  return;
}
inline void build(int now, int l, int r) {
  if (l == r) {
    Max[now] = -b[l];
    P[now] = l;
    return;
  }
  int mid = (l + r) >> 1;
  build(now << 1, l, mid);
  build(now << 1 | 1, mid + 1, r);
  pushup(now);
}
inline void pushdown(int now) {
  if (Tag[now] != 0) {
    Max[now << 1] += Tag[now];
    Max[now << 1 | 1] += Tag[now];
    Tag[now << 1] += Tag[now];
    Tag[now << 1 | 1] += Tag[now];
    Tag[now] = 0;
  }
}
inline void modify(int now, int l, int r, int ql, int qr, long long val) {
  if (l == ql && r == qr) {
    Max[now] += val;
    Tag[now] += val;
    return;
  }
  pushdown(now);
  int mid = (l + r) >> 1;
  if (mid >= qr)
    modify(now << 1, l, mid, ql, qr, val);
  else if (mid + 1 <= ql)
    modify(now << 1 | 1, mid + 1, r, ql, qr, val);
  else
    modify(now << 1, l, mid, ql, mid, val),
        modify(now << 1 | 1, mid + 1, r, mid + 1, qr, val);
  pushup(now);
}
inline pair<long long, int> query(int now, int l, int r, int ql, int qr) {
  if (l == ql && r == qr) return make_pair(Max[now], P[now]);
  pushdown(now);
  int mid = (l + r) >> 1;
  if (mid >= qr)
    return query(now << 1, l, mid, ql, qr);
  else if (mid + 1 <= ql)
    return query(now << 1 | 1, mid + 1, r, ql, qr);
  else {
    pair<long long, int> ll = query(now << 1, l, mid, ql, mid);
    pair<long long, int> rr = query(now << 1 | 1, mid + 1, r, mid + 1, qr);
    if (ll.first > rr.first)
      return ll;
    else
      return rr;
  }
}
int main() {
  read(n);
  for (int i = 1; i <= n; ++i) {
    read(xx[i]);
    read(yy[i]);
    read(c[i]);
    if (xx[i] != 0) b[++m] = xx[i];
    if (yy[i] != 0) b[++m] = yy[i];
  }
  b[0] = 0;
  sort(b + 1, b + m + 1);
  m = unique(b + 1, b + m + 1) - b - 1;
  build(1, 0, m);
  for (int i = 1; i <= n; ++i) {
    int pos = lower_bound(b, b + m + 1, min(xx[i], yy[i])) - b;
    int pp = lower_bound(b, b + m + 1, max(xx[i], yy[i])) - b;
    q[pos + 1].push_back(make_pair(pp, -c[i]));
    modify(1, 0, m, pp, m, c[i]);
  }
  b[m + 1] = limit;
  pair<long long, pair<int, int> > ans = make_pair(0, make_pair(m + 1, m + 1));
  pair<long long, int> val = query(1, 0, m, 0, m);
  if (val.first > ans.first)
    ans = make_pair(val.first, make_pair(0, val.second));
  for (int i = 1; i <= m; ++i) {
    for (auto x : q[i]) modify(1, 0, m, x.first, m, x.second);
    Tag[1] += b[i] - b[i - 1];
    Max[1] += b[i] - b[i - 1];
    pair<long long, int> val = query(1, 0, m, i, m);
    if (val.first > ans.first)
      ans = make_pair(val.first, make_pair(i, val.second));
  }
  cout << ans.first << "\n";
  cout << b[ans.second.first] << ' ' << b[ans.second.first] << ' '
       << b[ans.second.second] << ' ' << b[ans.second.second] << "\n";
  return 0;
}