Problem: Peter had a cube with non-zero length of a side. He put the cube into three-dimensional space in such a way that its vertices lay at integer points (it is possible that the cube's sides are not parallel to the coordinate axes). Then he took a piece of paper and wrote down eight lines, each containing three integers — coordinates of cube's vertex (a single line contains coordinates of a single vertex, each vertex is written exactly once), put the paper on the table and left. While Peter was away, his little brother Nick decided to play with the numbers on the paper. In one operation Nick could swap some numbers inside a single line (Nick didn't swap numbers from distinct lines). Nick could have performed any number of such operations.

When Peter returned and found out about Nick's mischief, he started recollecting the original coordinates. Help Peter restore the original position of the points or else state that this is impossible and the numbers were initially recorded incorrectly.

Input

Each of the eight lines contains three space-separated integers — the numbers written on the piece of paper after Nick's mischief. All numbers do not exceed 106 in their absolute value.

Output

If there is a way to restore the cube, then print in the first line "YES". In each of the next eight lines print three integers — the restored coordinates of the points. The numbers in the i-th output line must be a permutation of the numbers in i-th input line. The numbers should represent the vertices of a cube with non-zero length of a side. If there are multiple possible ways, print any of them.

If there is no valid way, print "NO" (without the quotes) in the first line. Do not print anything else.

Examples

Input

0 0 0
0 0 1
0 0 1
0 0 1
0 1 1
0 1 1
0 1 1
1 1 1


Output

YES
0 0 0
0 0 1
0 1 0
1 0 0
0 1 1
1 0 1
1 1 0
1 1 1


Input

0 0 0
0 0 0
0 0 0
0 0 0
1 1 1
1 1 1
1 1 1
1 1 1


Output

NO

Solution (in JAVA):

Solution:
import java.util.Scanner;

public class restorecube {

	final static int [] xperm = {0, 0, 1, 1, 2, 2};
	final static int [] yperm = {1, 2, 0, 2, 0, 1};
	final static int [] zperm = {2, 1, 2, 0, 1, 0};
	final static double sqrt2 = Math.sqrt(2);
	final static double sqrt3 = Math.sqrt(3);
	final static double EPSILON = 0.001;

	public static void main(String args[]) {
		int [][] scrambledVertices = new int[8][3];
		Scanner scan = new Scanner(System.in);
		for(int [] row : scrambledVertices) {
			for(int i = 0; i < 3; i++) {
				row[i] = scan.nextInt();
			}
		}
		// Initial vertex pair is scrambledVertices[0] and [1].
		double [] possDists = new double[7];
		// Permutations of first vertex...
		int [][] validVertices = new int[8][3];
		boolean validCombo = false;
		for(int i = 0; i < 6 && !validCombo; i++) {
			int initx = scrambledVertices[0][xperm[i]];
			int inity = scrambledVertices[0][yperm[i]];
			int initz = scrambledVertices[0][zperm[i]];
			validVertices[0][0] = initx;
			validVertices[0][1] = inity;
			validVertices[0][2] = initz;
			// Permutations of 2nd vertex.
			for(int j = 0; j < 6 && !validCombo; j++) {
				int secondx = scrambledVertices[1][xperm[j]];
				int secondy = scrambledVertices[1][yperm[j]];
				int secondz = scrambledVertices[1][zperm[j]];
				validVertices[1][0] = secondx;
				validVertices[1][1] = secondy;
				validVertices[1][2] = secondz;
				double baseDist = getDist(initx, inity, initz,
						secondx, secondy, secondz);
				if(baseDist != 0) {
					possDists[0] = baseDist;
					possDists[1] = sqrt2 * baseDist;
					possDists[2] = sqrt3 * baseDist;
					possDists[3] = baseDist / sqrt2;
					possDists[4] = baseDist / sqrt3;
					possDists[5] = sqrt2 * baseDist / sqrt3;
					possDists[6] = sqrt3 * baseDist / sqrt2;
					validCombo = recurseVerts(scrambledVertices, validVertices, 1, possDists);
				}
			}
		}
		if(validCombo) {
			System.out.println("YES");
			for (int [] row : validVertices) {
				for(int val : row) {
					System.out.print(val + " ");
				}
				System.out.println();
			}
		} else {
			System.out.println("NO");
		}
	}

	private static boolean recurseVerts(int[][] scrambledVertices,
			int[][] validVertices, int n, double[] possDists) {
		// Permutations of nth vertex.
		if(n == 7) return isCube(validVertices); // Filled all with valid vertices.
		n++;
		for(int i = 0; i < 6; i++) {
			int nextx = scrambledVertices[n][xperm[i]];
			int nexty = scrambledVertices[n][yperm[i]];
			int nextz = scrambledVertices[n][zperm[i]];
			boolean worksWithAll = true;
			// Check with all already done vertices...
			for(int j = 0; j < n && worksWithAll; j++) {
				double nextDist = getDist(validVertices[j][0], validVertices[j][1], validVertices[j][2],
						nextx, nexty, nextz);
				boolean worksWithThis = false;
				// See if distance is legal.
				// System.out.println(nextDist);
				for(int k = 0; k < 7 && !worksWithThis; k++) {
					worksWithThis = (nextDist - possDists[k] < EPSILON &&
							possDists[k] - nextDist < EPSILON);
				}
				worksWithAll = worksWithThis;
			}
			if(worksWithAll) {
				validVertices[n][0] = nextx;
				validVertices[n][1] = nexty;
				validVertices[n][2] = nextz;
				if(recurseVerts(scrambledVertices, validVertices, n, possDists)) {
					return true;
				}
			}
		}
		return false;
	}


	// Check if the given list of vertices is 100% valid as a cube.
	// TODO: THIS!!!!!
	private static boolean isCube(int[][] validVertices) {
		//		System.out.println("Checking cube-ality.");
		return true;
	}

	private static double getDist(double initx, double inity, double initz,
			double finalx, double finaly, double finalz) {
		// System.out.println(initx + ", " + inity + ", " + initz + "!");
		// System.out.println(finalx + ", " + finaly + ", " + finalz + ".");
		return Math.sqrt(Math.pow(finalx - initx, 2)
				+ Math.pow(finaly - inity, 2)
				+ Math.pow(finalz - initz, 2));
	}
}