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;
template <typename A, typename B>
string to_string(pair<A, B> p);
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
string to_string(const string& s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
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;
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ")";
}
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
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 = (int)1e6 + 10;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(nullptr);
  int boxes;
  cin >> boxes;
  vector<vector<int> > a(boxes);
  vector<vector<int> > visited(boxes);
  int64_t S = 0;
  for (int i = 0; i < boxes; i++) {
    int n;
    cin >> n;
    vector<int> weights(n);
    for (int& w : weights) {
      cin >> w;
      S += w;
    }
    a[i] = weights;
    visited[i] = vector<int>(n, 0);
  }
  if (S % boxes != 0) {
    cout << "No"
         << "\n";
    return 0;
  }
  S /= boxes;
  vector<int64_t> d;
  for (auto box : a) {
    int64_t w = 0;
    for (int box_weight : box) {
      w += box_weight;
    }
    d.push_back(S - w);
  }
  42;
  map<int64_t, pair<int, int> > where;
  for (int i = 0; i < boxes; i++) {
    for (int j = 0; j < a[i].size(); j++) {
      where[a[i][j]] = {i, j};
    }
  }
  map<int, vector<pair<int, int> > > cycleItemsMap;
  set<int> goodMasks;
  for (int i = 0; i < boxes; i++) {
    for (int j = 0; j < a[i].size(); j++) {
      int x = i, y = j;
      int mask = 0;
      int cycle = true;
      vector<pair<int, int> > markedVisited;
      vector<pair<int, int> > cycleItems;
      set<int> rowsTaken;
      while (true) {
        if (visited[x][y]) {
          if (x != i && y != j) {
            cycle = false;
          }
          break;
        }
        if (rowsTaken.count(x)) {
          cycle = false;
          break;
        }
        rowsTaken.insert(x);
        mask |= (1 << x);
        visited[x][y] = true;
        cycleItems.push_back({x, y});
        markedVisited.push_back({x, y});
        if (where.count(a[x][y] + d[x])) {
          auto it = where[a[x][y] + d[x]];
          x = it.first;
          y = it.second;
        } else {
          cycle = false;
          break;
        }
      }
      if (cycle && goodMasks.count(mask) == 0) {
        42;
        cycleItemsMap[mask] = cycleItems;
        goodMasks.insert(mask);
      }
      for (auto p : markedVisited) {
        visited[p.first][p.second] = false;
      }
    }
  }
  42;
  vector<int> previous(1 << boxes, -1);
  for (int mask : goodMasks) {
    previous[mask] = 0;
  }
  for (int mask = 1; mask < (1 << boxes); mask++) {
    for (int s = mask; s > 0; s = (s - 1) & mask) {
      if (s == mask) {
        continue;
      }
      if (cycleItemsMap.count(s) && previous[s ^ mask] != -1) {
        previous[mask] = s ^ mask;
        break;
      }
    }
  }
  if (previous[(1 << boxes) - 1] == -1) {
    cout << "No"
         << "\n";
    return 0;
  }
  int mask = (1 << boxes) - 1;
  vector<pair<int, int> > answer(boxes);
  while (mask > 0) {
    int nextMask = previous[mask];
    assert(nextMask != -1);
    int cycleMask = mask ^ nextMask;
    assert(cycleItemsMap.count(cycleMask));
    auto positions = cycleItemsMap[cycleMask];
    vector<int> vals;
    for (auto pos : positions) {
      vals.push_back(a[pos.first][pos.second]);
    }
    for (int i = 0; i < positions.size(); i++) {
      answer[positions[i].first] = {
          a[positions[i].first][positions[i].second],
          positions[(i - 1 + (int)positions.size()) % (int)positions.size()]
              .first};
    }
    mask = nextMask;
  }
  cout << "Yes"
       << "\n";
  for (int i = 0; i < boxes; i++) {
    cout << answer[i].first << " " << answer[i].second + 1 << "\n";
  }
  return 0;
}