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 static java.lang.Integer.*;

import java.util.*;

public class B {

	public B () {
		int [][] Q = sc.nextInts(8);

		for (int a : rep(0x100))
			if (bitCount(a) == 4 && a % 2 == 1) {
				int b = 0xff - a;
				Collection<SQ> A = squares(Q, a, true);
				Collection<SQ> B = squares(Q, b, false);

				for (SQ p : A)
					next: for (SQ q : B) {
						int [][] D = new int [4][3];
						for (int i : rep(4))
							for (int j : rep(3))
								D[i][j] = q.L[i][j] - p.L[i][j];
						for (int i : rep(4))
							for (int j : rep(3))
								if (D[i][j] != D[0][j])
									continue next;
						int [][] Y = { p.L[0], q.L[0], q.L[1], p.L[1] };
						if (square(Y)) {
							Y = new int [][] { p.L[0], q.L[0], q.L[3], p.L[3] };
							if (square(Y)) {
								int [][] res = new int [8][];
								for (int i : rep(4)) {
									res[p.J[i]] = p.L[i];
									res[q.J[i]] = q.L[i];
								}
								print("YES");
								println(res);
								return;
							}
						}
					}
			}
		exit("NO");
	}

	int [][] X = permutations(4);
	int [][] Y = permutations(3);

	class SQ {
		final int [] J;
		final int [][] L;
		SQ (int [] J, int [][] L) {
			this.J = J;
			this.L = L;
		}
		public boolean equals(Object o) {
			return Arrays.deepEquals(L, ((SQ)o).L);
		}
		public int hashCode() {
			return Arrays.deepHashCode(L);
		}
	}

	Set<SQ> squares(int [][] Q, int c, boolean fix) {
		int [] G = new int [4];
		for (int i = 0, j = 0; i < 8; ++i)
			if (has(c, i))
				G[j++] = i;

		Set<SQ> res = new HashSet<>();
		for (int [] x : X) {
			if (fix && x[0] != 0)
				continue;
			int [] J = permute(G, x);
			for (int [] y0 : Y)
				for (int [] y1 : Y)
					for (int [] y2 : Y)
						for (int [] y3 : Y) {
							int [][] y = { y0, y1, y2, y3 };
							int [][] L = new int [4][3];
							for (int i = 0; i < 4; ++i)
								for (int j = 0; j < 3; ++j)
									L[i][j] = Q[J[i]][y[i][j]];
							if (square(L))
								res.add(new SQ(J, L));
						}
		}
		return res;
	}

	boolean square(int [][] P) {
		int [] C = new int [3];
		long [][] Q = new long [4][3];
		for (int i = 0; i < 4; ++i)
			for (int j = 0; j < 3; ++j)
				C[j] += P[i][j];
		for (int i = 0; i < 4; ++i)
			for (int j = 0; j < 3; ++j)
				Q[i][j] = 4*P[i][j] - C[j];

		// Opposite sides cancel
		for (int i = 0; i < 2; ++i) {
			long D = 0;
			for (int j = 0; j < 3; ++j) {
				long Z = Q[i][j] + Q[i+2][j];
				D += Z*Z;
			}
			if (D != 0)
				return false;
		}

		// Contiguous sides are otrhogonal
		long D = 0;
		for (int j = 0; j < 3; ++j)
			D += Q[0][j] * Q[1][j];
		if (D != 0)
			return false;

		// Diagonal norms are equal and positive
		long [] Y = new long [2];
		for (int i = 0; i < 2; ++i)
			for (int j = 0; j < 3; ++j)
				Y[i] += Q[i][j] * Q[i][j];

		if (Y[0] != Y[1])
			return false;

		if (Y[0] == 0)
			return false;

		return true;
	}

	private static long and (long x, int i) { return (x & bit(i)); }
	private static long bit (int i) { return (1L << i); }
	private static boolean has(long x, int i) { return and(x, i) != 0; }
	private static int [][] permutations(int N) {
		if (N == 1)
			return new int [][] {{ 0 }};
		int [][] P = permutations(N-1);
		int [][] res = new int[N * P.length][N];
		for (int i = 0, n = 0; i < P.length; ++i)
			for (int j = 0; j < N; ++j, ++n) {
				for (int k = 0; k < N-1; ++k) {
					int x = P[i][k];
					res[n][k] = x < j ? x : x+1;
				}
				res[n][N-1] = j;
			}
		return res;
	}
	private static int [] permute(int [] A, int [] J) {
		int [] res = A.clone();
		for (int i = 0; i < J.length; ++i)
			res[i] = A[J[i]];
		return res;
	}
	private static int [] rep(int N) { return rep(0, N); }
	private static int [] rep(int S, int T) { if (T <= S) return new int [0]; int [] res = new int [T-S]; for (int i = S; i < T; ++i) res[i-S] = i; return res; }
	////////////////////////////////////////////////////////////////////////////////////
	private final static IOUtils.MyScanner sc = new IOUtils.MyScanner();
	private static void print (Object o, Object ... A) { IOUtils.print(o, A); }
	private static void println (Object o) { IOUtils.println(o); }
	private static void exit (Object o, Object ... A) { IOUtils.print(o, A); IOUtils.exit(); }
	private static class IOUtils {
		public static class MyScanner {
			public String nextLine() { return readLine(); }
			public String [] nextStrings() { return split(nextLine()); }
			public int [] nextInts() {
				String [] L = nextStrings();
				int [] res = new int [L.length];
				for (int i = 0; i < L.length; ++i)
					res[i] = Integer.parseInt(L[i]);
				return res;
			}
			public int [][] nextInts (int N) {
				int [][] res = new int [N][];
				for (int i = 0; i < N; ++i)
					res[i] = nextInts();
				return res;
			}
			private String readLine() {
				try {
					return r.readLine();
				} catch (Exception e) {
					throw new Error (e);
				}
			}
			private final java.io.BufferedReader r;
			private MyScanner () { this(new java.io.BufferedReader(new java.io.InputStreamReader(System.in))); }
			private MyScanner (java.io.BufferedReader r) {
				try {
					this.r = r;
					while (!r.ready())
						Thread.sleep(1);
					start();
				} catch (Exception e) {
					throw new Error(e);
				}
			}
			private String [] split(String s) { return s.length() > 0 ? s.split(" ") : new String [0]; }
		}
		private static String build(Object o, Object ... A) { return buildDelim(" ", o, A); }
		private static String buildDelim(String delim, Object o, Object ... A) {
			StringBuilder b = new StringBuilder();
			append(b, o, delim);
			for (Object p : A)
				append(b, p, delim);
			return b.substring(delim.length());
		}
		//////////////////////////////////////////////////////////////////////////////////
		private static void start() { if (t == 0) t = millis(); }
		private static void append(StringBuilder b, Object o, String delim) {
			if (o.getClass().isArray()) {
				int len = java.lang.reflect.Array.getLength(o);
				for (int i = 0; i < len; ++i)
					append(b, java.lang.reflect.Array.get(o, i), delim);
			} else if (o instanceof Iterable<?>)
				for (Object p : (Iterable<?>) o)
					append(b, p, delim);
			else {
				if (o instanceof Double)
					o = new java.text.DecimalFormat("#.############").format(o);
				b.append(delim).append(o);
			}
		}
		private static java.io.PrintWriter pw = new java.io.PrintWriter(System.out);
		private static void print(Object o, Object ... A) { pw.println(build(o, A)); }
		private static void println(Object o) {
			if (o.getClass().isArray()) {
				int len = java.lang.reflect.Array.getLength(o);
				for (int i = 0; i < len; ++i)
					print(java.lang.reflect.Array.get(o, i));
			} else if (o instanceof Iterable<?>)
				for (Object p : (Iterable<?>) o)
					print(p);
			else
				print(o);
		}
		private static void err(Object o, Object ... A) { System.err.println(build(o, A)); }
		private static void exit() {
			IOUtils.pw.close();
			System.out.flush();
			err("------------------");
			err(IOUtils.time());
			System.exit(0);
		}
		private static long t;
		private static long millis() { return System.currentTimeMillis(); }
		private static String time() { return "Time: " + (millis() - t) / 1000.0; }
	}
	public static void main (String[] args) { new B(); IOUtils.exit(); }
}