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 = 500000;
pair<long long, long long> points[N];
int costs[N];
struct lazySegTreeMax {
  pair<long long, long long>* tree;
  int len;
  vector<long long> lazy;
  lazySegTreeMax(const vector<int>& input, int l)
      : lazy(2 * (int)pow(2, ceil(log2(l))) - 1, 0) {
    int le = 2 * (int)pow(2, ceil(log2(l))) - 1;
    tree = new pair<long long, long long>[le];
    len = l;
    constructTree(0, len - 1, 0, input);
  }
  void constructTree(int low, int high, int pos, const vector<int>& input) {
    if (low == high) {
      tree[pos].first = 0;
      tree[pos].second = low;
      return;
    }
    int mid = (low + high) / 2;
    constructTree(low, mid, pos * 2 + 1, input);
    constructTree(mid + 1, high, pos * 2 + 2, input);
    tree[pos] = max(tree[pos * 2 + 2], tree[pos * 2 + 1]);
  }
  pair<long long, long long> query(int low, int high) {
    return rangeMax(low, high, 0, len - 1, 0);
  }
  pair<long long, long long> rangeMax(int qlow, int qhigh, int low, int high,
                                      int pos) {
    if (qlow > high || low > qhigh) {
      return {-2147483640, 0};
    }
    if (lazy[pos] != 0) {
      tree[pos].first += lazy[pos];
      if (low != high) {
        lazy[pos * 2 + 1] += lazy[pos];
        lazy[pos * 2 + 2] += lazy[pos];
      }
      lazy[pos] = 0;
    }
    if (qlow <= low && qhigh >= high) {
      return tree[pos];
    }
    int mid = (low + high) / 2;
    return max(rangeMax(qlow, qhigh, low, mid, pos * 2 + 1),
               rangeMax(qlow, qhigh, mid + 1, high, pos * 2 + 2));
  }
  void update(int ql, int qh, int incr) { update(incr, ql, qh, 0, len - 1, 0); }
  void update(int incr, int ql, int qh, int low, int high, int pos) {
    if (lazy[pos] != 0) {
      tree[pos].first += lazy[pos];
      if (low != high) {
        lazy[pos * 2 + 1] += lazy[pos];
        lazy[pos * 2 + 2] += lazy[pos];
      }
      lazy[pos] = 0;
    }
    if (ql > high || low > qh) {
      return;
    }
    if (ql <= low && high <= qh) {
      tree[pos].first += incr;
      if (low != high) {
        lazy[pos * 2 + 2] += incr;
        lazy[pos * 2 + 1] += incr;
      }
      return;
    }
    int mid = (low + high) / 2;
    update(incr, ql, qh, low, mid, pos * 2 + 1);
    update(incr, ql, qh, mid + 1, high, pos * 2 + 2);
    tree[pos] = max(tree[pos * 2 + 1], tree[pos * 2 + 2]);
  }
};
vector<pair<long long, long long> > xs(N);
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  map<int, int> mp;
  for (int i = 0; i < n; i++) {
    cin >> points[i].first >> points[i].second >> costs[i];
    if (points[i].first >= points[i].second) {
      xs[i].first = points[i].first;
      xs[i].second = i;
      mp[-points[i].second] = 0;
    } else {
      xs[i].first = points[i].second;
      xs[i].second = i;
      mp[-points[i].first] = 0;
    }
  }
  vector<int> arr(mp.size());
  int counter = 0;
  auto itr = mp.begin();
  while (itr != mp.end()) {
    arr[counter] = -(itr->first);
    itr->second = counter;
    counter++;
    itr++;
  }
  sort(xs.begin(), xs.begin() + n);
  lazySegTreeMax st(arr, counter);
  vector<bool> visited(counter, false);
  long long ans = 0;
  pair<long long, long long> coords = {-1, -1};
  int cnt = 0;
  while (cnt < n) {
    int val = xs[cnt].first;
    while (cnt < n && xs[cnt].first == val) {
      int num = xs[cnt].second;
      if (points[num].first == val) {
        int m = mp[-points[num].second];
        if (!visited[m]) {
          st.update(m, counter - 1, costs[num]);
          st.update(m, m, points[num].second);
          visited[m] = true;
        } else {
          st.update(m, counter - 1, costs[num]);
        }
      } else {
        int m = mp[-points[num].first];
        if (!visited[m]) {
          st.update(m, counter - 1, costs[num]);
          st.update(m, m, points[num].first);
          visited[m] = true;
        } else {
          st.update(m, counter - 1, costs[num]);
        }
      }
      cnt++;
    }
    pair<long long, long long> q = st.query(0, counter - 1);
    if (q.first - val > ans) {
      ans = q.first - val;
      coords.second = val;
      coords.first = arr[q.second];
    }
  }
  cout << ans << "\n";
  if (coords.first != -1) {
    cout << coords.first << " " << coords.first << " " << coords.second << " "
         << coords.second << "\n";
  } else {
    if (xs[0].first != 0) {
      cout << "0 0 0 0\n";
      return 0;
    }
    int done = false;
    for (int i = 1; i < n; i++) {
      if (xs[i].first - xs[i - 1].first > 1) {
        done = true;
        cout << xs[i].first - 1 << " " << xs[i].first - 1 << " "
             << xs[i].first - 1 << " " << xs[i].first - 1 << "\n";
      }
    }
    if (!done) {
      cout << "2000000000 2000000000 2000000000 2000000000\n";
    }
  }
}