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;
int x[500005], y[500005];
bool vis[500005];
long long c[500005];
vector<int> v;
inline int idx(int x) { return lower_bound(v.begin(), v.end(), x) - v.begin(); }
struct segtree {
  vector<pair<long long, long long> > v, lazy;
  int size = 1;
  segtree(int n) {
    size = 1;
    while (size < 2 * n) size <<= 1;
    v.resize(size);
    lazy.resize(size);
    for (int i = size / 2; i < size; i++) v[i].second = i - size / 2;
  }
  void push_down(int node, int start, int end) {
    if (!lazy[node].first) return;
    v[node].first += lazy[node].first;
    if (start != end) {
      lazy[node * 2].first += lazy[node].first;
      lazy[node * 2 + 1].first += lazy[node].first;
    }
    lazy[node].first = 0;
  }
  void add(int i, int j, long long val) { add(1, i, j, 0, size / 2 - 1, val); }
  void add(int node, int i, int j, int start, int end, long long val) {
    push_down(node, start, end);
    if (j < start || i > end)
      return;
    else if (i <= start && j >= end) {
      lazy[node].first += val;
      push_down(node, start, end);
    } else {
      add(node * 2, i, j, start, (start + end) / 2, val);
      add(node * 2 + 1, i, j, (start + end) / 2 + 1, end, val);
      v[node] = max(v[node * 2], v[node * 2 + 1]);
    }
  }
  pair<long long, long long> MAX(int i, int j) {
    return MAX(1, i, j, 0, size / 2 - 1);
  }
  pair<long long, long long> MAX(int node, int i, int j, int start, int end) {
    push_down(node, start, end);
    if (j < start || i > end)
      return {-0x7f7f7f7f7f7f7f7f, 0};
    else if (i <= start && j >= end)
      return v[node];
    else
      return max(MAX(node * 2, i, j, start, (start + end) / 2),
                 MAX(node * 2 + 1, i, j, (start + end) / 2 + 1, end));
  }
};
void solve() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i] >> c[i];
    if (x[i] <= 500000) vis[x[i]] = true;
    if (y[i] <= 500000) vis[y[i]] = true;
    v.push_back(x[i]);
    v.push_back(y[i]);
  }
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  int m = v.size();
  vector<vector<int> > vv(m);
  segtree st(m + 5);
  long long ans = -0x7f7f7f7f7f7f7f7f;
  for (int i = 0; i < m; i++) {
    st.add(i, i, -v[i]);
  }
  for (int i = 0; i < n; i++) {
    int z = min(x[i], y[i]);
    int j = idx(z);
    vv[j].push_back(i);
    int zz = max(x[i], y[i]);
    int jj = idx(zz);
    st.add(jj, m - 1, c[i]);
  }
  int x1, y1, x2, y2;
  for (int i = 0; i < m; i++) {
    pair<long long, long long> val = st.MAX(i, m - 1);
    if (val.first + v[i] > ans) {
      ans = val.first + v[i];
      x1 = y1 = v[i];
      x2 = y2 = v[val.second];
    }
    for (int k : vv[i]) {
      int zz = max(x[k], y[k]);
      int jj = idx(zz);
      st.add(jj, m - 1, -c[k]);
    }
  }
  if (ans < 0) {
    ans = 0;
    for (int i = 0; i <= n; i++) {
      if (!vis[i]) {
        x1 = y1 = x2 = y2 = i;
        break;
      }
    }
  }
  cout << ans << endl;
  cout << x1 << " " << y1 << " " << x2 << " " << y2 << endl;
}
int main(void) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) solve();
  return 0;
}