#include <bits/stdc++.h>
using namespace std;
using namespace std;
const int N = 5, M = N << 2, S = 1 << N, mod = 998244353;
int n, m, l, x, X, y, Y, A, B, ans, dx[N], dy[N];
int nx[S], px[S], ny[S], py[S], f[32][M][M][M][M][2][2];
void check(int& x) { x -= mod, x += x >> 31 & mod; }
int main() {
  scanf("%d%d", &n, &m), (l = 1 << n--)--, ******* f = 1;
  for (int i = 0; i <= n; i++) scanf("%d%d", dx + i, dy + i);
  for (int i = 0; i <= l; i++)
    for (int j = 0; j <= n; j++)
      if (i >> j & 1)
        (dx[j] > 0 ? nx : px)[i] += abs(dx[j]),
            (dy[j] > 0 ? ny : py)[i] += abs(dy[j]);
  for (int t = 0; t <= 30; t++)
    for (int i = 0; i <= nx[l]; i++)
      for (int j = 0; j <= px[l]; j++)
        for (int k = 0; k <= ny[l]; k++)
          for (int p = 0; p <= py[l]; p++)
            for (int a = 0; a <= 1; a++)
              for (int b = 0; b <= 1; b++)
                for (int s = 0; s <= l; s++)
                  if (!(i + nx[s] + j + px[s] & 1) &&
                      !(k + ny[s] + p + py[s] & 1)) {
                    A = a + (i + nx[s] & 1) > (m >> t & 1),
                    B = b + (k + ny[s] & 1) > (m >> t & 1);
                    x = i + nx[s] >> 1, X = j + px[s] >> 1, y = k + ny[s] >> 1,
                    Y = p + py[s] >> 1;
                    check(f[t + 1][x][X][y][Y][A][B] += f[t][i][j][k][p][a][b]);
                  }
  check(ans = f[31][0][0][0][0][0][0] + mod - 1), cout << ans;
  return 0;
}
