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 JAVA):

Solution:

//package week3;

import java.io.*;
import java.util.*;

public class ChooseSquare {

	public static void main(String[] args) throws IOException {

		ChooseSquare obj = new ChooseSquare();

		obj.doStuff();

	}
	
	class SortArr implements Comparator<int[]> {

		@Override
		public int compare(int[] o1, int[] o2) {
			return o1[1]-o2[1];
		}
		
	}
	
	class SegData {
		long totalSum = 0, suffixSum = Integer.MIN_VALUE, startPoint = -1;
	}
	SegData[] st; int l = 1; // 0 is total, 1 is suffix
	void init() {
		while (l <= coords.length) l*=2;
		st = new SegData[l*2];
		for (int i = 0; i < st.length; i++) {
			st[i] = new SegData();
		}
	}
	long findcoord(long index) {
		if (index==-1) return 0;
		return coords[(int) index];
	}
	void u(int p, int v, boolean adding) {
		p+=l;
		st[p].totalSum += v;
		if (st[p].suffixSum == Integer.MIN_VALUE) st[p].suffixSum = v;
		else st[p].suffixSum += v;
		st[p].startPoint = (adding)?(p-l-1):-1;
		p /= 2;
		while (p > 0) {
			st[p].totalSum = st[p*2].totalSum+st[p*2+1].totalSum;
			long rightinc = st[p*2+1].startPoint;
			long leftinc = st[p*2].startPoint;
			if (leftinc == -1) {
				st[p].suffixSum = Math.max(0, st[p*2+1].suffixSum);
				st[p].startPoint = st[p*2+1].startPoint;
			}
			else if (rightinc == -1) {
				st[p].suffixSum = Math.max(0, st[p*2].suffixSum+st[p*2+1].totalSum);
				st[p].startPoint = st[p*2].startPoint;
			} else {
				long right = st[p*2+1].suffixSum;
				long left = st[p*2].suffixSum+st[p*2+1].totalSum;
				rightinc = findcoord(rightinc);
				leftinc = findcoord(leftinc);
				if (right+rightinc >= left+leftinc) {
					st[p].suffixSum = Math.max(0, right);
					st[p].startPoint = st[p*2+1].startPoint;
				} else {
					st[p].suffixSum = Math.max(0, left);
					st[p].startPoint = st[p*2].startPoint;
				}
			}
			p /= 2;
		}
	}
	
	int bs(int val) {
		int l = 0, r = coords.length-1;
		while (l < r) {
			int m = (l+r)/2;
			if (coords[m] == val) {
				if (m==0 || coords[m-1] != val) return m;
				else r = m;
			}
			else if (coords[m] > val) r = m;
			else l = m+1;
		}
		return l;
	}

	int[] coords;
	int[][] data;
	private void doStuff() throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int squares = Integer.parseInt(br.readLine());
		data = new int[squares][2];
		coords = new int[squares*2];
		for (int i = 0; i < data.length; i++) {
			StringTokenizer st = new StringTokenizer(br.readLine());
			int a = Integer.parseInt(st.nextToken());
			int b = Integer.parseInt(st.nextToken());
			int c = Integer.parseInt(st.nextToken());
			data[i] = new int[] {Math.min(a, b), Math.max(a, b), c};
			coords[i*2] = a; coords[i*2+1] = b;
		}
		br.close();
		
		Arrays.sort(coords);
		Arrays.sort(data, new SortArr());
		init();
		int[] count = new int[coords.length];
		for (int i = 0; i < data.length; i++) {
			int pos = bs(data[i][0]);
			count[pos]++;
			u(pos+1, data[i][2], true);
		}
		long ans = 0;
		long bestleft = Integer.MAX_VALUE;
		long bestright = Integer.MAX_VALUE;
		int last = Integer.MAX_VALUE;
		for (int i = data.length-1; i >= 0; i--) {
			if (last != data[i][1]) {
				if (ans < this.st[1].suffixSum+findcoord(st[1].startPoint)-data[i][1]) {
					ans = this.st[1].suffixSum+findcoord(st[1].startPoint)-data[i][1];
					bestleft = this.st[1].startPoint;
					bestright = i;
				}
			}
			int pos = bs(data[i][0]);
			count[pos]--;
			u(pos+1, -(data[i][2]), (count[pos] != 0));
			last = data[i][1];
		}
		System.out.println(ans);
		if (bestright == Integer.MAX_VALUE) {
			int val = coords[coords.length-1]+1;
			System.out.println(val+" "+val+" "+val+" "+val);
		} else if (bestleft == Integer.MAX_VALUE) {
			int val = data[(int) bestright][1];
			System.out.println(val+" "+val+" "+val+" "+val);
		} else {
			bestleft = coords[(int) bestleft];
			bestright = data[(int) bestright][1];
			System.out.println(bestleft+" "+bestleft+" "+bestright+" "+bestright);
		}
	}

}