#include <algorithm>
#include <cstdio>
#include <queue>
#include <vector>

using namespace std;

#define MAX 100

const int M = 1000;
const int oo = 0x7FFFFFFF;

int N;
int H[MAX], T[MAX], P[MAX];
vector<int> preduvjeti[MAX];

int c[MAX+2][MAX+2];
vector<int> adj[MAX+2];
int f[MAX+2], bio[MAX+2], how[MAX+2];

void add_edge( int a, int b, int cap ) {
   c[a][b] += cap;
   adj[a].push_back( b );
   adj[b].push_back( a );
}

int bfs( int source, int sink ) {
   memset( f, 0, sizeof f );
   memset( bio, 0, sizeof bio );
   
   bio[source] = 1;
   f[source] = oo;
   queue<int> Q;
   for( Q.push( source ); !Q.empty(); Q.pop() ) {
      int u = Q.front();
      bio[u] = 2;
      if( u == sink ) return f[u];

      for( vector<int>::iterator it = adj[u].begin(); it != adj[u].end(); ++it ) {
         if( bio[*it] == 2 ) continue;
         int ff = min( f[u], c[u][*it] );
         if( ff == 0 || f[*it] >= ff ) continue;

         f[*it] = ff;
         how[*it] = u;

         if( bio[*it] == 0 ) {
            bio[*it] = 1;
            Q.push( *it );
         }
      }
   }
   return 0;
}

int mincut_not_empty( int avg ) {
   for( int i = 0; i < N+2; ++i ) adj[i].clear();
   memset( c, 0, sizeof c );

   int source = N, sink = N+1;
   for( int i = 0; i < N; ++i ) {
      add_edge( source, i, M - H[i] + T[i]*avg );
      add_edge( i, sink, M );
      for( vector<int>::iterator it = preduvjeti[i].begin(); it != preduvjeti[i].end(); ++it ) 
         add_edge( *it, i, oo );
   }

   int flow;
   while( (flow = bfs(source, sink)) ) 
      for( int x = sink; x != source; x = how[x] ) {
         c[how[x]][x] -= flow;
         c[x][how[x]] += flow;
      }   

   for( int i = 0; i < N; ++i ) 
      if( bio[i] == 0 ) return 1;
   return 0;
}

int main( void ) {
   scanf( "%d", &N );
   for( int i = 0; i < N; ++i ) {
      scanf( "%d%d%d", &H[i], &T[i], &P[i] );
      for( int j = 0; j < P[i]; ++j ) {
         int x;
         scanf( "%d", &x ); --x;
         preduvjeti[i].push_back( x );
      }
   }

   int lo = 0, hi = M;
   while( lo != hi ) {
      int mid = (lo+hi+1)/2;
      if( mincut_not_empty(mid) ) lo = mid; else hi = mid-1;
   }

   printf( "%d\n", lo );
   return 0;
}
