#include using namespace std; long long mod = 998244353; //入力が必ず-mod>= 1; } return ret; }; mint &operator=(const mint &b) = default; mint operator-() const {return mint(0)-(*this);} mint operator+(const mint b){return mint(v)+=b;} mint operator-(const mint b){return mint(v)-=b;} mint operator*(const mint b){return mint(v)*=b;} mint operator/(const mint b){return mint(v)/=b;} mint operator+=(const mint b){ v += b.v; if(v >= mod) v -= mod; return *this; } mint operator-=(const mint b){ v -= b.v; if(v < 0) v += mod; return *this; } mint operator*=(const mint b){v = v*b.v%mod; return *this;} mint operator/=(mint b){ if(b == 0) assert(false); int left = mod-2; while(left){if(left&1) *this *= b; b *= b; left >>= 1;} return *this; } mint operator++(int){*this += 1; return *this;} mint operator--(int){*this -= 1; return *this;} bool operator==(const mint b){return v == b.v;} bool operator!=(const mint b){return v != b.v;} bool operator>(const mint b){return v > b.v;} bool operator>=(const mint b){return v >= b.v;} bool operator<(const mint b){return v < b.v;} bool operator<=(const mint b){return v <= b.v;} mint pow(const long long x){return repeat2mint(v,x);} mint inv(){return mint(1)/v;} }; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int N,W; cin >> N >> W; vector>> dp(N+1,vector>(20009,{-1001001001,0})); auto update = [&](pair &a,pair &b,int v) -> void { if(b.first+v == a.first) a.second += b.second; else if(b.first+v > a.first) a = {b.first+v,b.second}; }; int zero = 10000; vector> WV(N); for(auto &[w,v] : WV) cin >> v >> w; sort(WV.begin(),WV.end()); dp.at(0).at(zero) = {0,1}; for(int i=0; i 20009) continue; update(dp.at(i+1).at(k+w),dp.at(i).at(k),v); } } pair ans = {-1001001001,0}; for(int i=0; i<=zero+W; i++) update(ans,dp.at(N).at(i),0); cout << ans.first << " " << ans.second.v << endl; }