#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <functional>
#include <complex>
#include <queue>
#include <stack>
#include <cmath>
#include <cassert>
#include <cstring>
using namespace std;
typedef long long LL;
typedef complex<double> CMP;

class SpaceshipEvacuation { public:
	int additionalCabins(int N, vector <string> tunnelNetwork, int crewSize) 
	{
		
	}
};

// BEGIN CUT HERE
#include <ctime>
double start_time; string timer()
 { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v)
 { os << "{ ";
   for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it)
   os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; }
void verify_case(const int& Expected, const int& Received) {
 bool ok = (Expected == Received);
 if(ok) cerr << "PASSED" << timer() << endl;  else { cerr << "FAILED" << timer() << endl;
 cerr << "\to: \"" << Expected << '\"' << endl << "\tx: \"" << Received << '\"' << endl; } }
#define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock();
#define END	 verify_case(_, SpaceshipEvacuation().additionalCabins(N, tunnelNetwork, crewSize));}
int main(){

CASE(0)
	int N = 3; 
	string tunnelNetwork_[] = {"0 1 5 3",
 "2 1 0 0"};
	  vector <string> tunnelNetwork(tunnelNetwork_, tunnelNetwork_+sizeof(tunnelNetwork_)/sizeof(*tunnelNetwork_)); 
	int crewSize = 5; 
	int _ = 7; 
END
CASE(1)
	int N = 3; 
	string tunnelNetwork_[] = {"0 1 0 2",
 "0 2 0 4"};
	  vector <string> tunnelNetwork(tunnelNetwork_, tunnelNetwork_+sizeof(tunnelNetwork_)/sizeof(*tunnelNetwork_)); 
	int crewSize = 5; 
	int _ = 4; 
END
CASE(2)
	int N = 4; 
	string tunnelNetwork_[] = {"0 1 0 6",
 "3 2 3 1",
 "2 1 0 1",
 "3 1 2 2"};
	  vector <string> tunnelNetwork(tunnelNetwork_, tunnelNetwork_+sizeof(tunnelNetwork_)/sizeof(*tunnelNetwork_)); 
	int crewSize = 6; 
	int _ = 6; 
END
CASE(3)
	int N = 10; 
	string tunnelNetwork_[] = {"0 1 11 101",
 "1 2 0 100",
 "2 3 20 100",
 "3 4 0 107",
 "4 1 66 0",
 "3 5 104 2",
 "4 6 82 0",
 "5 7 25 25",
 "7 8 14 42",
 "8 9 0 94",
 "9 5 17 92"};
	  vector <string> tunnelNetwork(tunnelNetwork_, tunnelNetwork_+sizeof(tunnelNetwork_)/sizeof(*tunnelNetwork_)); 
	int crewSize = 110; 
	int _ = 376; 
END
CASE(4)
	int N = 3; 
	string tunnelNetwork_[] = {"0 1 0 0"};
	  vector <string> tunnelNetwork(tunnelNetwork_, tunnelNetwork_+sizeof(tunnelNetwork_)/sizeof(*tunnelNetwork_)); 
	int crewSize = 1; 
	int _ = -1; 
END
CASE(5)
	int N = ; 
	string tunnelNetwork_[] = ;
	  vector <string> tunnelNetwork(tunnelNetwork_, tunnelNetwork_+sizeof(tunnelNetwork_)/sizeof(*tunnelNetwork_)); 
	int crewSize = ; 
	int _ = ; 
END
CASE(6)
	int N = ; 
	string tunnelNetwork_[] = ;
	  vector <string> tunnelNetwork(tunnelNetwork_, tunnelNetwork_+sizeof(tunnelNetwork_)/sizeof(*tunnelNetwork_)); 
	int crewSize = ; 
	int _ = ; 
END

}
// END CUT HERE
