#include <bits/stdc++.h>

using namespace std;

#ifdef BOI
#include "debug.h"
#else
#define debug(args...)
#endif

typedef long long ll;

int main() {
      ios_base :: sync_with_stdio(0);
      cin.tie(0);

      int n; cin >> n;
      ll k; cin >> k;
      vector <vector <ll>> a(n, vector <ll>(n));
      for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                  cin >> a[i][j];
            }
      }      

      vector <int> aa(n);
      iota(aa.begin(), aa.end(), 0);
      int cnt = 0;
      do {
            ll sum = 0;
            for (int i = 1; i < n; ++i) {
                  sum += a[aa[i]][aa[i - 1]];
            }
            sum += a[aa[n - 1]][0];
            if (sum == k) ++cnt;
            debug(aa, sum);
      } while (next_permutation(aa.begin() + 1, aa.end()));

      cout << cnt;
}     

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<ll mod>
struct Mint {
    ll x;
    Mint(ll x = 0) : x((x %= mod) < 0 ? x + mod : x) { }
    Mint& operator+=(Mint rhs) { return (x += rhs.x) >= mod ? x -= mod : 0, *this; }
    Mint& operator-=(Mint rhs) { return (x -= rhs.x) < 0 ? x += mod : 0, *this; }
    Mint& operator*=(Mint rhs) { return (x *= rhs.x) %= mod, *this; }
    Mint& operator/=(Mint rhs) { return *this *= rhs.power(-1); }
    Mint power(ll p) const {
        p %= mod - 1;
        if (p < 0) p += mod - 1;
        Mint res = 1;
        for (Mint y = *this; p; p >>= 1, y *= y) if (p & 1) res *= y;
        return res;
    }
    bool operator==(Mint rhs) const { return x == rhs.x; }
    bool operator<(Mint rhs) const { return x < rhs.x; }
    friend Mint operator+(Mint lhs, Mint rhs) { return lhs += rhs; }
    friend Mint operator-(Mint lhs, Mint rhs) { return lhs -= rhs; }
    friend Mint operator*(Mint lhs, Mint rhs) { return lhs *= rhs; }
    friend Mint operator/(Mint lhs, Mint rhs) { return lhs /= rhs; }
    friend ostream& operator<<(ostream& out, Mint a) { return out << a.x; }
    friend istream& operator>>(istream& in, Mint& a) {
        ll x;
        in >> x;
        a = Mint(x);
        return in;
    }
};
constexpr ll mod = 998244353;
using mint = Mint<mod>;
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int N;
    cin >> N;
    const int Wmax = 100;
    vector<vector<mint>> dp(N + 1, vector<mint>(N * Wmax + 1));
    dp[0][0] = 1;
    int sum = 0;
    for (int i = 0; i < N; ++i) {
        int W;
        cin >> W;
        for (int k = N - 1; k >= 0; --k) {
            for (int x = N * Wmax - W; x >= 0; --x) {
                dp[k + 1][x + W] += dp[k][x];
            }
        }
        sum += W;
    }
    mint ans = 0;
    if (sum % 2 == 0) {
        vector<mint> f(N + 1, 1);
        for (int x = 1; x <= N; ++x) {
            f[x] = x * f[x - 1];
        }
        for (int k = 1; k <= N; ++k) {
            ans += dp[k][sum / 2] * f[k] * f[N - k];
        }
    }
    cout << ans << endl;
    exit(0);
}
