#include #include #include #include #include #include typedef long long int ll; using namespace std; #define FOR(i,a,b) for (int i=(a);i<(b);i++) #define REP(i,n) for (int i=0;i<(n);i++) #define EREP(i,n) for (int i=1;i<=(n);i++) const int MOD = 1000000007; ll dp[100010]; ll N,v,w,V; ll bk=100000000007; int main(){ ios::sync_with_stdio(false); cin>>N; assert( N <= 100 && 1<=N ); REP(i,100010)dp[i]=bk; REP(i,N){ cin>>v>>w; assert( v <= 1000 && 1<=v ); assert( w <= 1000&& 1<=w ); for(int j=100010-1;j>v;j--) dp[j]=min(dp[j],dp[j-v]+w); for(int j=v;j>0;j--) dp[j]=min(dp[j],w); } cin>>V; assert( V <= 100000&& 0<=V ); dp[V]>0&&dp[V]!=bk?cout<