#include <bits/stdc++.h>
using namespace std;
long long read() {
  long long x = 0, f = 0;
  char ch = getchar();
  while (!isdigit(ch)) f = ch == '-', ch = getchar();
  while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
  return f ? -x : x;
}
const int N = 5, mod = 998244353;
void Add(int &x, int y) {
  if ((x += y) >= mod) x -= mod;
}
int n, m;
int x[N], y[N];
int dp[32][20][20][20][20][2][2];
int Px[1 << N], Py[1 << N], Nx[1 << N], Ny[1 << N];
int main() {
  n = read(), m = read();
  for (int i = (0); i <= (n - 1); i++) x[i] = read(), y[i] = read();
  for (int s = (0); s <= ((1 << n) - 1); s++)
    for (int i = (0); i <= (n - 1); i++)
      if (s >> i & 1) {
        (x[i] > 0 ? Px : Nx)[s] += abs(x[i]);
        (y[i] > 0 ? Py : Ny)[s] += abs(y[i]);
      }
  memset(dp, 0, sizeof(dp));
  dp[0][0][0][0][0][0][0] = 1;
  for (int i = (0); i <= (29); i++) {
    int bit = m >> i & 1;
    for (int px = (0); px <= (19); px++)
      for (int py = (0); py <= (19); py++)
        for (int nx = (0); nx <= (19); nx++)
          for (int ny = (0); ny <= (19); ny++)
            for (int kx = (0); kx <= (1); kx++)
              for (int ky = (0); ky <= (1); ky++) {
                int v = dp[i][px][py][nx][ny][kx][ky];
                if (!v) continue;
                for (int s = (0); s <= ((1 << n) - 1); s++) {
                  int a = px + Px[s], b = py + Py[s], c = nx + Nx[s],
                      d = ny + Ny[s];
                  if ((a & 1) == (c & 1) && (b & 1) == (d & 1))
                    Add(dp[i + 1][a >> 1][b >> 1][c >> 1][d >> 1]
                          [(a & 1) > bit || (a & 1) == bit && kx]
                          [(b & 1) > bit || (b & 1) == bit && ky],
                        v);
                }
              }
  }
  cout << (dp[30][0][0][0][0][0][0] - 1 + mod) % mod << endl;
  return 0;
}
