Problem: Ujan has a lot of numbers in his boxes. He likes order and balance, so he decided to reorder the numbers.

There are k boxes numbered from 1 to k. The i-th box contains n_i integer numbers. The integers can be negative. All of the integers are distinct.

Ujan is lazy, so he will do the following reordering of the numbers exactly once. He will pick a single integer from each of the boxes, k integers in total. Then he will insert the chosen numbers — one integer in each of the boxes, so that the number of integers in each box is the same as in the beginning. Note that he may also insert an integer he picked from a box back into the same box.

Ujan will be happy if the sum of the integers in each box is the same. Can he achieve this and make the boxes perfectly balanced, like all things should be?

Input

The first line contains a single integer k (1 ≤ k ≤ 15), the number of boxes. 

The i-th of the next k lines first contains a single integer n_i (1 ≤ n_i ≤ 5 000), the number of integers in box i. Then the same line contains n_i integers a_{i,1}, …, a_{i,n_i} (|a_{i,j}| ≤ 10^9), the integers in the i-th box. 

It is guaranteed that all a_{i,j} are distinct.

Output

If Ujan cannot achieve his goal, output "No" in a single line. Otherwise in the first line output "Yes", and then output k lines. The i-th of these lines should contain two integers c_i and p_i. This means that Ujan should pick the integer c_i from the i-th box and place it in the p_i-th box afterwards.

If there are multiple solutions, output any of those.

You can print each letter in any case (upper or lower).

Examples

Input


4
3 1 7 4
2 3 2
2 8 5
1 10


Output


Yes
7 2
2 3
5 1
10 4


Input


2
2 3 -2
2 -1 5


Output


No


Input


2
2 -10 10
2 0 -20


Output


Yes
-10 2
-20 1

Note

In the first sample, Ujan can put the number 7 in the 2nd box, the number 2 in the 3rd box, the number 5 in the 1st box and keep the number 10 in the same 4th box. Then the boxes will contain numbers \{1,5,4\}, \{3, 7\}, \{8,2\} and \{10\}. The sum in each box then is equal to 10.

In the second sample, it is not possible to pick and redistribute the numbers in the required way.

In the third sample, one can swap the numbers -20 and -10, making the sum in each box equal to -10.

Solution (in JAVA):

Solution:
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;


import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map.Entry;
import java.util.Random;
import java.util.TreeSet;

public final class CF_599_D1_C
{


	static boolean verb=true;
	static void log(Object X){if (verb) System.err.println(X);}
	static void log(Object[] X){if (verb) {for (Object U:X) System.err.print(U+" ");System.err.println("");}}
	static void log(int[] X){if (verb) {for (int U:X) System.err.print(U+" ");System.err.println("");}}
	static void log(int[] X,int L){if (verb) {for (int i=0;i<L;i++) System.err.print(X[i]+" ");System.err.println("");}}
	static void log(long[] X){if (verb) {for (long U:X) System.err.print(U+" ");System.err.println("");}}

	static void logWln(Object X){if (verb) System.err.print(X);}
	static void info(Object o){	System.out.println(o);}
	static void output(Object o){outputWln(""+o+"\n");	}
	static void outputWln(Object o){try {out.write(""+ o);} catch (Exception e) {}}

	static long mod=1000000007;

	// Global vars
	static BufferedWriter out;
	static InputReader reader;


	static class Composite implements Comparable<Composite>{
		int idx;
		int v;

		public int compareTo(Composite X) {
			if (v!=X.v)
				return v-X.v;
			return idx-X.idx;


		}

		public Composite(int idx, int v) {
			this.idx = idx;
			this.v = v;
		}



	}

	static void test() {
		log("testing");

		log("done");

	}

	static void explore(ArrayList<Integer>[] components,ArrayList<Integer> bob,int[][] move,ArrayList<int[]>[] howto,int[][] list) {

		for (int x:bob) {
			if (components[x].size()==1) {
				int tm[]=howto[x].get(0);


				int L=howto[x].size();
				howto[x].add(tm);
				for (int i=0;i<L;i++) {
					int[] cur=howto[x].get(i);
					int[] nx=howto[x].get(i+1);
					int a=cur[0];
					int a2=nx[0];
					int b2=nx[1];
					move[a2][0]=list[a2][b2];
					move[a2][1]=a;
				}

			} else {
				explore(components,components[x],move,howto,list);
			}
		}
	}


	static void process() throws Exception {


		//arrayTest();

		out = new BufferedWriter(new OutputStreamWriter(System.out));
		reader = new InputReader(System.in);


		int k=reader.readInt();
		int[][] list=new int[k][];
		long[] sum=new long[k];
		int[] L=new int[k];
		HashMap<Integer,int[]> target=new HashMap<Integer,int[]>();
		long tot=0;
		for (int i=0;i<k;i++) {
			L[i]=reader.readInt();
			list[i]=new int[L[i]];
			for (int j=0;j<L[i];j++) {
				list[i][j]=reader.readInt();
				sum[i]+=list[i][j];
				target.put(list[i][j],new int[] {i,j});
			}
			tot+=sum[i];
		}

		int MX=1<<k;
		int AX=1000000001;
		ArrayList<int[]>[] howto=new ArrayList[MX];

		log("ok with the data");

		if (tot%k!=0) {
			output("No");
		} else {

			tot/=k;





			for (int i=0;i<k;i++) {

				if (sum[i]==tot) {
					//log("nothing to do for i:"+i);
					// nothing to do
					int mask=1<<i;
					ArrayList<int[]> cand=new ArrayList<int[]>();
					cand.add(new int[] {i,0});
					howto[mask]=cand;
				} else 


					for (int j=0;j<L[i];j++) {
						int u=i;
						int v=j;
						boolean ok=true;
						int src_u=u;
						int src_v=v;
						int mask=0;
						boolean goon=true;
						ArrayList<int[]> cand=new ArrayList<int[]>();
						//log("start loop");
						while (goon) {
							cand.add(new int[] {u,v});
							//log("u:"+u+" v:"+v);
							ok=false;
							goon=false;
							long need=tot-((long)sum[u]-(long)list[u][v]);
							if (Math.abs(need)<=AX) {
								//log("need:"+need);
								int nd=(int)need;
								int[] tm=target.get(nd);
								//log("tm:"+tm);
								if (tm!=null) {
									//log("can find successor");
									int nxu=tm[0];
									int nxv=tm[1];
									if ((mask&(1<<nxu))==0) {
										mask|=1<<nxu;
										if (nxu==src_u) {
											// looping back to source
											if (nxv==src_v)
												ok=true;
										} else {
											u=nxu;
											v=nxv;
											ok=true;
											goon=true;
										}
									} 
								}
							}
						}
						if (ok) {
							if (howto[mask]==null) {

								howto[mask]=cand;

							}
						}
					}
			}

			log("step 1 done");

			// now mask


			ArrayList[] components=new ArrayList[MX];


			int[] msk=new int[MX];
			int w=0;

			for (int m=0;m<MX;m++) {
				if (howto[m]!=null) {
					//String s=Integer.toBinaryString(m);
					//while (s.length()<k)
					//	s="0"+s;
					//log("found mask:"+s);
					components[m]=new ArrayList<Integer>();
					components[m].add(m);
					msk[w++]=m;
				}
			}

			int base=w;

			for (int e=0;e<base;e++) {
				int a=msk[e];
				int ww=w;
				for (int i=0;i<ww;i++) {
					int b=msk[i];
					if ((b&a)==0) {
						int c=b|a;
						//log("creating c:"+c+" ");
						if (components[c]==null ) {
							components[c]=new ArrayList<Integer>();
							components[c].add(a);
							components[c].add(b);
							msk[w++]=c;
						}
					}
				}
			}
			//log("msk:"+msk);
			//log(components[MX-1]);
			if (components[MX-1]!=null) {
				output("Yes");
				int[][] move=new int[k][2];
				explore(components,components[MX-1],move,howto,list);
				for (int i=0;i<k;i++) {
					output(move[i][0]+" "+(move[i][1]+1));
				}

			} else {
				output("No");
			}

		}


		try {
			out.close();
		} catch (Exception e) {
		}

	}





	public static void main(String[] args) throws Exception {
		process();

	}

	static final class InputReader {
		private final InputStream stream;
		private final byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public InputReader(InputStream stream) {
			this.stream = stream;
		}

		private int read() throws IOException {
			if (curChar >= numChars) {
				curChar = 0;
				numChars = stream.read(buf);
				if (numChars <= 0) {
					return -1;
				}
			}
			return buf[curChar++];
		}

		public final String readString() throws IOException {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.append((char) c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public final int readInt() throws IOException {
			int c = read();
			boolean neg = false;
			while (isSpaceChar(c)) {
				c = read();
			}
			char d = (char) c;
			// log("d:"+d);
			if (d == '-') {
				neg = true;
				c = read();
			}
			int res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			// log("res:"+res);
			if (neg)
				return -res;
			return res;

		}

		public final long readLong() throws IOException {
			int c = read();
			boolean neg = false;
			while (isSpaceChar(c)) {
				c = read();
			}
			char d = (char) c;
			// log("d:"+d);
			if (d == '-') {
				neg = true;
				c = read();
			}
			long res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			// log("res:"+res);
			if (neg)
				return -res;
			return res;

		}

		private boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}
	}

}