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.io.BufferedReader;

import java.io.InputStreamReader;

import java.io.IOException;

import java.util.Arrays;

import java.util.StringTokenizer;

 

public class RestoreCube {

    public static void main(String[] args) {

        MyScanner sc = new MyScanner();
        
        int[] x = new int[8];
        int[] y = new int[8];
        int[] z = new int[8];
        int[][][] perms = new int[8][][];
        
        for (int i = 0; i < 8; i++) {
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
            z[i] = sc.nextInt();
            perms[i] = permute3(x[i], y[i], z[i]);
        }
        
//        int[][] p0 = permute3(x[0], y[0], z[0]);
        
        for (int a = 0; a < 6; a++)
        for (int b = 0; b < 6; b++)
        for (int c = 0; c < 6; c++)
        for (int d = 0; d < 6; d++)
        for (int e = 0; e < 6; e++)
        for (int f = 0; f < 6; f++)
        for (int g = 0; g < 6; g++)
        for (int h = 0; h < 6; h++)
        {
            if (good(perms[0][a], perms[1][b], perms[2][c], perms[3][d], perms[4][e], perms[5][f], perms[6][g], perms[7][h]) && allUnique(perms[0][a], perms[1][b], perms[2][c], perms[3][d], perms[4][e], perms[5][f], perms[6][g], perms[7][h])) {
                System.out.println("YES");
                printArr(perms[0][a]);
                printArr(perms[1][b]);
                printArr(perms[2][c]);
                printArr(perms[3][d]);
                printArr(perms[4][e]);
                printArr(perms[5][f]);
                printArr(perms[6][g]);
                printArr(perms[7][h]);
                return;
            }
        }
        System.out.println("NO");
    }
    
    public static boolean allUnique(int[] p0, int[] p1, int[] p2, int[] p3, int[] p4, int[] p5, int[] p6, int[] p7) {
        int[][] pts = new int[][] { p0, p1, p2, p3, p4, p5, p6, p7 };
        for (int i = 0; i < pts.length; i++) {
            for (int j = i + 1; j < pts.length; j++) {
                if (Arrays.equals(pts[i], pts[j])) {
                    return false;
                }
            }
        }
        return true;
    }
    
    public static void printArr(int[] arr) {
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }
        System.out.println();
    }
    
    public static boolean good(int[] x, int[] y, int[] z) {
        long[] dists = new long[7];
        for (int i = 0; i < 7; i++) {
            dists[i] = dist2(x[0], y[0], z[0], x[i + 1], y[i + 1], z[i + 1]);
        }
        Arrays.sort(dists);
        return ((dists[0] == dists[2]) && (dists[3] == dists[5]) && (2 * dists[0] == dists[3]) && (3 * dists[0] == dists[6]));
    }
    
    public static boolean good(int[] p0, int[] p1, int[] p2, int[] p3, int[] p4, int[] p5, int[] p6, int[] p7) {
        int[][] pts = new int[][] { p0, p1, p2, p3, p4, p5, p6, p7 };
        long[] dists = new long[7];
        for (int i = 0; i < 7; i++) {
            dists[i] = dist2(pts[0], pts[i + 1]);
        }
        Arrays.sort(dists);
        return ((dists[0] == dists[2]) && (dists[3] == dists[5]) && (2 * dists[0] == dists[3]) && (3 * dists[0] == dists[6]));
    }
    
    public static long dist2(int[] p0, int[] p1) {
        long sum = 0;
        for (int i = 0; i < p0.length; i++) {
            long d = (long)(p0[i] - p1[i]);
            sum += d * d;
        }
        return sum;
    }
    
    public static long dist2(long x0, long y0, long z0, long x1, long y1, long z1) {
        return (x0 - x1) * (x0 - x1) + (y0 - y1) * (y0 - y1) + (z0 - z1) * (z0 - z1);
    }
    
    public static int[][] permute3(int x, int y, int z) {
        int[][] p = new int[6][];
        p[0] = new int[] { x, y, z };
        p[1] = new int[] { x, z, y };
        p[2] = new int[] { y, x, z };
        p[3] = new int[] { y, z, x };
        p[4] = new int[] { z, x, y };
        p[5] = new int[] { z, y, x };
        return p;
    }
    
    public static class MyScanner {

        BufferedReader br;

        StringTokenizer st;

 

        public MyScanner() {

            br = new BufferedReader(new InputStreamReader(System.in));

        }

 

        int nextInt() {

            return Integer.parseInt(next());

        }

 

        long nextLong() {

            return Long.parseLong(next());

        }

 

        double nextDouble() {

            return Double.parseDouble(next());

        }

 

        String next() {

            while (st == null || !st.hasMoreElements()) {

                try {

                    st = new StringTokenizer(br.readLine());

                } catch (IOException e) {

                    e.printStackTrace();

                }

            }

            return st.nextToken();

        }

 

        String nextLine() {

            String str = "";

            try { str = br.readLine(); }

            catch (IOException e) { e.printStackTrace(); }

            return str;

        }

    }

}