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

public class E implements Runnable {
	public static void main (String[] args) {new Thread(null, new E(), "_cf", 1 << 28).start();}

	HashMap<Integer, Integer> valToNode, nodeToVal, whichBox;
	int N, ptsTo[], cycleMask[], dfsStack[], tempList[];
	ArrayDeque<Integer> stack = new ArrayDeque<>();
	
	public void run() {
		FastScanner fs = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		System.err.println("");

		valToNode = new HashMap<>();
		nodeToVal = new HashMap<>();
		whichBox = new HashMap<>();
		
		int K = fs.nextInt();
		int[][] vals = new int[K][], valToNode2 = new int[K][];
		long[] sums = new long[K];
		long total = 0;
		
		for(int i = 0; i < K; i++) {
			int size = fs.nextInt();
			vals[i] = new int[size];
			valToNode2[i] = new int[size];
			for(int j = 0; j < size; j++) {
				vals[i][j] = fs.nextInt();
				sums[i] += vals[i][j];
				valToNode2[i][j] = valToNode.size();
				valToNode.put(vals[i][j], valToNode.size());
				nodeToVal.put(valToNode.size()-1, vals[i][j]);
				whichBox.put(vals[i][j], i);
			}
			total += sums[i];
		}
		if(total % K != 0) {
			System.out.println("No");
			return;
		}
		long perGroup = total/K;
		
		N = valToNode.size();
		ptsTo = new int[N];
		for(int i = 0; i < K; i++) {
			for(int j = 0; j < vals[i].length; j++) {
				long newSum = perGroup - (sums[i]-vals[i][j]);
				if(newSum > (int)1e9 || newSum < (int)-1e9) continue;
				if(valToNode.containsKey((int)newSum)) {
					ptsTo[valToNode.get(vals[i][j])] = valToNode.get((int)newSum);
				}
				else ptsTo[valToNode.get(vals[i][j])] = -1;
			}
		}
		
		tempList = new int[N];
		dfsStack = new int[N];
		cycleMask = new int[N];
		
		for(int i = 0; i < K; i++) {
			for(int j = 0; j < vals[i].length; j++) {
				int node = valToNode.get(vals[i][j]);
				if(dfsStack[node] == 0) dfs(node);
			}
		}
		
		int[] goodMask = new int[1<<K];
		Arrays.fill(goodMask, -1); goodMask[0] = 0;
		for(int mask = 1; mask < goodMask.length; mask++) {
			int idx = Integer.numberOfTrailingZeros(Integer.lowestOneBit(mask));
			for(int i = 0; i < vals[idx].length; i++) {
				int node = valToNode2[idx][i];
				if(cycleMask[node] == mask) {
					goodMask[mask] = node;
					break;
				}
			}
		}
		
		int[] dp = new int[1<<K];
		Arrays.fill(dp, -1); dp[0] = 0;
		for(int mask = 1; mask < dp.length; mask++) {
			if(goodMask[mask] != -1) {
				dp[mask] = mask;
				continue;
			}
			for(int sub = mask; sub != 0; sub = (sub-1)&mask) {
				if(goodMask[sub] == -1) continue;
				int newMask = mask-sub;
				if(dp[newMask] == -1) continue;
				
				dp[mask] = sub;
				break;
			}
		}
		
		if(dp[dp.length-1] == -1) out.println("No");
		else {
			int[][] res = new int[K][2];
			for(int[] x : res) Arrays.fill(x, -1);
			int curMask = dp.length-1;
			while(curMask > 0) {
				int temp = dp[curMask];
				int curNode = goodMask[temp];
				
				while(temp > 0) {
					int curVal = nodeToVal.get(curNode), curBox = whichBox.get(curVal);
					res[curBox][0] = curVal;
					int goingTo = ptsTo[curNode], goingVal = nodeToVal.get(goingTo), goingBox = whichBox.get(goingVal);
					res[goingBox][1] = curBox;
					curNode = ptsTo[curNode];
					temp -= 1<<curBox;
				}
				
				curMask -= dp[curMask];
			}
			
			out.println("Yes");
			for(int i = 0; i < K; i++) {
				if(res[i][1] == -1) throw null;
				out.printf("%d %d\n", res[i][0], res[i][1]+1);
			}
		}
		
		out.close();
	}
	
	void dfs(int node) {
		dfsStack[node] = 1;
		stack.addLast(node);
		int goTo = ptsTo[node];
		if(goTo == -1) {
			while(!stack.isEmpty()) {
				cycleMask[stack.pollLast()] = -1;
			}
		}
		else {
			if(dfsStack[goTo] == 1) {
				int ptr = 0, mask = 0, conflict = 0;
				while(!stack.isEmpty()) {
					int now = stack.pollLast(), val = nodeToVal.get(now), box = whichBox.get(val);
					tempList[ptr++] = now;
					if((mask & (1<<box)) > 0) conflict = 1;
					mask |= 1<<box;
					
					if(now == goTo) break;
				}
				while(!stack.isEmpty()) {
					cycleMask[stack.pollLast()] = -1;
				}
				for(int i = 0; i < ptr; i++) {
					int now = tempList[i];
					if(conflict > 0) cycleMask[now] = -1;
					else cycleMask[now] = mask;
				}
			}
			else if(dfsStack[goTo] == 2) {
				while(!stack.isEmpty()) {
					cycleMask[stack.pollLast()] = -1;
				}
			}
			else {
				dfs(goTo);
			}
		}
		
		dfsStack[node] = 2;
	}

	class FastScanner {
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

		public FastScanner() {
			in = new BufferedInputStream(System.in, BS);
		}

		public FastScanner(String s) {
			try {
				in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
			}
			catch (Exception e) {
				in = new BufferedInputStream(System.in, BS);
			}
		}

		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}                
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}

		public int nextInt() {
			return (int)nextLong();
		}

		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}

		public double nextDouble() {
			double cur = nextLong();
			return c!='.' ? cur:cur+nextLong()/num;
		}

		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}
		
		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for(int i = 0; i < n; i++) res[i] = nextInt();
			return res;
		}
		
	}

}