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;
long long k, sum, s[5011];
map<long long, long long> posx, posy;
vector<long long> arr[20];
long long cant_take[20][5011];
long long vis[20][5011];
long long num[20][5011];
long long idx_cnt;
void dfs(long long i, long long j) {
  long long req = sum - s[i] + arr[i][j];
  vis[i][j] = true;
  if (posx.find(req) == posx.end())
    num[i][j] = -3;
  else {
    long long ii = posx[req];
    long long jj = posy[req];
    if (vis[ii][jj] and num[ii][jj] == -2 or i == ii and j == jj) {
      cant_take[ii][jj] = true;
      num[ii][jj] = idx_cnt;
      num[i][j] = idx_cnt++;
    } else if (vis[ii][jj])
      num[i][j] = -3;
    else {
      num[i][j] = -2;
      dfs(ii, jj);
      if (num[i][j] > -1)
        ;
      else if (cant_take[ii][jj])
        num[i][j] = -3;
      else
        num[i][j] = num[ii][jj];
    }
  }
}
long long bit[15 * 5011], nok_seg[15 * 5011];
long long take_this[15 * 5011];
vector<long long> ans;
long long vis2[20][5011];
long long ans_c[20], ans_p[20];
long long segx[15 * 5011], segy[15 * 5011];
vector<pair<long long, long long> > seg[15 * 5011];
void dfs2(long long i, long long j) {
  vis2[i][j] = true;
  long long req = sum - s[i] + arr[i][j];
  long long ii = posx[req];
  long long jj = posy[req];
  seg[num[i][j]].emplace_back(i, j);
  if (!vis2[ii][jj]) dfs2(ii, jj);
}
long long bit_pos[15000000];
long long dp_wew[40000], par[40000];
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  memset(num, -1, sizeof num);
  cin >> k;
  for (long long i = 0; i < k; i++) {
    long long m;
    cin >> m;
    for (long long j = 0; j < m; j++) {
      long long x;
      cin >> x;
      sum += x;
      s[i] += x;
      posx[x] = i;
      posy[x] = j;
      arr[i].push_back(x);
    }
  }
  if (sum % k) {
    cout << "No\n";
    return 0;
  }
  sum /= k;
  for (long long i = 0; i < k; i++) {
    for (long long j = 0; j < (long long)arr[i].size(); j++) {
      if (vis[i][j]) continue;
      dfs(i, j);
    }
  }
  for (long long i = 0; i < k; i++) {
    for (long long j = 0; j < (long long)arr[i].size(); j++) {
      if (num[i][j] < 0) continue;
      if (bit[num[i][j]] & (1 << i)) nok_seg[num[i][j]] = true;
      bit[num[i][j]] |= (1 << i);
      segx[num[i][j]] = i;
      segy[num[i][j]] = j;
    }
  }
  memset(bit_pos, -1, sizeof bit_pos);
  for (long long i = 0; i < idx_cnt; i++) {
    if (nok_seg[i]) continue;
    bit_pos[bit[i]] = i;
  }
  for (long long mask = 0; mask < (1 << k); mask++) {
    dp_wew[mask] = (mask == 0);
    for (long long sub = mask; sub; sub = (sub - 1) & mask) {
      if (bit_pos[sub] != -1 and dp_wew[mask ^ sub]) {
        dp_wew[mask] = 1;
        par[mask] = bit_pos[sub];
        break;
      }
    }
  }
  if (dp_wew[(1 << k) - 1] == 0)
    cout << "No\n";
  else {
    long long mask = (1 << k) - 1;
    while (mask) {
      long long ii = par[mask];
      ans.push_back(ii);
      mask ^= bit[ii];
    }
    cout << "Yes\n";
    for (long long x : ans) {
      dfs2(segx[x], segy[x]);
      long long m = (long long)seg[x].size();
      for (long long i = 0; i < m; i++) {
        long long cur_i = seg[x][i].first;
        long long cur_j = seg[x][i].second;
        long long nxt_i = seg[x][(i + 1) % m].first;
        long long nxt_j = seg[x][(i + 1) % m].second;
        ans_c[nxt_i] = arr[nxt_i][nxt_j];
        ans_p[nxt_i] = cur_i;
      }
    }
    for (long long i = 0; i < k; i++)
      cout << ans_c[i] << " " << ans_p[i] + 1 << endl;
  }
  return 0;
}