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 MOD = 1e9 + 7;
const int INF = 1e9;
const long long IINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const char dir[4] = {'D', 'R', 'U', 'L'};
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for (T &x : v) is >> x;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for (int i = 0; i < v.size(); ++i) {
    os << v[i] << (i + 1 == v.size() ? "" : " ");
  }
  return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << '(' << p.first << ',' << p.second << ')';
  return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &m) {
  os << '{';
  for (auto itr = m.begin(); itr != m.end(); ++itr) {
    os << '(' << itr->first << ',' << itr->second << ')';
    if (++itr != m.end()) os << ',';
    --itr;
  }
  os << '}';
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const set<T> &s) {
  os << '{';
  for (auto itr = s.begin(); itr != s.end(); ++itr) {
    os << *itr;
    if (++itr != s.end()) os << ',';
    --itr;
  }
  os << '}';
  return os;
}
void debug_out() { cerr << '\n'; }
template <class Head, class... Tail>
void debug_out(Head &&head, Tail &&...tail) {
  cerr << head;
  if (sizeof...(Tail) > 0) cerr << ", ";
  debug_out(move(tail)...);
}
template <typename T>
T gcd(T x, T y) {
  return y != 0 ? gcd(y, x % y) : x;
}
template <typename T>
T lcm(T x, T y) {
  return x / gcd(x, y) * y;
}
template <class T1, class T2>
inline bool chmin(T1 &a, T2 b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T1, class T2>
inline bool chmax(T1 &a, T2 b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
using T = tuple<int, int, int>;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int k;
  cin >> k;
  vector<int> n(k);
  vector<vector<int>> a(k);
  map<int, int> mp;
  vector<long long> sum(k, 0);
  long long whole = 0;
  for (int i = 0; i < k; ++i) {
    cin >> n[i];
    for (int j = 0; j < n[i]; ++j) {
      int A;
      cin >> A;
      a[i].emplace_back(A);
      mp[A] = i;
      sum[i] += A;
    }
    whole += sum[i];
  }
  if (whole % k != 0) {
    cout << "No" << '\n';
    return 0;
  }
  long long ave = whole / k;
  auto check = [&](int i, int A) -> vector<T> {
    vector<T> res;
    map<int, int> take;
    while (1) {
      take[i] = A;
      long long nxt = ave - (sum[i] - A);
      if (nxt < -INF || INF < nxt) return {};
      if (!mp.count(nxt)) return {};
      int j = mp[nxt];
      res.emplace_back(j, nxt, i);
      if (take.count(j)) {
        if (take[j] != nxt) return {};
        sort(res.begin(), res.end());
        return res;
      }
      i = j, A = nxt;
    }
  };
  pair<int, int> imp = {-1, -1}, ori = {0, 0};
  vector<pair<int, int>> dp(1 << k, imp);
  map<int, vector<T>> can;
  for (int i = 0; i < k; ++i) {
    for (int j = 0; j < n[i]; ++j) {
      vector<T> used = check(i, a[i][j]);
      if (used.empty()) continue;
      vector<int> v;
      for (auto t : used) v.emplace_back(get<0>(t));
      int mask = 0;
      for (int x : v) mask |= (1 << x);
      if (__builtin_popcount(mask) != v.size()) continue;
      if (!can.count(mask)) {
        can[mask] = used;
        dp[mask] = ori;
      }
    }
  }
  dp[0] = imp;
  for (int mask = 1; mask < (1 << k); ++mask) {
    if (dp[mask] == ori) continue;
    for (int sub = mask;; sub = (sub - 1) & mask) {
      if (dp[sub] != imp && dp[mask ^ sub] != imp) dp[mask] = {sub, mask ^ sub};
      if (!sub) break;
    }
  }
  if (dp[(1 << k) - 1] == imp) {
    cout << "No" << '\n';
    return 0;
  }
  cout << "Yes" << '\n';
  queue<int> que;
  que.emplace((1 << k) - 1);
  vector<T> ans;
  while (!que.empty()) {
    int mask = que.front();
    que.pop();
    if (dp[mask] == ori) {
      for (auto t : can[mask]) {
        ans.emplace_back(t);
      }
    } else {
      que.emplace(dp[mask].first);
      que.emplace(dp[mask].second);
    }
  }
  sort(ans.begin(), ans.end());
  for (int i = 0; i < k; ++i)
    cout << get<1>(ans[i]) << ' ' << get<2>(ans[i]) + 1 << '\n';
}