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>
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-O3")
#pragma GCC optimize("Ofast")
using namespace std;
const int oo = 2e9;
const long long OO = 4e18;
const long double pi = arg(complex<long double>(-1, 0));
const long double pi2 = pi + pi;
const int md = 0x3b800001;
const int MD = 1e9 + 7;
inline long long time() {
  return chrono ::system_clock().now().time_since_epoch().count();
}
mt19937 rnd(time());
mt19937_64 RND(time());
const int N = 1e5 + 228;
inline string bin(int x, int n) {
  string ans = "";
  for (int i = 0; i < n; ++i) ans += '0' + (x & 1), x >>= 1;
  return ans;
}
int k, m, n[16], a[16][5007];
long long s[16];
pair<int, int> ans[16];
unordered_map<int, int> v;
void solve() {
  cin >> k;
  m = 1 << k;
  for (int i = 0; i < k; ++i) s[i] = 0;
  long long S = 0;
  v.clear();
  for (int i = 0; i < k; ++i) {
    cin >> n[i];
    for (int j = 0; j < n[i]; ++j)
      cin >> a[i][j], v[a[i][j]] = i, s[i] += a[i][j];
    S += s[i];
  }
  if (S % k) {
    cout << "No\n";
    return;
  }
  S /= k;
  unordered_map<int, vector<pair<int, int> > > D;
  for (int i = 0; i < k; ++i)
    for (int j = 0; j < n[i]; ++j) {
      bool bad = 0;
      int f = i;
      int ms = 0;
      long long e = a[i][j];
      vector<pair<int, int> > g;
      if (s[i] != S) {
        while (1) {
          e = S - (s[f] - e);
          g.emplace_back(e, f + 1);
          if (abs(e) > oo || v.find((int)e) == v.end()) {
            bad = 1;
            break;
          }
          f = v[e];
          if (ms & (1 << f)) {
            bad = 1;
            break;
          }
          ms |= (1 << f);
          if (e == a[i][j]) break;
        }
      } else {
        g.assign(1, {a[i][j], i + 1});
        ms = (1 << i);
      }
      reverse(g.begin(), g.end());
      if (bad) continue;
      if (D.find(ms) == D.end()) D[ms] = g;
    }
  int dp[m];
  memset(dp, 0, sizeof dp);
  for (auto &a : D) dp[m - 1 - a.first] = a.first;
  for (int i = m - 1; i; --i)
    if (dp[i]) {
      vector<int> z;
      for (int t = 0; t < k; ++t)
        if (i & (1 << t)) z.emplace_back((1 << t));
      int j = int(z.size());
      for (int t = 0; t < (1 << j); ++t)
        if (t) {
          int u = 0;
          for (int w = 0; w < j; ++w)
            if (t & (1 << w)) u |= z[w];
          if (D.find(u) == D.end()) continue;
          dp[i - u] = u;
        }
    }
  if (!(dp[0])) {
    cout << "No\n";
    return;
  }
  for (int i = 0; i + 1 < m; i += dp[i]) {
    int u = dp[i];
    for (pair<int, int> p : D[u]) ans[v[p.first]] = p;
  }
  cout << "Yes\n";
  for (int i = 0; i < k; ++i)
    cout << ans[i].first << ' ' << ans[i].second << endl;
}
int main() {
  ios_base ::sync_with_stdio(0);
  solve();
  return 0;
}