using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); static int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray(); public static void Main() { Solve(); } static void Solve() { var c = NList; var (n, w) = (c[0], c[1]); var map = NArr(n); var dpv = new int[20001]; var dpc = new long[20001]; var dpe = new bool[20001]; var mod = 998_244_353; dpc[10000] = 1; dpe[10000] = true; for (var i = 0; i < n; ++i) { var ndpv = (int[]) dpv.Clone(); var ndpc = (long[]) dpc.Clone(); var ndpe = (bool[]) dpe.Clone(); for (var j = 0; j < dpv.Length; ++j) { if (!dpe[j]) continue; var to = j + map[i][1]; if (to >= dpv.Length) break; if (!ndpe[to] || ndpv[to] < dpv[j] + map[i][0]) { ndpv[to] = dpv[j] + map[i][0]; ndpc[to] = dpc[j]; ndpe[to] = true; } else if (dpv[to] == dpv[j] + map[i][0]) { ndpc[to] = (dpc[to] + dpc[j]) % mod; } } dpv = ndpv; dpc = ndpc; dpe = ndpe; } var max = int.MinValue; for (var i = 0; i <= w + 10000; ++i) if (dpe[i]) max = Math.Max(max, dpv[i]); var count = 0L; for (var i = 0; i <= w + 10000; ++i) if (dpe[i] && dpv[i] == max) count = (count + dpc[i]) % mod; WriteLine($"{max} {count}"); } }