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>
long long dx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
long long dy[8] = {1, 0, -1, 0, -1, 1, 1, -1};
using namespace std;
class pa3 {
 public:
  long long x;
  long long y, z;
  pa3(long long x = 0, long long y = 0, long long z = 0) : x(x), y(y), z(z) {}
  bool operator<(const pa3 &p) const {
    if (x != p.x) return x < p.x;
    if (y != p.y) return y < p.y;
    return z < p.z;
  }
  bool operator>(const pa3 &p) const {
    if (x != p.x) return x > p.x;
    if (y != p.y) return y > p.y;
    return z > p.z;
  }
  bool operator==(const pa3 &p) const {
    return x == p.x && y == p.y && z == p.z;
  }
  bool operator!=(const pa3 &p) const {
    return !(x == p.x && y == p.y && z == p.z);
  }
};
class pa4 {
 public:
  long long x;
  long long y, z, w;
  pa4(long long x = 0, long long y = 0, long long z = 0, long long w = 0)
      : x(x), y(y), z(z), w(w) {}
  bool operator<(const pa4 &p) const {
    if (x != p.x) return x < p.x;
    if (y != p.y) return y < p.y;
    if (z != p.z) return z < p.z;
    return w < p.w;
  }
  bool operator>(const pa4 &p) const {
    if (x != p.x) return x > p.x;
    if (y != p.y) return y > p.y;
    if (z != p.z) return z > p.z;
    return w > p.w;
  }
  bool operator==(const pa4 &p) const {
    return x == p.x && y == p.y && z == p.z && w == p.w;
  }
};
class pa2 {
 public:
  long long x, y;
  pa2(long long x = 0, long long y = 0) : x(x), y(y) {}
  pa2 operator+(pa2 p) { return pa2(x + p.x, y + p.y); }
  pa2 operator-(pa2 p) { return pa2(x - p.x, y - p.y); }
  bool operator<(const pa2 &p) const { return y != p.y ? y < p.y : x < p.x; }
  bool operator>(const pa2 &p) const { return x != p.x ? x < p.x : y < p.y; }
  bool operator==(const pa2 &p) const {
    return abs(x - p.x) == 0 && abs(y - p.y) == 0;
  }
  bool operator!=(const pa2 &p) const {
    return !(abs(x - p.x) == 0 && abs(y - p.y) == 0);
  }
};
string itos(long long i) {
  ostringstream s;
  s << i;
  return s.str();
}
long long gcd(long long v, long long b) {
  if (v == 0) return b;
  if (b == 0) return v;
  if (v > b) return gcd(b, v);
  if (v == b) return b;
  if (b % v == 0) return v;
  return gcd(v, b % v);
}
long long mod;
long long extgcd(long long a, long long b, long long &x, long long &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  long long d = extgcd(b, a % b, y, x);
  y -= a / b * x;
  return d;
}
pair<long long, long long> operator+(const pair<long long, long long> &l,
                                     const pair<long long, long long> &r) {
  return {l.first + r.first, l.second + r.second};
}
pair<long long, long long> operator-(const pair<long long, long long> &l,
                                     const pair<long long, long long> &r) {
  return {l.first - r.first, l.second - r.second};
}
long long pr[10000100];
long long inv[10000010];
long long beki(long long wa, long long rr, long long warukazu) {
  if (rr == 0) return 1 % warukazu;
  if (rr == 1) return wa % warukazu;
  wa %= warukazu;
  if (rr % 2 == 1)
    return ((long long)beki(wa, rr - 1, warukazu) * (long long)wa) % warukazu;
  long long zx = beki(wa, rr / 2, warukazu);
  return (zx * zx) % warukazu;
}
long long comb(long long nn, long long rr) {
  if (rr < 0 || rr > nn || nn < 0) return 0;
  long long r = pr[nn] * inv[rr];
  r %= mod;
  r *= inv[nn - rr];
  r %= mod;
  return r;
}
void gya(long long ert) {
  pr[0] = 1;
  for (long long i = 1; i <= ert; i++) {
    pr[i] = ((long long)pr[i - 1] * i) % mod;
  }
  inv[ert] = beki(pr[ert], mod - 2, mod);
  for (long long i = ert - 1; i >= 0; i--) {
    inv[i] = (long long)inv[i + 1] * (i + 1) % mod;
  }
}
vector<long long> ve[20];
vector<pair<long long, long long> > G[20];
vector<long long> sumi[20];
vector<pair<long long, long long> > dp[1 << 15];
void dfs(long long x, long long y, long long num) {
  while (1) {
    if (G[x][y].first == -1) return;
    if (sumi[x][y] < num) return;
    if (sumi[x][y] == num) {
      vector<pair<long long, long long> > ri;
      ri.push_back(make_pair(x, y));
      while (1) {
        long long xx = x, yy = y;
        x = G[xx][yy].first;
        y = G[xx][yy].second;
        if (ri[0] == make_pair(x, y))
          break;
        else
          ri.push_back(make_pair(x, y));
      }
      long long e = 0;
      for (auto v : ri) {
        if (e & (1 << (v.first - 1))) return;
        e += (1 << (v.first - 1));
      }
      if (dp[e].size()) return;
      dp[e] = ri;
      return;
    } else {
      sumi[x][y] = num;
      long long xx = x, yy = y;
      x = G[xx][yy].first;
      y = G[xx][yy].second;
    }
  }
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  map<long long, pair<long long, long long> > ma;
  long long n;
  cin >> n;
  long long r[20] = {};
  long long wa[20] = {};
  long long zw = 0;
  for (long long i = 1; i <= n; i++) {
    cin >> r[i];
    for (long long j = 0; j < r[i]; j++) {
      long long y;
      cin >> y;
      ve[i].push_back(y);
      wa[i] += y;
      ma[y] = make_pair(i, j);
    }
    zw += wa[i];
  }
  if (abs(zw) % n) {
    cout << "No" << endl;
    return 0;
  }
  for (long long i = 1; i <= n; i++)
    wa[i] = (zw / n) - wa[i], sumi[i].resize(r[i], 1000000007);
  for (long long i = 1; i <= n; i++)
    for (long long j = 0; j < r[i]; j++) {
      if (!ma.count(ve[i][j] + wa[i])) {
        G[i].push_back(make_pair(-1, -1));
      } else
        G[i].push_back(ma[ve[i][j] + wa[i]]);
    }
  long long cnt = 1;
  for (long long i = 1; i <= n; i++)
    for (long long j = 0; j < r[i]; j++) {
      if (sumi[i][j] != 1000000007) continue;
      dfs(i, j, cnt);
      cnt++;
    }
  for (long long i = 1; i < (1 << n); i++) {
    if (dp[i].size()) continue;
    for (long long j = ((i - 1) & i); j > 0; j = ((j - 1) & i)) {
      if (dp[j ^ i].size() > 0 && dp[j].size() > 0) {
        dp[i] = dp[j];
        for (auto v : dp[i ^ j]) dp[i].push_back(v);
        break;
      }
    }
  }
  if (dp[(1 << n) - 1].size()) {
    cout << "Yes" << endl;
    long long ans1[20];
    long long ans2[20];
    for (auto v : dp[(1 << n) - 1]) {
      ans1[v.first] = ve[v.first][v.second];
      ans2[G[v.first][v.second].first] = v.first;
    }
    for (long long i = 1; i <= n; i++)
      cout << ans1[i] << " " << ans2[i] << endl;
  } else {
    cout << "No" << endl;
    return 0;
  }
  return 0;
}