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 comment(linker, "/STACK:512000000")
using namespace std;
using li = long long;
using ld = long double;
void solve(bool);
void precalc();
clock_t start;
int main() {
  start = clock();
  int t = 1;
  cout.sync_with_stdio(0);
  cin.tie(0);
  cout.precision(20);
  cout << fixed;
  precalc();
  while (t--) {
    solve(true);
  }
  cout.flush();
  return 0;
}
template <typename T>
T binpow(T q, T w, T mod) {
  if (!w) return 1 % mod;
  if (w & 1) return q * 1LL * binpow(q, w - 1, mod) % mod;
  return binpow(q * 1LL * q % mod, w / 2, mod);
}
template <typename T>
T gcd(T q, T w) {
  while (w) {
    q %= w;
    swap(q, w);
  }
  return q;
}
template <typename T>
T lcm(T q, T w) {
  return q / gcd(q, w) * w;
}
template <typename T>
void make_unique(vector<T>& vec) {
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
}
template <typename T>
void relax_min(T& cur, T val) {
  cur = min(cur, val);
}
template <typename T>
void relax_max(T& cur, T val) {
  cur = max(cur, val);
}
mt19937 rng(
    (unsigned long long)chrono::steady_clock::now().time_since_epoch().count());
void precalc() {}
void solve(__attribute__((unused)) bool read) {
  li n;
  cin >> n;
  vector<vector<li>> vals(n);
  vector<li> initial_sum(n, 0);
  li overall_sum = 0;
  for (li i = 0; i < n; ++i) {
    li k;
    cin >> k;
    vals[i].resize(k);
    for (li j = 0; j < k; ++j) {
      cin >> vals[i][j];
      initial_sum[i] += vals[i][j];
    }
    make_unique(vals[i]);
    overall_sum += initial_sum[i];
  }
  if (overall_sum % n) {
    cout << "No\n";
    return;
  }
  li need_every = overall_sum / n;
  vector<vector<pair<li, li>>> edges(n);
  for (li i = 0; i < n; ++i) {
    edges[i].assign(vals[i].size(), {-1, -1});
    if (initial_sum[i] == need_every) {
      continue;
    }
    for (li to_erase = 0; to_erase < vals[i].size(); ++to_erase) {
      li need_rest = need_every - initial_sum[i] + vals[i][to_erase];
      for (li nex = 0; nex < n; ++nex) {
        if (nex == i) {
          continue;
        }
        auto it = lower_bound(vals[nex].begin(), vals[nex].end(), need_rest);
        if (it != vals[nex].end() && *it == need_rest) {
          edges[i][to_erase] = {nex, it - vals[nex].begin()};
          break;
        }
      }
    }
  }
  vector<vector<pair<li, li>>> good_cycles(1 << n);
  li start_mask = 0;
  for (li i = 0; i < n; ++i) {
    if (initial_sum[i] == need_every) {
      start_mask |= (1 << i);
      continue;
    }
    for (li s = 0; s < vals[i].size(); ++s) {
      vector<pair<li, li>> cycle;
      cycle.push_back({i, s});
      li cur_box = i, cur_index = s;
      li mask = (1 << cur_box);
      bool f = true;
      while (edges[cur_box][cur_index].first != -1 &&
             edges[cur_box][cur_index].first != i) {
        li new_box = edges[cur_box][cur_index].first;
        cur_index = edges[cur_box][cur_index].second;
        cur_box = new_box;
        if (mask & (1 << cur_box)) {
          f = false;
          break;
        }
        mask |= (1 << cur_box);
        cycle.push_back({cur_box, cur_index});
      }
      if (f && edges[cur_box][cur_index].first == i &&
          edges[cur_box][cur_index].second == s) {
        good_cycles[mask] = cycle;
      }
    }
  }
  vector<li> dp(1 << n, -1);
  dp[start_mask] = 0;
  for (li mask = start_mask + 1; mask < (1 << n); ++mask) {
    for (li s = mask; s > 0; s = (s - 1) & mask) {
      if (dp[mask ^ s] == -1) {
        continue;
      }
      if (!good_cycles[s].empty()) {
        dp[mask] = (mask ^ s);
        break;
      }
    }
  }
  auto cur_mask = dp[(1 << n) - 1];
  if (cur_mask == -1) {
    cout << "No\n";
    return;
  }
  cout << "Yes\n";
  cur_mask = (1 << n) - 1;
  vector<pair<li, li>> ans(n);
  for (li i = 0; i < n; ++i) {
    ans[i] = {0, i};
  }
  while (cur_mask != start_mask) {
    li s = (dp[cur_mask] ^ cur_mask);
    for (li j = 0; j < good_cycles[s].size(); ++j) {
      li prev_index = j - 1;
      if (prev_index < 0) {
        prev_index = (li)good_cycles[s].size() - 1;
      }
      ans[good_cycles[s][j].first] = {good_cycles[s][j].second,
                                      good_cycles[s][prev_index].first};
    }
    cur_mask = dp[cur_mask];
  }
  for (li i = 0; i < n; ++i) {
    cout << vals[i][ans[i].first] << " " << ans[i].second + 1 << endl;
  }
}