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>
template <class T>
int gmax(T &a, T b) {
  if (b > a) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
int gmin(T &a, T b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
using namespace std;
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char *s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
const int MAXN = 75005;
vector<int> graph[MAXN];
vector<int> group[MAXN];
int dfn[MAXN], low[MAXN];
int dcnt;
int col[MAXN + 5], ccnt;
bool vis[MAXN + 5];
int stk[MAXN + 5], tp;
vector<pair<int, int>> dp[32768];
void Tarjan_scc(int u) {
  dfn[u] = ++dcnt, low[u] = dcnt, vis[u] = true;
  stk[++tp] = u;
  for (int i = 0; i < (int)graph[u].size(); i++) {
    int v = graph[u][i];
    if (!dfn[v]) {
      Tarjan_scc(v);
      low[u] = min(low[u], low[v]);
    } else if (vis[v])
      low[u] = min(low[u], low[v]);
  }
  if (dfn[u] == low[u]) {
    ++ccnt;
    while (true) {
      col[stk[tp]] = ccnt;
      vis[stk[tp]] = false;
      if (stk[tp--] == u) break;
    }
  }
}
int main() {
  int k;
  while (~scanf("%d", &k)) {
    tp = -1;
    ccnt = 0;
    dcnt = 0;
    for (int i = 0; i < MAXN; ++i) {
      dfn[i] = 0;
      graph[i].clear();
      group[i].clear();
    }
    vector<long long> sum;
    vector<pair<int, int>> vc;
    map<long long, pair<int, int>> mp;
    int tot = 0;
    long long allSum = 0;
    for (int i = 0; i < k; ++i) {
      int x;
      scanf("%d", &x);
      long long tmpSum = 0;
      for (int j = 0; j < x; ++j) {
        int y;
        scanf("%d", &y);
        vc.push_back(make_pair(y, i));
        mp[y] = make_pair(tot, i);
        tot++;
        tmpSum += y;
      }
      sum.push_back(tmpSum);
      allSum += tmpSum;
    }
    if (allSum % k) {
      printf("No\n");
      continue;
    }
    allSum /= k;
    set<int> selfCircle;
    set<pair<int, int>> hasEdge;
    for (int i = 0, len = vc.size(); i < len; ++i) {
      long long searchNum = allSum - sum[vc[i].second] + vc[i].first;
      if (mp.find(searchNum) == mp.end())
        continue;
      else if (mp[searchNum].second == vc[i].second &&
               mp[searchNum].first != i) {
        continue;
      } else if (mp[searchNum].first == i) {
        selfCircle.insert(i);
      }
      graph[i].push_back(mp[searchNum].first);
      hasEdge.insert(make_pair(i, mp[searchNum].first));
      42;
    }
    for (int i = 0; i < tot; ++i) {
      if (!dfn[i]) Tarjan_scc(i);
    }
    for (int i = 0; i < tot; ++i) {
      group[col[i]].push_back(i);
    }
    for (int i = 1; i <= ccnt; ++i) {
      if (group[i].size() == 1 && selfCircle.count(group[i][0])) {
        int id = group[i][0];
        vector<pair<int, int>> tmpPair;
        tmpPair.push_back(make_pair(vc[id].first, vc[id].second + 1));
        dp[1 << vc[id].second] = tmpPair;
      } else if (group[i].size() > 1) {
        vector<pair<int, int>> tmpPair;
        int tmp = 0;
        int len = group[i].size();
        bool suc = true;
        for (int j = 0; j < len; ++j) {
          int to = group[i][j];
          if (tmp & (1 << vc[to].second)) {
            suc = false;
            break;
          }
          tmp |= 1 << vc[to].second;
        }
        if (suc == false) {
          continue;
        }
        for (int j = 0; j < len; ++j) {
          for (int k = 0; k < len; ++k) {
            int fr = group[i][j];
            int to = group[i][k];
            if (hasEdge.count(make_pair(fr, to))) {
              tmpPair.push_back(make_pair(vc[to].first, vc[fr].second + 1));
            }
          }
        }
        dp[tmp] = tmpPair;
      }
    }
    for (int i = 0; i < (1 << k); ++i) {
      for (int s = (i - 1) & i; s; s = (s - 1) & i) {
        int t = i ^ s;
        if (dp[s].size() > 0 && dp[t].size() > 0) {
          dp[i] = dp[s];
          dp[i].insert(dp[i].end(), dp[t].begin(), dp[t].end());
          break;
        }
      }
    }
    auto cmp = [&](pair<int, int> &A, pair<int, int> &B) {
      return mp[A.first].second < mp[B.first].second;
    };
    int end = (1 << k) - 1;
    if (dp[end].size() > 0) {
      printf("Yes\n");
      sort(dp[end].begin(), dp[end].end(), cmp);
      for (int i = 0; i < k; ++i) {
        printf("%d %d\n", dp[end][i].first, dp[end][i].second);
      }
    } else
      printf("No\n");
  }
  return 0;
}