#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;
using ld = long double;
using mint = atcoder::modint998244353;
const ll inf = 9e18;

pair<ll,mint> calc(pair<ll,mint> x,pair<ll,mint> y,ll add=0){
    auto[vx,cx]=x;
    auto[vy,cy]=y;
    if(vx>vy+add) return x;
    if(vx==vy+add) return {vx,cx+cy};
    else return {vy+add,cy};
}

int main(){

	ios::sync_with_stdio(0);
	cin.tie(0);

    ll n,W;
    cin >> n >> W;
    vector<ll> v(n),w(n);
    for(ll i=0;i<n;i++) cin >> v[i] >> w[i];
    vector dp(n+1,vector<pair<ll,mint>>(20001,{-inf,0}));
    dp[0][10000]={0,1};

    for(ll i=0;i<n;i++){
        for(ll j=0;j<=20000;j++){
            dp[i+1][j]=calc(dp[i+1][j],dp[i][j]);
            if(0<=j+w[i]&&j+w[i]<=20000){
                dp[i+1][j+w[i]]=calc(dp[i+1][j+w[i]],dp[i][j],v[i]);
            }
        }
    }

    ll mxv=-inf;
    mint cnt=0;

    for(ll j=0;j<=W+10000;j++){
        auto[v,c]=dp[n][j];
        if(mxv>v) continue;
        if(mxv==v) cnt+=c;
        if(mxv<v){
            cnt=c;
            mxv=v;
        }
    }

    cout << mxv << " " << cnt.val() << endl;
    return 0;
    
}