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("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#pragma GCC optimize("unroll-loops")
using namespace std;
template <typename T1, typename T2>
inline void chkmin(T1 &first, T2 second) {
  if (first > second) first = second;
}
template <typename T1, typename T2>
inline void chkmax(T1 &first, T2 second) {
  if (first < second) first = second;
}
template <typename T, typename U>
inline ostream &operator<<(ostream &_out, const pair<T, U> &_p) {
  _out << _p.first << ' ' << _p.second;
  return _out;
}
template <typename T, typename U>
inline istream &operator>>(istream &_in, pair<T, U> &_p) {
  _in >> _p.first >> _p.second;
  return _in;
}
template <typename T>
inline ostream &operator<<(ostream &_out, const vector<T> &_v) {
  if (_v.empty()) {
    return _out;
  }
  _out << _v.front();
  for (auto _it = ++_v.begin(); _it != _v.end(); ++_it) {
    _out << ' ' << *_it;
  }
  return _out;
}
template <typename T>
inline istream &operator>>(istream &_in, vector<T> &_v) {
  for (auto &_i : _v) {
    _in >> _i;
  }
  return _in;
}
template <typename T>
inline ostream &operator<<(ostream &_out, const set<T> &_s) {
  if (_s.empty()) {
    return _out;
  }
  _out << *_s.begin();
  for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) {
    _out << ' ' << *_it;
  }
  return _out;
}
template <typename T>
inline ostream &operator<<(ostream &_out, const multiset<T> &_s) {
  if (_s.empty()) {
    return _out;
  }
  _out << *_s.begin();
  for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) {
    _out << ' ' << *_it;
  }
  return _out;
}
template <typename T>
inline ostream &operator<<(ostream &_out, const unordered_set<T> &_s) {
  if (_s.empty()) {
    return _out;
  }
  _out << *_s.begin();
  for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) {
    _out << ' ' << *_it;
  }
  return _out;
}
template <typename T>
inline ostream &operator<<(ostream &_out, const unordered_multiset<T> &_s) {
  if (_s.empty()) {
    return _out;
  }
  _out << *_s.begin();
  for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) {
    _out << ' ' << *_it;
  }
  return _out;
}
template <typename T, typename U>
inline ostream &operator<<(ostream &_out, const map<T, U> &_m) {
  if (_m.empty()) {
    return _out;
  }
  _out << '(' << _m.begin()->first << ": " << _m.begin()->second << ')';
  for (auto _it = ++_m.begin(); _it != _m.end(); ++_it) {
    _out << ", (" << _it->first << ": " << _it->second << ')';
  }
  return _out;
}
template <typename T, typename U>
inline ostream &operator<<(ostream &_out, const unordered_map<T, U> &_m) {
  if (_m.empty()) {
    return _out;
  }
  _out << '(' << _m.begin()->first << ": " << _m.begin()->second << ')';
  for (auto _it = ++_m.begin(); _it != _m.end(); ++_it) {
    _out << ", (" << _it->first << ": " << _it->second << ')';
  }
  return _out;
}
const int N = 15;
int k;
vector<int> val[N];
long long w[N];
vector<long long> how[(1 << N) + 228];
pair<int, int> dp[(1 << N) + 228];
unordered_set<long long> used;
unordered_map<long long, int> place;
pair<int, int> ans[N];
int main() {
  ios::sync_with_stdio(0);
  srand(time(0));
  cin >> k;
  long long sum = 0;
  for (int i = 0; i < k; ++i) {
    int n;
    cin >> n;
    val[i].resize(n);
    cin >> val[i];
    for (auto j : val[i]) {
      place[j] = i;
      sum += j;
      w[i] += j;
    }
  }
  if (sum % k != 0) {
    cout << "No\n";
    return 0;
  }
  int n = k;
  sum /= k;
  for (int i = 0; i < k; ++i) {
    for (auto j : val[i]) {
      if (used.count(j)) continue;
      vector<long long> val;
      val.push_back(j);
      while (true) {
        used.insert(val.back());
        long long delta = sum - (w[place[val.back()]] - val.back());
        if (place.count(delta) == 0) break;
        if (used.count(delta)) break;
        val.push_back(delta);
      }
      long long delta = sum - (w[place[val.back()]] - val.back());
      if (place.count(delta) == 0) continue;
      vector<long long> res;
      bool OK = false;
      for (auto q : val) {
        if (q == delta) OK = true;
        if (OK) res.push_back(q);
      }
      int mask = 0;
      for (auto q : res) {
        int id = place[q];
        if ((mask >> id) & 1) {
          mask = -1;
          break;
        }
        mask |= (1 << id);
      }
      if (mask == -1) continue;
      how[mask] = res;
    }
  }
  for (int mask = 0; mask < (1 << n); ++mask) {
    int rev = ((1 << n) - 1) ^ mask;
    int cur = (1 << n) - 1;
    auto [first, second] = dp[mask];
    if ((first | second) != mask) continue;
    while (cur > 0) {
      cur &= rev;
      if (how[cur].size()) {
        dp[mask | cur] = {mask, cur};
      }
      --cur;
    }
  }
  int mm = (1 << n) - 1;
  auto [first, second] = dp[mm];
  if ((first | second) != mm) {
    cout << "No\n";
    return 0;
  }
  vector<int> masks;
  while (mm != 0) {
    masks.push_back(dp[mm].second);
    mm = dp[mm].first;
  }
  cout << "Yes\n";
  for (int cur : masks) {
    vector<long long> res = how[cur];
    res.push_back(res[0]);
    for (int i = 0; i + 1 < res.size(); ++i) {
      ans[place[res[i + 1]]] = {res[i + 1], place[res[i]] + 1};
    }
  }
  for (int i = 0; i < n; ++i) {
    cout << ans[i] << '\n';
  }
}