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.*;
import java.io.*;
import java.lang.*;

public class RestoreCube {

	public static final double sqrtTwo = Math.sqrt(2);
	public static final double sqrtThree = Math.sqrt(3);
	public static final double standardError = 0.000001;

	public static void main(String[] args) {
		MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out)); 

        long[][] points = new long[8][3];

        for (int i = 0; i < points.length; i++) {
        	for (int j = 0; j < points[0].length; j++) {
        		points[i][j] = sc.nextInt();
        	}
        }

        // for (int a = 0; a < 6; a++) {
        // 	points[0] = newComb(points, 0, a);
        // 0, 4, 4, 1, 3, 4, 2, 1

        long[][] testingArray = new long[8][3];
        testingArray[0] = points[0];
        	for (int b = 0; b < 6; b++) {
        		testingArray[1] = newComb(points, 1, b);
        		for (int c = 0; c < 6; c++) {
        			testingArray[2] = newComb(points, 2, c);
        			for (int d = 0; d < 6; d++) {
        				testingArray[3] = newComb(points, 3, d);
        				for (int e = 0; e < 6; e++) {
        					testingArray[4] = newComb(points, 4, e);
        					for (int f = 0; f < 6; f++) {
        						testingArray[5] = newComb(points, 5, f);
        						for (int g = 0; g < 6; g++) {
        							testingArray[6] = newComb(points, 6, g);
        							for (int h = 0; h < 6; h++) {
        								testingArray[7] = newComb(points, 7, h);
        								// if (b == 5 && c == 4 && d == 1 && e == 3 && f == 4 & g == 2 && h == 1) {
        								// 	out.println("TEST IS TRUE!");
        								// 	printTrueResult(testingArray);
        								// }
        								if (isCube(testingArray)) {
        									printTrueResult(testingArray);
        									out.close();
        									System.exit(0);
        								}
        							}
        						}
        					}
        				}
        			}
        		}
        	}
        // }

        out.println("NO");


        out.close();
        System.exit(0);
	}

	public static void printTrueResult(long[][] points) {
		out.println("YES");
		for (int i = 0; i < points.length; i++) {
			for (int j = 0; j < points[0].length; j++) {
				out.print(points[i][j] + " ");
			}
			out.println();
		}
	}

	public static boolean isCube(long[][] points) {
		HashMap<Double, Integer> map = new HashMap<Double, Integer>();

		for (int a = 1; a < 8; a++) {
			double distance = findDistance(points[0], points[a]);
			if (map.containsKey(distance)) {
				int count = map.get(distance);
				count++;
				map.put(distance, count);
			}
			else {
				map.put(distance, 1);
			}
		}
		for (int b = 2; b < 8; b++) {
			double distance = findDistance(points[1], points[b]);
			if (map.containsKey(distance)) {
				int count = map.get(distance);
				count++;
				map.put(distance, count);
			}
			else {
				map.put(distance, 1);
			}
		}	
		for (int c = 3; c < 8; c++) {
			double distance = findDistance(points[2], points[c]);
			if (map.containsKey(distance)) {
				int count = map.get(distance);
				count++;
				map.put(distance, count);
			}
			else {
				map.put(distance, 1);
			}
		}
		for (int d = 4; d < 8; d++) {
			double distance = findDistance(points[3], points[d]);
			if (map.containsKey(distance)) {
				int count = map.get(distance);
				count++;
				map.put(distance, count);
			}
			else {
				map.put(distance, 1);
			}
		}
		for (int e = 5; e < 8; e++) {
			double distance = findDistance(points[4], points[e]);
			if (map.containsKey(distance)) {
				int count = map.get(distance);
				count++;
				map.put(distance, count);
			}
			else {
				map.put(distance, 1);
			}
		}
		for (int f = 6; f < 8; f++) {
			double distance = findDistance(points[5], points[f]);
			if (map.containsKey(distance)) {
				int count = map.get(distance);
				count++;
				map.put(distance, count);
			}
			else {
				map.put(distance, 1);
			}
		}
		for (int g = 7; g < 8; g++) {
			double distance = findDistance(points[6], points[g]);
			if (map.containsKey(distance)) {
				int count = map.get(distance);
				count++;
				map.put(distance, count);
			}
			else {
				map.put(distance, 1);
			}					
		}

		// int[][] test = {{-5, -3, -8}, {-5, 8, -8}, {6, -3, 3}, {6, 8, 3}, 
		// 				{6, -3, -8}, {6, 8, -8}, {-5, -3, 3}, {-5, 8, 3}};
		// if (isEqual(points, test)) {
		// 	out.println(map);
		// }


		if (map.size() == 3) {
			// out.println(map);
			TreeSet<Double> keys = new TreeSet<Double>();
			for (Double key : map.keySet()) {
				keys.add(key);
			}
			double min = keys.pollFirst();
			double mid = keys.pollFirst();
			double max = keys.pollFirst();

			if (map.get(min) == 12 && map.get(mid) == 12 && map.get(max) == 4) {
				// out.println("IS CUBE IS RETURNING TRUE");
				// out.println(map);
				return true;
			}

		}

		return false;
	}

	public static boolean isEqual (long[][] points, long[][] test) {
		for (int i = 0; i < points.length; i++) {
			for (int j = 0; j < points[0].length; j++) {
				if (points[i][j] != test[i][j])
					return false;
			}
		}
		return true;
	}

	public static double findDistance(long[] point1, long[] point2) {
		return Math.sqrt(((point2[0] - point1[0]) * (point2[0] - point1[0])) + 
			((point2[1] - point1[1]) * (point2[1] - point1[1])) + 
			((point2[2] - point1[2]) * (point2[2] - point1[2])));
	}

	// 4, 1, 3, 2, 0, 3, 5, 2
	// {{-5, -3, -8}, {-5, 8, -8}, {6, -3, 3}, {6, 8, 3}, 
	//	{6, -3, -8}, {6, 8, -8}, {-5, -3, 3}, {-5, 8, 3}};
	// 0, 5, 4, 1, 3, 4, 2, 1
	public static long[] newComb(long[][] points, int row, int combNum) {
		long[] result = new long[3];;
		switch(combNum) {
			case 0:
				return points[row];
			case 1:
				result[0] = points[row][0];
				result[1] = points[row][2];
				result[2] = points[row][1];
				return result;
			case 2:
				result[0] = points[row][1];
				result[1] = points[row][0];
				result[2] = points[row][2];
				return result;
			case 3:
				result[0] = points[row][1];
				result[1] = points[row][2];
				result[2] = points[row][0];
				return result;
			case 4:
				result[0] = points[row][2];
				result[1] = points[row][0];
				result[2] = points[row][1];
				return result;
			case 5:
				result[0] = points[row][2];
				result[1] = points[row][1];
				result[2] = points[row][0];
				return result;
			default:
				break;
		}

		return null;
	}

	//-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;

    //-----------MyScanner class for faster input----------------------------------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}