#include <algorithm>
#include <vector>
#include <string>
#include <queue>

#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;

const int MAXN = 110;
const int inf = 1000000000;

int n;

int placa[ MAXN ];
int vrijeme[ MAXN ];

vector< int > req[ MAXN ];

int source;
int sink;

int cap[ MAXN ][ MAXN ];
vector< int > E[ MAXN ];

int dad[ MAXN ];
queue< int > Q;

bool bio[ MAXN ];

int augment()
{
    for( int i = 0; i <= sink; ++i )
        dad[i] = -1;

    for( ; !Q.empty(); Q.pop() );
    dad[source] = source;
    Q.push( source );

    for( ; !Q.empty(); Q.pop() ) {
        int x = Q.front();
        if( x == sink ) break;

        for( vector< int >::iterator it = E[x].begin(); it != E[x].end(); ++it )
            if( dad[*it] == -1 && cap[x][*it] > 0 ) {
                dad[*it] = x;
                Q.push( *it );
            }
    }

    if( dad[sink] == -1 ) return 0;

    int flow = inf;

    for( int x = sink; x != source; x = dad[x] )
        flow = min( flow, cap[ dad[x] ][ x ] );

    for( int x = sink; x != source; x = dad[x] ) {
        cap[ dad[x] ][ x ] -= flow;
        cap[ x ][ dad[x] ] += flow;
    }

    return flow;
}

bool solve( int P )
{
    if( P == 0 ) return true;

    for( int i = 0; i <= sink; ++i )
        for( int j = 0; j <= sink; ++j )
            cap[i][j] = 0;

    for( int i = 0; i < n; ++i )
        for( vector< int >::iterator it = req[i].begin(); it != req[i].end(); ++it )
            cap[*it][i] = inf;

    for( int i = 0; i < n; ++i ) {
        cap[source][i] = P * vrijeme[i] - placa[i] + 1000;
        cap[i][sink] = 1000;
    }

    int flow = 0;
    for( int f; ( f = augment() ) > 0; flow += f );
    return flow - n * 1000 < 0;
}

void flood( int x )
{
    if( bio[x] ) return;
    bio[x] = true;

    for( vector< int >::iterator it = E[x].begin(); it != E[x].end(); ++it )
        if( cap[x][*it] > 0 )
            flood( *it );
}

int main( void )
{
    scanf( "%d", &n );

    source = n;
    sink = n + 1;

    for( int i = 0; i < n; ++i ) {
        scanf( "%d %d", placa + i, vrijeme + i );
        int cnt; scanf( "%d", &cnt );

        for( ; cnt > 0; --cnt ) {
            int x; scanf( "%d", &x ); --x;
            req[i].push_back( x );
            E[i].push_back( x );
            E[x].push_back( i );
        }

        E[source].push_back( i );
        E[i].push_back( source );
        E[i].push_back( sink );
        E[sink].push_back( i );
    }

    int lo = 0, hi = 1000;

    while( lo < hi ) {
        int mid = ( lo + hi ) / 2;

        if( solve( mid ) )
            lo = mid + 1;
        else
            hi = mid;
    }

    if( lo > 0 ) {
        solve( lo );
        flood( source );

        int cnt = 0;
        for( int i = 0; i < n; ++i )
            cnt += bio[i];

        if( cnt == n ) --lo;
    }

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

