#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main (){
	int n,k;
	cin >> n >> k;
	vector<vector<int>>T(n,vector<int>(n));
	for(int i=0;i<n;i++)for(int j=0;j<n;j++){
		cin >> T[i][j];
	}
	
	vector<int>index;
	for(int i=0;i<n;i++)index.push_back(i);

	int ans=0;
	do{
		int time=0;
		for(int i=0;i<n;i++)time+=T[index[i]][index[(i+1)%n]];
		if(time==k)ans++;
	}while(next_permutation(index.begin()+1, index.end()));
	cout << ans;
}
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define f(i,a,n) for(ll i=a;i<n;i++)
#define w(x) ll _t;cin>>_t;f(x,1,_t+1)
#define br cout<<"\n"
#define N 10000000
ll md=1e9+7,n;
ll h,w,m,k;
//l,d,r,u
ll x[]={0,1,0,-1};
ll y[]={1,0,-1,0};
ll mat[15][15];
bool isSafe(ll i,ll j){
    return i>=0 && i<h && j>=0 && j<w;
}
ll sol(ll x,ll sm,ll u){
    if(x==(1<<n)-1){
        if(sm+mat[0][u]==k) return 1;
        return 0;
    }
    ll ans=0;
    f(i,0,n){
        if(((1<<i) & x) == 0){
            ans += sol(x | (1<<i) ,sm+mat[u][i] ,i);
        }
    }
    return ans;
}

int main() {
    ios::sync_with_stdio(false);cin.tie(0);
    
    //w(_x)
    {
        cin>>n>>k;
        f(i,0,n) f(j,0,n) cin>>mat[i][j];
        cout<<sol(1,0,0);
    }
    return 0;
}