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.DataInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Formatter;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.Queue;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

        public class Main {
            static double two=Math.sqrt(2);
            static double three=Math.sqrt(3);
            static int[][]ord=
             {
                 {0,1,2},
                 {0,2,1},
                 {1,0,2},
                 {1,2,0},
                 {2,0,1},
                 {2,1,0},
                
             };
           
            public static class Point implements Comparable<Point>
            {
                int[]coords;
                int ordId;
                public Point(int[] cc)
                {
                    coords=cc;
                    ordId=0;
                }
                public  Point getPointByOrder()
                {
                    int []ms=new int[3];
                    ms[0]=coords[ord[ordId][0]];
                    ms[1]=coords[ord[ordId][1]];
                    ms[2]=coords[ord[ordId][2]];
                    return new Point(ms);
                }
                @Override
                public int compareTo(Point o) {
                    // TODO Auto-generated method stub
                    Point a=this.getPointByOrder();
                    Point b=o.getPointByOrder();
                    if(a.coords[0]<b.coords[0])
                        return 1;
                    else
                        if(a.coords[0]>b.coords[0])
                            return -1;
                        else
                            if(a.coords[1]<b.coords[1])
                                return 1;
                            else
                                if(a.coords[1]>b.coords[1])
                                    return -1;
                                else
                                    if(a.coords[2]<b.coords[2])
                                        return 1;
                                    else
                                        if(a.coords[2]>b.coords[2])
                                            return -1;
                                        else
                                            return 0;
                    
                
                }
            }
            
            public static class Cube implements Comparable<Cube>
            {
                ArrayList<Point> Points;
                public Cube (ArrayList<Point> al)
                {
                    Points=new ArrayList<Point>();
                    for(int i=0; i<8; i++)
                        Points.add(al.get(i).getPointByOrder());
                    Collections.sort(Points);
                    int t=0;
                    t++;
                }
                @Override
                public int compareTo(Cube o) {
                    // TODO Auto-generated method stub
                    for(int i=0; i<8; i++)
                    {
                        int res=this.Points.get(i).compareTo(o.Points.get(i));
                        if(res==0)
                            continue;
                        else
                            return res;
                    }
                    return 0;
                }
            }
             public static void main(String[] args) throws IOException {
         PrintWriter pw = new PrintWriter(System.out);
         BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer stk;//=new StringTokenizer(bf.readLine());
         
         ArrayList<Point> al=new ArrayList<Point> ();
         for(int i=0; i<8; i++)
         {
             stk=new StringTokenizer(bf.readLine());
             int[] ms=new int[3];
             for(int j=0; j<3; j++)
             {
                 ms[j]=Integer.parseInt(stk.nextToken());
             }
             al.add(new Point(ms));
         }
         TreeSet <Cube> cubes=new TreeSet<Cube>();
         while(!done(al))
         {
            //Cube b=new Cube(al);
            //if(cubes.contains(b))
            //{
            //  int i=0;
                //while(al.get(i).ordId==5)
                //{
                //  al.get(i).ordId=0;
                //i++;
                //}
                //al.get(i).ordId++;
                //continue;
            //}
            double p=getMinDist(al);
            int cn[]=Count(al,p);
            if(Sq(cn))
            {
                pw.println("YES");
                for(int i=0; i<8; i++)
                {
                    Point x=al.get(i).getPointByOrder();
                    for(int j=0; j<3; j++)
                        pw.print(x.coords[j]+" ");
                    pw.println();
                    pw.flush();
                }
                return;
            }
            else
            {
                //cubes.add(b);
                int i=0;
                while(al.get(i).ordId==5)
                {
                    al.get(i).ordId=0;
                    i++;
                }
                al.get(i).ordId++;
                continue;
            }
                
         }
         pw.println("NO");
         pw.flush();
        
         
   }
             private static boolean Sq(int[] cn) {
                // TODO Auto-generated method stub
                 if(cn[0]==-1)
                     return false;
                 if(cn[0]==12 && cn[1]==12 && cn[2]==4)
                     return true;
                return false;
            }
            private static int[] Count(ArrayList<Point> al, double p)
             {
                 
                 int res[]=new int[3];
                 for(int i=0; i<8; i++)
                     for(int j=i+1; j<8; j++)
                     {
                            double c=distBetween(al.get(i).getPointByOrder(),al.get(j).getPointByOrder());
                            if(Math.abs(c-p)<=0.00000001)
                                res[0]++;
                            else
                                
                            if(Math.abs(c-two*p)<=0.00000001)
                                res[1]++;
                            else
                            if(Math.abs(c-three*p)<=0.00000001)
                                res[2]++;
                            else
                            {
                                res[0]=-1;
                                return res;
                            }
                            
                     }
                 return res;
             }
            private static double getMinDist(ArrayList<Point> al) {
                // TODO Auto-generated method stub
                double mn=-1;
                for(int i=0; i<8; i++)
                    for(int j=i+1; j<8; j++ )
                    {
                        double p=distBetween(al.get(i).getPointByOrder(),al.get(j).getPointByOrder());
                        if (i==0 && j==1)
                            mn=p;
                        if(p<mn)
                            mn=p;
                    }
                return mn;
            }
            static double distBetween(Point a, Point b)
            {
                return Math.sqrt((long)(a.coords[0]-b.coords[0])*(long)(a.coords[0]-b.coords[0])+(long)(a.coords[1]-b.coords[1])*(long)(a.coords[1]-b.coords[1])+(long)(a.coords[2]-b.coords[2])*(long)(a.coords[2]-b.coords[2]));
            }
            private static boolean done(ArrayList<Point> al) {
                // TODO Auto-generated method stub
                for(int i=0; i<7; i++)
                    if(al.get(i).ordId!=5)
                        return false;
                return true;
            }   
}
        
        
  /*
        входные данные
        0 0 0
        0 0 1
        0 0 1
        0 0 1
        0 1 1
        0 1 1
        0 1 1
        1 1 1
        выходные данные
        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
        входные данные
        0 0 0
        0 0 0
        0 0 0
        0 0 0
        1 1 1
        1 1 1
        1 1 1
        1 1 1
        выходные данные
        NO
        */