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 javafx.util.Pair;

import java.io.*;
import java.util.*;
import static java.lang.Math.*;

public class Main implements Runnable
{
    boolean multiple = false;
    long MOD;

    @SuppressWarnings({"Duplicates", "ConstantConditions"})
    void solve() throws Exception
    {
        int k = sc.nextInt();
        long tar = 0;
        long[][] arr = new long[k][];
        long[] sum = new long[k];
        HashMap<Long, Pair<Integer, Integer>> map = new HashMap<>();
        for (int i = 0; i < k; i++)
        {
            int ni = sc.nextInt();
            arr[i] = new long[ni];
            for (int j = 0; j < ni; j++)
            {
                sum[i] += (arr[i][j] = sc.nextInt());
                map.put(arr[i][j], new Pair<>(i, j));
            }
            tar += sum[i];
        }
        if (tar % k != 0) { System.out.println("No"); return; }
        tar /= k;
        works = new HashMap<>();
        for (int i = 0; i < k; i++)
        {
            outer: for (int j = 0; j < arr[i].length; j++)
            {
                long val = arr[i][j];
                long want = tar - sum[i] + val;
                if (!map.containsKey(want)) continue;
//                ArrayList<pli> list = new ArrayList<>();
                int key = 1 << i;
                int next = map.get(want).getKey();
//                int prev = i;
                HashSet<Integer> seen = new HashSet<>();
                seen.add(i);
                while (true)
                {
                    if (seen.contains(next))
                    {
                        if (next == i && want == arr[i][j])
                            works.put(key, (((long) i) << 32) + ((long) j));
                        break;
                    }
//                    list.add(new pli(want, prev));
                    val = arr[next][map.get(want).getValue()];
                    want = tar - sum[next] + val;
                    if (!map.containsKey(want)) continue outer;
                    key |= 1 << next;
//                    prev = next;
                    seen.add(next);
                    next = map.get(want).getKey();
                }
            }
        }
//        dp.put(0, new ArrayList<>());
        dp = new long[1 << k];
        done = new boolean[1 << k];
        yes = new boolean[1 << k];
        yes[0] = done[0] = true;
        long ans = r((1 << k) - 1);
        long[] val = new long[k];
        int[] pos = new int[k];
        if (!yes[(1 << k) - 1]) System.out.println("No");
        else
        {
//            System.out.println(ans);
//            System.out.println(map);
            System.out.println("Yes");
            while (ans >> 32 != 0)
            {
                long p = works.get((int)(ans >> 32));
                int i = (int)(p >> 32), j = (int)(p & ((1L<<32)-1));
                long VAL = arr[i][j];
                long want = tar - sum[i] + VAL;
                int key = 1 << i;
                int next = map.get(want).getKey();
                int prev = i;
                while (true)
                {
                    if (next == i)
                    {
                        val[map.get(want).getKey()] = want;
                        pos[map.get(want).getKey()] = prev + 1;
                        if (want == arr[i][j])
                            works.put(key, (((long)i)<<32) + ((long)j));
                        break;
                    }
                    val[map.get(want).getKey()] = want;
                    pos[map.get(want).getKey()] = prev + 1;
                    VAL = arr[next][map.get(want).getValue()];
                    want = tar - sum[next] + VAL;
                    key |= 1 << next;
                    prev = next;
                    next = map.get(want).getKey();
                }

                ans = dp[(int)(ans & ((1L << 32)- 1))];
            }
            for (int i = 0; i < k; i++)
                System.out.println(val[i] + " " + pos[i]);
        }
    }

    HashMap<Integer, Long> works;
    long[] dp;
    boolean[] done, yes;

    long r(int mask)
    {
        if (done[mask]) return dp[mask];
        done[mask] = true;
        for (int s = mask; s != 0; s = (s-1) & mask)
            if (works.keySet().contains(s))
            {
                int tempMask = mask;
                for (int i = 0; i < 16; i++)
                    if ((s & (1 << i)) != 0)
                        tempMask ^= 1 << i;
                r(tempMask);
                if (yes[tempMask])
                {
                    yes[mask] = true;
                    return dp[mask] = (((long)s) << 32) + tempMask;
                }
            }
        return 0;
    }

    class pii { int f, s; pii(int k, int v) { f = k; s = v; } }
    class pli { long f; int s; pli(long k, int v) { f = k; s = v; } public String toString() { return "(" + f + ", " + s + ")"; } }
    StringBuilder ANS = new StringBuilder();
    void p(Object s) { ANS.append(s); } void p(double s) {ANS.append(s); } void p(long s) {ANS.append(s); } void p(char s) {ANS.append(s); }
    void pl(Object s) { ANS.append(s); ANS.append('\n'); } void pl(double s) { ANS.append(s); ANS.append('\n'); } void pl(long s) { ANS.append(s); ANS.append('\n'); } void pl(char s) { ANS.append(s); ANS.append('\n'); } void pl() { ANS.append(('\n')); }
    /*I/O, and other boilerplate*/ @Override public void run() { try { in = new BufferedReader(new InputStreamReader(System.in));out = new PrintWriter(System.out);sc = new FastScanner(in);if (multiple) { int q = sc.nextInt();for (int i = 0; i < q; i++) solve(); } else solve(); System.out.print(ANS); } catch (Throwable uncaught) { Main.uncaught = uncaught; } finally { out.close(); }} public static void main(String[] args) throws Throwable{ Thread thread = new Thread(null, new Main(), "", (1 << 26));thread.start();thread.join();if (Main.uncaught != null) {throw Main.uncaught;} } static Throwable uncaught; BufferedReader in; FastScanner sc; PrintWriter out; } class FastScanner { BufferedReader in; StringTokenizer st; public FastScanner(BufferedReader in) {this.in = in;}public String nextToken() throws Exception { while (st == null || !st.hasMoreTokens()) { st = new StringTokenizer(in.readLine()); }return st.nextToken(); }public int nextInt() throws Exception { return Integer.parseInt(nextToken()); }public long nextLong() throws Exception { return Long.parseLong(nextToken()); }public double nextDouble() throws Exception { return Double.parseDouble(nextToken()); }
}