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 int lg = 22;
const long long int N = 5e3 + 5;
const long long int K = 16;
const long long int INF = 1e9 + 5;
const long long int mod = 1e9 + 7;
const double PI = 3.14159265358979323846;
template <typename T>
T power(T x, T y) {
  T ans = 1;
  while (y > 0) {
    if (y & 1LL) ans = (ans * x) % mod;
    y >>= 1LL;
    x = (x * x) % mod;
  }
  return ans % mod;
}
inline long long int mul(long long int a, long long int b) {
  return (a * 1ll * b) % mod;
}
inline long long int sub(long long int a, long long int b) {
  long long int c = a - b;
  if (c < 0) c += mod;
  return c;
}
inline long long int add(long long int a, long long int b) {
  long long int c = a + b;
  if (c > mod) c -= mod;
  return c;
}
inline long long int inv(long long int a) { return power(a, mod - 2); }
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
stack<long long int> st;
vector<long long int> allmasks;
map<long long int, long long int> inval, vis, maskvis;
unordered_map<long long int, vector<long long int> > edge, values;
long long int first, k, totsum, needed, n[K], a[K][N], sum[K], dp[(1 << K)];
void Cycle(long long int cur) {
  vis[cur] = 1;
  st.push(cur);
  for (auto i : edge[cur]) {
    if (!vis[i]) {
      Cycle(i);
    } else {
      if (vis[i] == 1) {
        first = 1;
        long long int invalid = 0;
        vector<long long int> temp;
        long long int mask = 0, ins = allmasks.size(), checker = 0;
        while (st.size()) {
          long long int inside = st.top();
          checker |= mask & (1 << (inval[inside] - 1));
          if (checker) {
            st.pop();
            invalid = 1;
            if (inside == i) {
              break;
            }
            continue;
          }
          temp.push_back(inside);
          mask |= (1 << (inval[inside] - 1));
          if (inside == i) {
            st.pop();
            break;
          }
          st.pop();
        }
        if (mask) {
          if (maskvis[mask]) {
            continue;
          }
          maskvis[mask] = 1;
          allmasks.push_back(mask);
          for (auto j : temp) {
            values[ins].push_back(j);
          }
        }
        if (invalid) {
          allmasks.pop_back();
          values[ins].clear();
        }
      }
    }
  }
  vis[cur] = 2;
  if (st.size()) {
    st.pop();
  }
}
long long int F(long long int idx, long long int mask) {
  long long int res = 0;
  if (idx == allmasks.size()) {
    return (mask == (1 << k) - 1);
  }
  if (dp[mask] != -1) {
    return dp[mask];
  }
  long long int check = allmasks[idx] & mask;
  res |= F(idx + 1, mask);
  if (!check) {
    res |= F(idx + 1, mask | allmasks[idx]);
  }
  return dp[mask] = res;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> k;
  memset(dp, -1, sizeof(dp));
  for (long long int i = 0; i < k; i++) {
    cin >> n[i];
    long long int cursum = 0;
    for (long long int j = 0; j < n[i]; j++) {
      cin >> a[i][j];
      totsum += a[i][j];
      cursum += a[i][j];
      inval[a[i][j]] = i + 1;
    }
    sum[i] = cursum;
  }
  needed = totsum / k;
  if (totsum % k) {
    cout << "No" << endl;
    exit(0);
  }
  for (long long int i = 0; i < k; i++) {
    for (long long int j = 0; j < n[i]; j++) {
      long long int ifremoved = needed - sum[i] + a[i][j];
      if (inval[ifremoved] == 0) {
        continue;
      }
      edge[ifremoved].push_back(a[i][j]);
    }
  }
  for (long long int i = 0; i < k; i++) {
    for (long long int j = 0; j < n[i]; j++) {
      long long int cur = a[i][j];
      while (st.size()) {
        st.pop();
      }
      if (vis[cur]) {
        continue;
      }
      Cycle(cur);
    }
  }
  long long int check = F(0, 0), oldmask = 0;
  if (!check) {
    cout << "No" << endl;
    exit(0);
  }
  vector<pair<long long int, pair<long long int, long long int> > > ans;
  for (long long int i = 0; i < allmasks.size(); i++) {
    long long int checker = oldmask & allmasks[i];
    if (checker) {
      continue;
    }
    long long int includethis = F(i + 1, oldmask | (allmasks[i]));
    if (!includethis) {
      continue;
    }
    long long int sz = values[i].size();
    long long int nexvertex = values[i][sz - 1];
    oldmask |= allmasks[i];
    for (auto j : values[i]) {
      ans.push_back(make_pair(inval[j], make_pair(j, inval[nexvertex])));
      nexvertex = j;
    }
  }
  sort(ans.begin(), ans.end());
  cout << "Yes" << endl;
  for (auto i : ans) {
    cout << i.second.first << " " << i.second.second << endl;
  }
}