#include <bits/stdc++.h>

using namespace std;

static struct FastInput {
  static constexpr int BUF_SIZE = 1 << 20;
  char buf[BUF_SIZE];
  size_t chars_read = 0;
  size_t buf_pos = 0;
  FILE *in = stdin;
  char cur = 0;
 
  inline char get_char() {
    if (buf_pos >= chars_read) {
      chars_read = fread(buf, 1, BUF_SIZE, in);
      buf_pos = 0;
      buf[0] = (chars_read == 0 ? -1 : buf[0]);
    }
    return cur = buf[buf_pos++];
  }
 
  inline void tie(int) {}
 
  inline explicit operator bool() {
    return cur != -1;
  }
 
  inline static bool is_blank(char c) {
    return c <= ' ';
  }
 
  inline bool skip_blanks() {
    while (is_blank(cur) && cur != -1) {
      get_char();
    }
    return cur != -1;
  }
 
  inline FastInput& operator>>(char& c) {
    skip_blanks();
    c = cur;
    return *this;
  }
  
  inline FastInput& operator>>(string& s) {
    if (skip_blanks()) {
      s.clear();
      do {
        s += cur;
      } while (!is_blank(get_char()));
    }
    return *this;
  }
 
  template <typename T>
  inline FastInput& read_integer(T& n) {
    // unsafe, doesn't check that characters are actually digits
    n = 0;
    if (skip_blanks()) {
      int sign = +1;
      if (cur == '-') {
        sign = -1;
        get_char();
      }
      do {
        n += n + (n << 3) + cur - '0';
      } while (!is_blank(get_char()));
      n *= sign;
    }
    return *this;
  }
 
  template <typename T>
  inline typename enable_if<is_integral<T>::value, FastInput&>::type operator>>(T& n) {
    return read_integer(n);
  }
  
  #if !defined(_WIN32) || defined(_WIN64)
  inline FastInput& operator>>(__int128& n) {
    return read_integer(n);
  }
  #endif
 
  template <typename T>
  inline typename enable_if<is_floating_point<T>::value, FastInput&>::type operator>>(T& n) {
    // not sure if really fast, for compatibility only
    n = 0;
    if (skip_blanks()) {
      string s;
      (*this) >> s;
      sscanf(s.c_str(), "%lf", &n);
    }
    return *this;
  }
} fast_input;
 
#define cin fast_input
 
static struct FastOutput {
  static constexpr int BUF_SIZE = 1 << 20;
  char buf[BUF_SIZE];
  size_t buf_pos = 0;
  static constexpr int TMP_SIZE = 1 << 20;
  char tmp[TMP_SIZE];
  FILE *out = stdout;
 
  inline void put_char(char c) {
    buf[buf_pos++] = c;
    if (buf_pos == BUF_SIZE) {
      fwrite(buf, 1, buf_pos, out);
      buf_pos = 0;
    }
  }
 
  ~FastOutput() {
    fwrite(buf, 1, buf_pos, out);
  }
 
  inline FastOutput& operator<<(char c) {
    put_char(c);
    return *this;
  }
 
  inline FastOutput& operator<<(const char* s) {
    while (*s) {
      put_char(*s++);
    }
    return *this;
  }
 
  inline FastOutput& operator<<(const string& s) {
    for (int i = 0; i < (int) s.size(); i++) {
      put_char(s[i]);
    }
    return *this;
  }
 
  template <typename T>
  inline char* integer_to_string(T n) {
    // beware of TMP_SIZE
    char* p = tmp + TMP_SIZE - 1;
    if (n == 0) {
      *--p = '0';
    } else {
      bool is_negative = false;
      if (n < 0) {
        is_negative = true;
        n = -n;
      }
      while (n > 0) {
        *--p = (char) ('0' + n % 10);
        n /= 10;
      }
      if (is_negative) {
        *--p = '-';
      }
    }
    return p;
  }
 
  template <typename T>
  inline typename enable_if<is_integral<T>::value, char*>::type stringify(T n) {
    return integer_to_string(n);
  }
 
  #if !defined(_WIN32) || defined(_WIN64)
  inline char* stringify(__int128 n) {
    return integer_to_string(n);
  }
  #endif
 
  template <typename T>
  inline typename enable_if<is_floating_point<T>::value, char*>::type stringify(T n) {
    sprintf(tmp, "%.17f", n);
    return tmp;
  }
 
  template <typename T>
  inline FastOutput& operator<<(const T& n) {
    auto p = stringify(n);
    for (; *p != 0; p++) {
      put_char(*p);
    }
    return *this;
  }
} fast_output;

// here puts define
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

#define rint register int
#define rll register ll 
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fors(i, a, b) for (ll i = (a); i <= (b); ++i)
#define _fors(i, a, b) for (ll i = (a); i >= (b); --i)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define mem(A, b) memset(A, b, sizeof(A))
#define all(X) (X).begin(), (X).end()
#define y0 gawgfawgawg
#define y1 sdfyseyegeh
#define pb push_back
#define eb emplace_back
#define cout fast_output
#define endl '\n'
#define int long long

int start_time;

// here puts const

const int mod = 998244353;

// here puts pre variable

int n, d[55];
int ans;
vector<int> dlc;
int num;
int minn[55];
int delta;
set<int> s;
vector<pii> seg;
int l, r;

// here puts function

inline int add(int a, int b) {
  return (((a + b) % mod) + mod) % mod;
}

inline int mul(int a, int b) {
  return (((1LL * a * b) % mod) + mod) % mod;
}

struct Matrix {
  int row, col;
  int a[55][55];
   
   Matrix operator * (const Matrix& rhs) const {
     assert(col == rhs.row);
     Matrix ret;
     ret.row = row, ret.col = rhs.col;
     fors(i, 1, ret.row) {
       fors(j, 1, ret.col) {
         ret.a[i][j] = 0;
         fors(k, 1, col) {
           ret.a[i][j] = add(ret.a[i][j], mul(a[i][k], rhs.a[k][j]));
         }
       }
     }
     return ret;
   }
};

Matrix qpow(Matrix A, int p) {
  assert(A.row == A.col);
  Matrix ret;
  ret.row = A.row, ret.col = A.col;
  fors(i, 1, ret.row) fors(j, 1, ret.col) ret.a[i][j] = (i == j);
  while (p) {
    if (p & 1) ret = ret * A;
    A = A * A;
    p >>= 1;
  }
  return ret;
}

void main_init() {

  return ;
}

void test_init() {

  return ;
}

void get_ans() {
  fors(i, l + 1, r) dlc[i] -= dlc[l];
  dlc[l] = 0;
  vector<int> tmp;
  fors(i, l, r) tmp.pb(dlc[i]);
  sort(all(tmp));
  unique(all(tmp));
  Matrix A, x;
  A.row = A.col = r - l;
  x.row = r - l, x.col = 1;
  tmp.erase(tmp.begin());
  fors(i, l + 1, r) x.a[i-l][1] = (dlc[i] == 0); 
  x.a[1][1] = 1;
  fors(i, 1, r - l) {
    if (dlc[l+i-1] == 0 || dlc[l+i] == 0) {
      fors(j, 1, i - 1) A.a[i][j] = 1;
      A.a[i][i] = i % 2; 
      fors(j, i + 1, r - l) A.a[i][j] = 0;
    }
    else {
      fors(j, 1, r - 1) A.a[i][j] = 0;
    }
  }
  int las = 0;
  for (auto v : tmp) {
    A = qpow(A, v - las);
    x = A * x;
    las = v;
    fors(i, 1, r - l) {
      if (i % 2) {
        if (dlc[i+l] <= v || dlc[i+l-1] > v) fors(j, 1, r - l) A.a[i][j] = 0;
        else {
          fors(j, 1, i) A.a[i][j] = 1;
          fors(j, i + 1, r - l) A.a[i][j] = 0;
        }
      }
      else {
        if (dlc[i+l] == v) {
          _fors(j, i - 1, 1) if (x.a[j][1]) { x.a[i][1] = x.a[j][1]; break; } 
        }
        if (dlc[i+l-1] == v) x.a[i][1] = 0;
        if (dlc[i+l] > v || dlc[i+l-1] <= v) fors(j, 1, r - l) A.a[i][j] = 0;
        else {
          fors(j, 1, i - 1) A.a[i][j] = 1;
          fors(j, i, r - l) A.a[i][j] = 0;
        }
      }
    }
    if (v == delta) break;
  }
  fors(i, 1, r - l) ans = add(ans, x.a[i][1]);
  return ;
}

void solve() {
  cin >> n >> d[0];
  d[0] = 0;
  fors(i, 1, n) cin >> d[i];
  dlc.pb(0);
  int now = 0, las = 0;
  fors(i, 1, n) {
    if (d[i] == 0) continue;
    if (d[i] > 0 && las < 0 || d[i] < 0 && las > 0) dlc.pb(now);
    now += d[i];
    las = d[i];
  }
  if (las) dlc.pb(now);
  if (dlc.size() <= 2) {
    if (las <= 0) cout << 1 << ' ';
    else cout << dlc[1] - dlc[0] + 1 << ' ';
    cout << (las < 0 ? (1 - dlc[1]) % mod : 1) << endl;
    return ;
  }
  num = dlc.size();
  minn[0] = 0;
  fors(i, 1, num - 1) {
    minn[i] = min(minn[i-1], dlc[i]);
  }
  fors(i, 0, num - 1) delta = max(delta, dlc[i] - minn[i]);
  fors(i, 0, num - 1) s.insert(dlc[i]);
  for (int i = 0; i < num; i++) {
    if (!s.count(dlc[i] + delta)) continue;
    int cur = -1;
    fors(j, i+1, num - 1) if (dlc[j] == dlc[i] + delta) cur = j;
    if (cur == -1) continue;
    seg.pb(mp(i, cur));
    i = cur;
  }
  for (auto v : seg) {
    l = v.first, r = v.second;
    get_ans();
  }
  cout << delta + 1 << ' ' << ans << endl;
  return ;
}

signed main() {
  #ifdef Sakuyalove
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
  #endif
  ios::sync_with_stdio(false);
  cin.tie(0);
  start_time = clock();
  main_init();
  int T = 1;
  // cin >> T;
  while (T--) {
    test_init();
    solve();
  }

  #ifdef Sakuyalove
    cout << "time = " << clock() - start_time << endl;
  #endif
  return 0;
}
### Prompt

Please create a solution in Cpp to the following problem:

Igor had a sequence d_1, d_2, ..., d_n of integers. When Igor entered the classroom there was an integer x written on the blackboard.

Igor generated sequence p using the following algorithm: 

  1. initially, p = [x]; 
  2. for each 1 ≤ i ≤ n he did the following operation |d_i| times: 
    * if d_i ≥ 0, then he looked at the last element of p (let it be y) and appended y + 1 to the end of p; 
    * if d_i < 0, then he looked at the last element of p (let it be y) and appended y - 1 to the end of p. 



For example, if x = 3, and d = [1, -1, 2], p will be equal [3, 4, 3, 4, 5].

Igor decided to calculate the length of the longest increasing subsequence of p and the number of them.

A sequence a is a subsequence of a sequence b if a can be obtained from b by deletion of several (possibly, zero or all) elements.

A sequence a is an increasing sequence if each element of a (except the first one) is strictly greater than the previous element.

For p = [3, 4, 3, 4, 5], the length of longest increasing subsequence is 3 and there are 3 of them: [\underline{3}, \underline{4}, 3, 4, \underline{5}], [\underline{3}, 4, 3, \underline{4}, \underline{5}], [3, 4, \underline{3}, \underline{4}, \underline{5}].

Input

The first line contains a single integer n (1 ≤ n ≤ 50) — the length of the sequence d.

The second line contains a single integer x (-10^9 ≤ x ≤ 10^9) — the integer on the blackboard.

The third line contains n integers d_1, d_2, …, d_n (-10^9 ≤ d_i ≤ 10^9).

Output

Print two integers: 

  * the first integer should be equal to the length of the longest increasing subsequence of p; 
  * the second should be equal to the number of them modulo 998244353. 



You should print only the second number modulo 998244353.

Examples

Input


3
3
1 -1 2


Output


3 3


Input


3
100
5 -3 6


Output


9 7


Input


3
1
999999999 0 1000000000


Output


2000000000 1


Input


5
34
1337 -146 42 -69 228


Output


1393 3876

Note

The first test case was explained in the statement.

In the second test case p = [100, 101, 102, 103, 104, 105, 104, 103, 102, 103, 104, 105, 106, 107, 108].

In the third test case p = [1, 2, …, 2000000000].

### Response

```cpp
#include <bits/stdc++.h>

using namespace std;

static struct FastInput {
  static constexpr int BUF_SIZE = 1 << 20;
  char buf[BUF_SIZE];
  size_t chars_read = 0;
  size_t buf_pos = 0;
  FILE *in = stdin;
  char cur = 0;
 
  inline char get_char() {
    if (buf_pos >= chars_read) {
      chars_read = fread(buf, 1, BUF_SIZE, in);
      buf_pos = 0;
      buf[0] = (chars_read == 0 ? -1 : buf[0]);
    }
    return cur = buf[buf_pos++];
  }
 
  inline void tie(int) {}
 
  inline explicit operator bool() {
    return cur != -1;
  }
 
  inline static bool is_blank(char c) {
    return c <= ' ';
  }
 
  inline bool skip_blanks() {
    while (is_blank(cur) && cur != -1) {
      get_char();
    }
    return cur != -1;
  }
 
  inline FastInput& operator>>(char& c) {
    skip_blanks();
    c = cur;
    return *this;
  }
  
  inline FastInput& operator>>(string& s) {
    if (skip_blanks()) {
      s.clear();
      do {
        s += cur;
      } while (!is_blank(get_char()));
    }
    return *this;
  }
 
  template <typename T>
  inline FastInput& read_integer(T& n) {
    // unsafe, doesn't check that characters are actually digits
    n = 0;
    if (skip_blanks()) {
      int sign = +1;
      if (cur == '-') {
        sign = -1;
        get_char();
      }
      do {
        n += n + (n << 3) + cur - '0';
      } while (!is_blank(get_char()));
      n *= sign;
    }
    return *this;
  }
 
  template <typename T>
  inline typename enable_if<is_integral<T>::value, FastInput&>::type operator>>(T& n) {
    return read_integer(n);
  }
  
  #if !defined(_WIN32) || defined(_WIN64)
  inline FastInput& operator>>(__int128& n) {
    return read_integer(n);
  }
  #endif
 
  template <typename T>
  inline typename enable_if<is_floating_point<T>::value, FastInput&>::type operator>>(T& n) {
    // not sure if really fast, for compatibility only
    n = 0;
    if (skip_blanks()) {
      string s;
      (*this) >> s;
      sscanf(s.c_str(), "%lf", &n);
    }
    return *this;
  }
} fast_input;
 
#define cin fast_input
 
static struct FastOutput {
  static constexpr int BUF_SIZE = 1 << 20;
  char buf[BUF_SIZE];
  size_t buf_pos = 0;
  static constexpr int TMP_SIZE = 1 << 20;
  char tmp[TMP_SIZE];
  FILE *out = stdout;
 
  inline void put_char(char c) {
    buf[buf_pos++] = c;
    if (buf_pos == BUF_SIZE) {
      fwrite(buf, 1, buf_pos, out);
      buf_pos = 0;
    }
  }
 
  ~FastOutput() {
    fwrite(buf, 1, buf_pos, out);
  }
 
  inline FastOutput& operator<<(char c) {
    put_char(c);
    return *this;
  }
 
  inline FastOutput& operator<<(const char* s) {
    while (*s) {
      put_char(*s++);
    }
    return *this;
  }
 
  inline FastOutput& operator<<(const string& s) {
    for (int i = 0; i < (int) s.size(); i++) {
      put_char(s[i]);
    }
    return *this;
  }
 
  template <typename T>
  inline char* integer_to_string(T n) {
    // beware of TMP_SIZE
    char* p = tmp + TMP_SIZE - 1;
    if (n == 0) {
      *--p = '0';
    } else {
      bool is_negative = false;
      if (n < 0) {
        is_negative = true;
        n = -n;
      }
      while (n > 0) {
        *--p = (char) ('0' + n % 10);
        n /= 10;
      }
      if (is_negative) {
        *--p = '-';
      }
    }
    return p;
  }
 
  template <typename T>
  inline typename enable_if<is_integral<T>::value, char*>::type stringify(T n) {
    return integer_to_string(n);
  }
 
  #if !defined(_WIN32) || defined(_WIN64)
  inline char* stringify(__int128 n) {
    return integer_to_string(n);
  }
  #endif
 
  template <typename T>
  inline typename enable_if<is_floating_point<T>::value, char*>::type stringify(T n) {
    sprintf(tmp, "%.17f", n);
    return tmp;
  }
 
  template <typename T>
  inline FastOutput& operator<<(const T& n) {
    auto p = stringify(n);
    for (; *p != 0; p++) {
      put_char(*p);
    }
    return *this;
  }
} fast_output;

// here puts define
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

#define rint register int
#define rll register ll 
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fors(i, a, b) for (ll i = (a); i <= (b); ++i)
#define _fors(i, a, b) for (ll i = (a); i >= (b); --i)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define mem(A, b) memset(A, b, sizeof(A))
#define all(X) (X).begin(), (X).end()
#define y0 gawgfawgawg
#define y1 sdfyseyegeh
#define pb push_back
#define eb emplace_back
#define cout fast_output
#define endl '\n'
#define int long long

int start_time;

// here puts const

const int mod = 998244353;

// here puts pre variable

int n, d[55];
int ans;
vector<int> dlc;
int num;
int minn[55];
int delta;
set<int> s;
vector<pii> seg;
int l, r;

// here puts function

inline int add(int a, int b) {
  return (((a + b) % mod) + mod) % mod;
}

inline int mul(int a, int b) {
  return (((1LL * a * b) % mod) + mod) % mod;
}

struct Matrix {
  int row, col;
  int a[55][55];
   
   Matrix operator * (const Matrix& rhs) const {
     assert(col == rhs.row);
     Matrix ret;
     ret.row = row, ret.col = rhs.col;
     fors(i, 1, ret.row) {
       fors(j, 1, ret.col) {
         ret.a[i][j] = 0;
         fors(k, 1, col) {
           ret.a[i][j] = add(ret.a[i][j], mul(a[i][k], rhs.a[k][j]));
         }
       }
     }
     return ret;
   }
};

Matrix qpow(Matrix A, int p) {
  assert(A.row == A.col);
  Matrix ret;
  ret.row = A.row, ret.col = A.col;
  fors(i, 1, ret.row) fors(j, 1, ret.col) ret.a[i][j] = (i == j);
  while (p) {
    if (p & 1) ret = ret * A;
    A = A * A;
    p >>= 1;
  }
  return ret;
}

void main_init() {

  return ;
}

void test_init() {

  return ;
}

void get_ans() {
  fors(i, l + 1, r) dlc[i] -= dlc[l];
  dlc[l] = 0;
  vector<int> tmp;
  fors(i, l, r) tmp.pb(dlc[i]);
  sort(all(tmp));
  unique(all(tmp));
  Matrix A, x;
  A.row = A.col = r - l;
  x.row = r - l, x.col = 1;
  tmp.erase(tmp.begin());
  fors(i, l + 1, r) x.a[i-l][1] = (dlc[i] == 0); 
  x.a[1][1] = 1;
  fors(i, 1, r - l) {
    if (dlc[l+i-1] == 0 || dlc[l+i] == 0) {
      fors(j, 1, i - 1) A.a[i][j] = 1;
      A.a[i][i] = i % 2; 
      fors(j, i + 1, r - l) A.a[i][j] = 0;
    }
    else {
      fors(j, 1, r - 1) A.a[i][j] = 0;
    }
  }
  int las = 0;
  for (auto v : tmp) {
    A = qpow(A, v - las);
    x = A * x;
    las = v;
    fors(i, 1, r - l) {
      if (i % 2) {
        if (dlc[i+l] <= v || dlc[i+l-1] > v) fors(j, 1, r - l) A.a[i][j] = 0;
        else {
          fors(j, 1, i) A.a[i][j] = 1;
          fors(j, i + 1, r - l) A.a[i][j] = 0;
        }
      }
      else {
        if (dlc[i+l] == v) {
          _fors(j, i - 1, 1) if (x.a[j][1]) { x.a[i][1] = x.a[j][1]; break; } 
        }
        if (dlc[i+l-1] == v) x.a[i][1] = 0;
        if (dlc[i+l] > v || dlc[i+l-1] <= v) fors(j, 1, r - l) A.a[i][j] = 0;
        else {
          fors(j, 1, i - 1) A.a[i][j] = 1;
          fors(j, i, r - l) A.a[i][j] = 0;
        }
      }
    }
    if (v == delta) break;
  }
  fors(i, 1, r - l) ans = add(ans, x.a[i][1]);
  return ;
}

void solve() {
  cin >> n >> d[0];
  d[0] = 0;
  fors(i, 1, n) cin >> d[i];
  dlc.pb(0);
  int now = 0, las = 0;
  fors(i, 1, n) {
    if (d[i] == 0) continue;
    if (d[i] > 0 && las < 0 || d[i] < 0 && las > 0) dlc.pb(now);
    now += d[i];
    las = d[i];
  }
  if (las) dlc.pb(now);
  if (dlc.size() <= 2) {
    if (las <= 0) cout << 1 << ' ';
    else cout << dlc[1] - dlc[0] + 1 << ' ';
    cout << (las < 0 ? (1 - dlc[1]) % mod : 1) << endl;
    return ;
  }
  num = dlc.size();
  minn[0] = 0;
  fors(i, 1, num - 1) {
    minn[i] = min(minn[i-1], dlc[i]);
  }
  fors(i, 0, num - 1) delta = max(delta, dlc[i] - minn[i]);
  fors(i, 0, num - 1) s.insert(dlc[i]);
  for (int i = 0; i < num; i++) {
    if (!s.count(dlc[i] + delta)) continue;
    int cur = -1;
    fors(j, i+1, num - 1) if (dlc[j] == dlc[i] + delta) cur = j;
    if (cur == -1) continue;
    seg.pb(mp(i, cur));
    i = cur;
  }
  for (auto v : seg) {
    l = v.first, r = v.second;
    get_ans();
  }
  cout << delta + 1 << ' ' << ans << endl;
  return ;
}

signed main() {
  #ifdef Sakuyalove
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
  #endif
  ios::sync_with_stdio(false);
  cin.tie(0);
  start_time = clock();
  main_init();
  int T = 1;
  // cin >> T;
  while (T--) {
    test_init();
    solve();
  }

  #ifdef Sakuyalove
    cout << "time = " << clock() - start_time << endl;
  #endif
  return 0;
}
```