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;
using ll = long long;
template <class t, class u>
void chmax(t& first, u second) {
  if (first < second) first = second;
}
template <class t, class u>
void chmin(t& first, u second) {
  if (second < first) first = second;
}
template <class t>
using vc = vector<t>;
template <class t>
using vvc = vc<vc<t>>;
using pi = pair<ll, ll>;
using vi = vc<ll>;
template <class t, class u>
ostream& operator<<(ostream& os, const pair<t, u>& p) {
  return os << "{" << p.first << "," << p.second << "}";
}
template <class t>
ostream& operator<<(ostream& os, const vc<t>& v) {
  os << "{";
  for (auto e : v) os << e << ",";
  return os << "}";
}
using uint = unsigned;
using ull = unsigned long long;
template <ll i, class T>
void print_tuple(ostream&, const T&) {}
template <ll i, class T, class H, class... Args>
void print_tuple(ostream& os, const T& t) {
  if (i) os << ",";
  os << get<i>(t);
  print_tuple<i + 1, T, Args...>(os, t);
}
template <class... Args>
ostream& operator<<(ostream& os, const tuple<Args...>& t) {
  os << "{";
  print_tuple<0, tuple<Args...>, Args...>(os, t);
  return os << "}";
}
void print(ll x, ll suc = 1) {
  cout << x;
  if (suc == 1) cout << "\n";
  if (suc == 2) cout << " ";
}
ll read() {
  ll i;
  cin >> i;
  return i;
}
vi readvi(ll n, ll off = 0) {
  vi v(n);
  for (ll i = ll(0); i < ll(n); i++) v[i] = read() + off;
  return v;
}
template <class T>
void print(const vector<T>& v, ll suc = 1) {
  for (ll i = ll(0); i < ll(v.size()); i++)
    print(v[i], i == ll(v.size()) - 1 ? suc : 2);
}
string readString() {
  string s;
  cin >> s;
  return s;
}
template <class T>
T sq(const T& t) {
  return t * t;
}
void yes(bool ex = true) {
  cout << "Yes" << endl;
  if (ex) exit(0);
}
void no(bool ex = true) {
  cout << "No" << endl;
  if (ex) exit(0);
}
constexpr ll ten(ll n) { return n == 0 ? 1 : ten(n - 1) * 10; }
const ll infLL = LLONG_MAX / 3;
const ll inf = infLL;
ll topbit(signed t) { return t == 0 ? -1 : 31 - __builtin_clz(t); }
ll topbit(ll t) { return t == 0 ? -1 : 63 - __builtin_clzll(t); }
ll botbit(signed first) { return first == 0 ? 32 : __builtin_ctz(first); }
ll botbit(ll first) { return first == 0 ? 64 : __builtin_ctzll(first); }
ll popcount(signed t) { return __builtin_popcount(t); }
ll popcount(ll t) { return __builtin_popcountll(t); }
bool ispow2(ll i) { return i && (i & -i) == i; }
ll mask(ll i) { return (ll(1) << i) - 1; }
bool inc(ll first, ll second, ll c) { return first <= second && second <= c; }
template <class t>
void mkuni(vc<t>& v) {
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
}
ll rand_int(ll l, ll r) {
  static random_device rd;
  static mt19937_64 gen(rd());
  return uniform_int_distribution<ll>(l, r)(gen);
}
struct Namori {
  const vi& p;
  ll n;
  vvc<ll> gr;
  vi rt;
  Namori(const vi& pp) : p(pp), n(p.size()), rt(n) {
    vi c(n);
    for (ll i = ll(0); i < ll(n); i++)
      if (p[i] != -1) c[p[i]]++;
    vi ls;
    for (ll i = ll(0); i < ll(n); i++)
      if (c[i] == 0) ls.push_back(i);
    ll j = 0;
    while (j < ll(ls.size())) {
      ll i = ls[j++];
      if (p[i] != -1 && --c[p[i]] == 0) ls.push_back(p[i]);
    }
    for (ll i = ll(0); i < ll(n); i++)
      if (c[i]) {
        ll x = i;
        vi v;
        do {
          c[x] = 0;
          rt[x] = x;
          v.push_back(x);
          x = p[x];
        } while (x != i);
        gr.push_back(v);
      }
    for (ll ii = ll(ls.size()) - 1; ii >= ll(0); ii--) {
      ll i = ls[ii];
      if (p[i] == -1)
        rt[i] = -1;
      else
        rt[i] = rt[p[i]];
    }
  }
};
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
  ll k;
  cin >> k;
  ll s = 0;
  map<ll, ll> idx;
  vvc<ll> first(k);
  vi as(k);
  vi raw, tp;
  ll sum = 0;
  for (ll i = ll(0); i < ll(k); i++) {
    ll n;
    cin >> n;
    first[i] = readvi(n);
    for (ll j = ll(0); j < ll(n); j++) {
      raw.push_back(first[i][j]);
      tp.push_back(i);
      idx[first[i][j]] = s++;
      sum += first[i][j];
      as[i] += first[i][j];
    }
  }
  if (sum % k) {
    no();
  }
  ll avg = sum / k;
  vi to(s, -1);
  for (ll i = ll(0); i < ll(s); i++) {
    ll need = avg - (as[tp[i]] - raw[i]);
    if (idx.count(need)) to[i] = idx[need];
  }
  void(0);
  auto gr = Namori(to).gr;
  vi id(1 << k, -1);
  for (ll i = ll(0); i < ll(gr.size()); i++) {
    auto z = gr[i];
    ll second = 0;
    for (auto v : z) second |= (1 << tp[v]);
    if (popcount(second) == (ll)z.size()) {
      id[second] = i;
    }
  }
  vi pre(1 << k, -1);
  pre[0] = -2;
  for (ll i = ll(1); i < ll(1 << k); i++) {
    ll sub = i;
    do {
      if (pre[sub] != -1 && id[(i ^ sub)] != -1) {
        pre[i] = i ^ sub;
        break;
      }
      sub = (sub - 1) & i;
    } while (sub != i);
  }
  void(0);
  if (pre[(1 << k) - 1] == -1) {
    no();
  }
  yes(0);
  vc<pi> ans(k);
  ll cur = (1 << k) - 1;
  while (cur) {
    ll use = pre[cur];
    auto z = gr[id[use]];
    reverse(z.begin(), z.end());
    for (ll i = ll(0); i < ll(z.size()); i++) {
      ll x = z[i], y = z[(i + 1) % z.size()];
      ans[tp[x]] = pi(raw[x], tp[y]);
    }
    cur ^= use;
  }
  for (auto w : ans) {
    cout << w.first << " " << w.second + 1 << endl;
  }
}