#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; const int inf=1<<30; const ll INF=1LL<<62; typedef pair P; typedef pair PP; const ll MOD=998244353; int main(){ int N; ll M,Q; cin>>N>>M>>Q; vector A(N),B(N); for(int i=0;i>A[i]>>B[i]; vector> dp(1<>i)&1){ dp[S].first+=A[i]; dp[S].second+=B[i]; } } } ll ans=0; int all=(1<0;t=(t-1)&T){ if(dp[t].first<=Q){ ans=max(ans,dp[S].second + dp[t].second); } } } } cout<