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 CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const long long maxn_node = 15 * 5010;
const long long maxn_dp_state = (1LL << 16);
long long st[maxn_node];
long long st_idx;
long long color[maxn_node];
long long sum_boxes[20];
long long revmp[maxn_node];
long long next_node[maxn_node];
long long box_number[maxn_node];
long long cnt_array[20];
long long ans_array[20];
long long ans_array2[20];
long long dp_store1[maxn_dp_state];
long long dp_store2[maxn_dp_state];
bool found[maxn_dp_state];
long long dp[maxn_dp_state];
long long path[maxn_dp_state];
map<long long, long long> mp, mp2;
map<long long, bool> exists;
vector<long long> v[20];
vector<long long> incycle_nodes;
vector<long long> nodeset[maxn_dp_state];
vector<vector<long long> > ansv;
vector<pair<long long, pair<long long, long long> > > ansv2;
long long k;
long long setbit(long long mask, long long i) { return mask | (1LL << i); }
bool checkbit(long long mask, long long i) { return mask & (1LL << i); }
void dfs(long long u) {
  st[st_idx++] = u;
  long long v = next_node[u];
  if (v == -1) return;
  color[u] = 1;
  if (color[v] == 1) {
    long long idx = st_idx - 1;
    while (idx >= 0) {
      incycle_nodes.push_back(st[idx]);
      if (st[idx] == v) break;
      idx--;
    }
  }
  if (color[v] == 0) {
    dfs(v);
  }
  color[u] = 2;
  st_idx--;
}
void dfs2(long long mask) {
  cerr << mask << endl;
  if (mask == 0) return;
  if (dp_store1[mask] == 0) {
    for (long long i = 0; i < nodeset[mask].size(); i++) {
      long long boxnumber = box_number[nodeset[mask][i]];
      ans_array[boxnumber] = revmp[nodeset[mask][i]];
    }
  } else {
    dfs2(dp_store1[mask]);
    dfs2(mask ^ dp_store1[mask]);
  }
}
long long start_node;
void dfs3(long long u) {
  long long v = next_node[u];
  assert(v != -1);
  color[u] = 1;
  if (color[v] == 1) {
    assert(v == start_node);
  }
  if (color[v] != 2)
    ansv2.push_back(
        make_pair(box_number[v], make_pair(revmp[v], box_number[u])));
  if (color[v] == 0) {
    dfs3(v);
  }
  color[u] = 2;
}
int main() {
  long long sum = 0, cnt = 0;
  scanf("%lld", &k);
  for (long long i = 1; i <= k; i++) {
    long long tempcnt = 0;
    scanf("%lld", &tempcnt);
    for (long long j = 0; j < tempcnt; j++) {
      long long temp;
      scanf("%lld", &temp);
      v[i].push_back(temp);
      sum_boxes[i] += temp;
      sum += temp;
      mp[temp] = ++cnt;
      revmp[cnt] = temp;
      box_number[cnt] = i;
      exists[temp] = true;
    }
  }
  if (sum % k) {
    printf("No\n");
    return 0;
  }
  sum /= k;
  memset(next_node, -1, sizeof next_node);
  for (long long i = 1; i <= k; i++) {
    for (long long j = 0; j < v[i].size(); j++) {
      long long newsum = sum_boxes[i] - v[i][j];
      long long need = sum - newsum;
      if (exists[need]) {
        next_node[mp[v[i][j]]] = mp[need];
      } else {
        exists.erase(need);
      }
    }
  }
  for (int i = 1; i <= cnt; i++) {
    if (color[i] == 0) {
      incycle_nodes.clear();
      dfs(i);
      if (incycle_nodes.size()) {
        bool alright = true;
        memset(cnt_array, 0, sizeof cnt_array);
        for (int j = 0; j < incycle_nodes.size(); j++) {
          long long node = incycle_nodes[j];
          long long thisbox = box_number[node];
          if (cnt_array[thisbox]) {
            alright = false;
          } else {
            cnt_array[thisbox] = true;
          }
        }
        if (alright && incycle_nodes.size()) {
          long long mask = 0;
          for (int j = 1; j <= k; j++) {
            if (cnt_array[j]) {
              mask = setbit(mask, j - 1);
            }
          }
          dp[mask] = true;
          nodeset[mask] = incycle_nodes;
        }
      }
    }
  }
  dp[0] = true;
  long long mask_all = (1LL << k) - 1;
  for (long long i = 1; i < (1LL << k); i++) {
    if (dp[i]) continue;
    for (long long s = i; s; s = (s - 1) & i) {
      if (dp[s] && dp[i ^ s]) {
        dp[i] = true;
        dp_store1[i] = s;
      }
    }
  }
  long long current_mask = (1LL << k) - 1;
  dfs2(current_mask);
  for (int i = 1; i <= k; i++) {
    cerr << ans_array[i] << endl;
  }
  current_mask = (1LL << k) - 1;
  for (int i = 1; i <= k; i++) {
    long long num_to_remove = ans_array[i];
    long long newsum = sum_boxes[i] - num_to_remove;
    long long need = sum - newsum;
    mp2[need] = i;
  }
  if (dp[current_mask]) {
    printf("Yes\n");
    memset(color, 0, sizeof color);
    for (int i = 1; i <= k; i++)
      printf("%lld %lld\n", ans_array[i], mp2[ans_array[i]]);
  } else {
    printf("No\n");
  }
  return 0;
}