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 maxn = 1e6 + 5;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const double Pi = acos(-1);
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
double dpow(double a, long long b) {
  double ans = 1.0;
  while (b) {
    if (b % 2) ans = ans * a;
    a = a * a;
    b /= 2;
  }
  return ans;
}
long long quick_pow(long long x, long long y) {
  long long ans = 1;
  while (y) {
    if (y & 1) {
      ans = ans * x % mod;
    }
    x = x * x % mod;
    y >>= 1;
  }
  return ans;
}
pair<long long, long long> Max[maxn << 2];
long long lazy[maxn << 2];
long long w[maxn];
void push_up(int rt) { Max[rt] = max(Max[rt << 1], Max[rt << 1 | 1]); }
void build(int l, int r, int rt) {
  lazy[rt] = 0;
  if (l == r) {
    Max[rt].first = -w[l];
    Max[rt].second = l;
    return;
  }
  int mid = (l + r) >> 1;
  build(l, mid, rt << 1);
  build(mid + 1, r, rt << 1 | 1);
  push_up(rt);
}
void push_down(int rt, int len) {
  if (lazy[rt]) {
    lazy[rt << 1] += lazy[rt];
    lazy[rt << 1 | 1] += lazy[rt];
    Max[rt << 1].first += lazy[rt];
    Max[rt << 1 | 1].first += lazy[rt];
    lazy[rt] = 0;
  }
}
void update(int L, int R, int val, int l, int r, int rt) {
  if (L <= l && r <= R) {
    Max[rt].first += val;
    lazy[rt] += val;
    return;
  }
  int mid = (l + r) >> 1;
  push_down(rt, r - l + 1);
  if (L <= mid) update(L, R, val, l, mid, rt << 1);
  if (R > mid) update(L, R, val, mid + 1, r, rt << 1 | 1);
  push_up(rt);
}
pair<long long, long long> query(int L, int R, int l, int r, int rt) {
  if (L <= l && r <= R) {
    return Max[rt];
  }
  int mid = (l + r) >> 1;
  push_down(rt, r - l + 1);
  pair<long long, long long> ans = make_pair(-INF, 0);
  if (L <= mid) ans = max(ans, query(L, R, l, mid, rt << 1));
  if (R > mid) ans = max(ans, query(L, R, mid + 1, r, rt << 1 | 1));
  return ans;
}
long long a[maxn], b[maxn], c[maxn];
vector<long long> vec;
vector<pair<long long, long long> > mp[maxn];
int Hash[maxn];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%lld%lld%lld", &a[i], &b[i], &c[i]);
    if (a[i] > b[i]) swap(a[i], b[i]);
    vec.push_back(a[i]);
    vec.push_back(b[i]);
    if (a[i] <= 1000000) Hash[a[i]] = 1;
    if (b[i] <= 1000000) Hash[b[i]] = 1;
  }
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  int sz = vec.size();
  for (int i = 0; i < sz; i++) w[i + 1] = vec[i] - vec[0];
  build(1, sz, 1);
  for (int i = 0; i < n; i++) {
    a[i] = lower_bound(vec.begin(), vec.end(), a[i]) - vec.begin() + 1;
    b[i] = lower_bound(vec.begin(), vec.end(), b[i]) - vec.begin() + 1;
    mp[a[i]].push_back(make_pair(b[i], c[i]));
    update(b[i], sz, c[i], 1, sz, 1);
  }
  long long ans = 0;
  long long x = -1, y = -1;
  for (int i = 1; i <= 1000001; i++) {
    if (!Hash[i]) {
      x = i;
      y = i;
      break;
    }
  }
  for (int i = 1; i <= sz; i++) {
    pair<long long, long long> tmp = query(i, sz, 1, sz, 1);
    if (tmp.first > ans) {
      ans = tmp.first;
      x = vec[i - 1];
      y = vec[tmp.second - 1];
    }
    for (auto p : mp[i]) update(p.first, sz, -p.second, 1, sz, 1);
    if (i != sz) update(i + 1, sz, vec[i] - vec[i - 1], 1, sz, 1);
  }
  printf("%lld\n", ans);
  printf("%lld %lld %lld %lld\n", x, x, y, y);
  return 0;
}