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 P599E {
    public static long average;
    public static long[] boxSums;
    public static HashMap<Long, Entry> numToEntry;
    public static HashMap<Integer, ArrayList<Long>> cycleMap;
    public static DPEntry[] dp;
    public static int k;
    public static boolean debug;
    public static boolean recording;
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        debug = false;
        recording = false;

        k = Integer.parseInt(br.readLine());
        ArrayList<ArrayList<Entry>> boxes = new ArrayList<>();
        boxSums = new long[k];
        numToEntry = new HashMap<>();
        cycleMap = new HashMap<>();
        dp = new DPEntry[1 << k];
        dp[0] = new DPEntry();
        dp[0].b = true;
        long total = 0;
        for(int i=0; i<k; i++) {
            String[] line = br.readLine().split(" ");
            ArrayList<Entry> box = new ArrayList<>();
            boxes.add(box);
            for(int j=1; j<line.length; j++) {
                long val = Long.parseLong(line[j]);
                if(i == 0 && j == 1 && val == -446845155) {
                    //debug = true;
                }
                Entry ent = new Entry(val, i);
                box.add(ent);
                numToEntry.put(val, ent);
                boxSums[i] += val;
                total += val;
            }
        }
        if(total % k != 0) {
            System.out.println("No");
        } else {
            average = total / k;
            for(int i=0; i<k; i++) {
                ArrayList<Entry> box = boxes.get(i);
                for(Entry ent : box) {
                    if(!ent.visited) {
                        ExploreNode node = explore(ent, new ExploreNodeDeque());
                        if(node != null)
                            cycleMap.put(node.mask, node.nums);
                    }
                }
            }
            DPEntry answer = goDP((1<<k) - 1);
            if(answer.b) {
                System.out.println("Yes");
                long[] vals = new long[k];
                int[] dests = new int[k];
                for(int mask : answer.masks) {
                    ArrayList<Long> nums = cycleMap.get(mask);
                    if(debug) {
                        System.out.println("Mask: " + Integer.toBinaryString(mask));
                        for(int m=0; m<nums.size(); m++) {
                            System.out.print(numToEntry.get(nums.get(m)).boxIndex + ": ");
                            System.out.print(nums.get(m) + " | ");
                        }
                        System.out.println();
                    }
                    for(int i=0; i<nums.size(); i++) {
                        int dest = numToEntry.get(nums.get((i-1+nums.size()) % nums.size())).boxIndex + 1;
                        int index = numToEntry.get(nums.get(i)).boxIndex;
                        vals[index] = nums.get(i);
                        dests[index] = dest;
                    }
                }
                for(int i=0; i<k; i++) {
                    System.out.println(vals[i] + " " + dests[i]);
                }
            } else {
                System.out.println("No");
            }
        }
    }

    public static DPEntry goDP(int index) {
        if(dp[index] != null) {
            return dp[index];
        } else {
            for(int submask = index; submask > 0; submask = (submask - 1) & index) {
                DPEntry inv = goDP(~submask & index);
                if(cycleMap.containsKey(submask) && inv.b) {
                    dp[index] = new DPEntry();
                    dp[index].b = true;
                    dp[index].masks.add(submask);
                    dp[index].masks.addAll(inv.masks);
                    break;
                }
            }
            if(dp[index] == null) {
                dp[index] = new DPEntry();
            }
        }
        return dp[index];
    }

    // call with an empty node to start
    public static ExploreNode explore(Entry ent, ExploreNodeDeque node) {
        if(debug && (ent.num == 61717176 || ent.num == 61619898 || ent.num == -76364152 || ent.num == 61846396 || ent.num == -75886071
        || ent.num == 59883050 || ent.num == 62090352 || ent.num == -75910923 || ent.num == -76591758 || ent.num == 60476221
        || ent.num == 68206001 || ent.num == -75662008 || ent.num == 61171623 || ent.num == -76155301 || ent.num == 60641509 ) && false)
            recording = true;
        if(ent.visited) {
            if(recording) {
                System.out.println("Already Visited: " + ent.boxIndex + " " + ent.num);
                recording = false;
            }
            return null;
        }
        ent.visited = true;
        node.mask += (1 << ent.boxIndex);
        node.nums.add(ent.num);

        long numberNeeded = average - boxSums[ent.boxIndex] + ent.num;
        Entry nextEntry = numToEntry.getOrDefault(numberNeeded, null);

        if(nextEntry == null) {
            if(recording) {
                System.out.println("Next Entry is Non-Existent: " + ent.boxIndex + " " + ent.num);
                recording = false;
            }
            return null;
        } else {
            //if((node.mask & (1 << nextEntry.boxIndex)) > 0) {
                // valid cycle backtrack and return
                if(node.nums.contains(nextEntry.num)) {
                    ExploreNode ret = new ExploreNode();
                    long curNum = node.nums.peek();
                    while(curNum != nextEntry.num) {
                        node.nums.poll();
                        curNum = node.nums.peek();
                    }
                    ret.nums = new ArrayList<>();
                    while(!node.nums.isEmpty()) {
                        ret.nums.add(node.nums.poll());
                    }
                    for(int i=0; i<ret.nums.size(); i++) {
                        int numMask = (1 << numToEntry.get(ret.nums.get(i)).boxIndex);
                        if((ret.mask & numMask) > 0) {
                            return null;
                        }
                        else {
                            ret.mask += numMask;
                        }
                    }
                    if(recording) {
                        System.out.println("Valid Cycle Found " + ent.boxIndex + " " + ent.num);
                        System.out.println(ret.mask);
                        recording = false;
                    }
                    return ret;
                }
                else {
                    if(node.nums.size() > 16) {
                        node.nums.poll();
                    }
                }
            //}
            if(recording) {
                System.out.println("Exploring From: " + ent.boxIndex + " " + ent.num);
                System.out.println("To: " + nextEntry.boxIndex + " " + nextEntry.num);
            }
            return explore(nextEntry, node);
        }
    }
}

class ExploreNode {
    public int mask;
    public ArrayList<Long> nums;
    public ExploreNode() {
        nums = new ArrayList<>();
        mask = 0;
    }
}

class ExploreNodeDeque {
    public int mask;
    public ArrayDeque<Long> nums;
    public ExploreNodeDeque() {
        nums = new ArrayDeque<>();
        mask = 0;
    }
}

class DPEntry {
    public boolean b;
    public ArrayList<Integer> masks;
    public DPEntry() {
        b = false;
        masks = new ArrayList<>();
    }
}

class Entry {
    public int boxIndex;
    public long num;
    public boolean visited;
    public Entry(long number, int i) {
        boxIndex = i;
        num = number;
        visited = false;
    }
}