Problem: Problem

There are N sets of integers. Each of these sets is assigned a number from 1 to N. The number of elements in the i-th set is Ki, and the j-th smallest integer in the elements of the set is ai, j.

Taro decided to choose any number of sets from this. Taro, who thought it would be boring to just choose the right one, decided to choose at least three sets. In addition, we decided to select the product so that the product of "the number of elements in the union of the selected set" and "the number of elements in the intersection of the selected set" is as large as possible.

When Taro selects the optimal set, find the maximum value of the product of "the number of elements in the union of the selected set" and "the number of elements in the intersection of the selected set".

Constraints

The input satisfies the following conditions.

* All inputs are integers.
* 3 ≤ N ≤ 20,000
* 1 ≤ ai, j ≤ 22
* ai, j <ai, j + 1 (1 ≤ i ≤ N) (1 ≤ j <Ki)

Input

The input is given in the following format.


N
K1 a1,1 a1,2 ... a1, K1
K2 a2,1 a2,2 ... a2, K2
...
KN aN, 1 aN, 2 ... aN, KN


Output

Output the maximum value of the product of "the number of elements in the union of the selected set" and "the number of elements in the intersection of the selected set" when Taro chose optimally.

Examples

Input

4
1 5
2 3 5
3 3 5 7
4 3 5 7 9


Output

8


Input

5
4 1 4 5 6
4 1 7 8 9
3 1 2 3
3 1 2 3
3 1 2 3


Output

9


Input

3
2 3 4
2 2 5
2 1 6


Output

0

Solution (in CPP):

Solution:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

// 0 : max sum
// 1 : three count
// 2 : id 1
// 3 : id 2
int dp[1<<22][4];

int main(){
  // init
  REP(i,1<<22){
    dp[i][0] = 0;
    dp[i][1] = false;
    dp[i][2] = dp[i][3] = -1;
  }
  int n;
  scanf("%d",&n);
  REP(i,n){
    int id = 0;
    int k;
    scanf("%d",&k);
    REP(j,k){
      int a;
      scanf("%d",&a);
      id |= (1<<(a-1));
    }
    dp[id][0] |= id;
    if(!dp[id][1]){
      if(dp[id][2]==-1){
        dp[id][2] = i;
      }else if(dp[id][2]!=i){
        if(dp[id][3]==-1){
          dp[id][3] = i;
        }else if(dp[id][3]!=i){
          dp[id][1] = true;
        }
      }
    }
  }
  FORR(i,1,1<<22){
    REP(j,22)if(i&(1<<j)){
      int to = i ^ (1<<j);
      dp[to][0] |= dp[i][0];
      if(dp[i][1]){
        dp[to][1] = true;
      }else if(!dp[to][1]){
        if(dp[i][2]!=-1){
          int add = dp[i][2];
          if(dp[to][2]==-1){
            dp[to][2] = add;
          }else if(dp[to][2]!=add){
            if(dp[to][3]==-1){
              dp[to][3] = add;
            }else if(dp[to][3]!=add){
              dp[to][1] = true;
            }
          }
        }
        if(dp[i][3]!=-1){
          int add = dp[i][3];
          if(dp[to][2]==-1){
            dp[to][2] = add;
          }else if(dp[to][2]!=add){
            if(dp[to][3]==-1){
              dp[to][3] = add;
            }else if(dp[to][3]!=add){
              dp[to][1] = true;
            }
          }
        }
      }
    }
  }
  int ans = 0;
  REP(i,1<<22)if(dp[i][1]){
    CHMAX(ans, __builtin_popcount(i) * __builtin_popcount(dp[i][0]));
  }
  printf("%d\n",ans);
  return 0;
}