#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define endl "\n"
ll mod=1000000007;
ll arr[10][10],n,k;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll finds(set<int> st,ll sum,ll prev)
{
    //cout<<"yo "<<st.size()<<" "<<prev<<" "<<sum<<endl;
    if(st.size()==0 && sum+arr[prev][0]==k)return 1;
    if(st.size()==0)return 0;
    ll ans=0;
    for(int i:st)
    {
        set<int> st1;
        st1=st;
        st1.erase(i);
        ans+=finds(st1,sum+arr[i][prev],i);

    }
    return ans;
}
int main()
{
    IOS;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    //ll t;cin>>t;while(t--)
    {
        ll a,b,c,d,i,j,sum=0,temp=0,f=0,cnt=0;
        cin>>n>>k;
        for(i=0;i<n;i++)
            for(j=0;j<n;j++)
                cin>>arr[i][j];
        set<int>st;
        for(i=1;i<n;i++)
            st.insert(i);
        cout<<finds(st,0,0);



    }
}

#include <bits/stdc++.h>
#define Fr(i,a,b) for(int i=(a);i<=(b);++i)
#define Fl(i,a,b) for(int i=(a);i>=(b);--i)
#define Fe(i,u) for(int i=H[u];i;i=e[i].nx)
#define ms(a,x) memset((a),(x),sizeof(a));
using namespace std;
int N,G[15][15],K,vis[15],ans;
void dfs(int s,int x,int sum)
{
	if(x==N)
	{
		if(G[s][1]+sum==K)++ans;
		return;
	}
	Fr(i,2,N)
	{
		if(!vis[i])
		{
			vis[i]=1;
			dfs(i,x+1,sum+G[s][i]);
			vis[i]=0;
		}
	}
}
int main()
{
	scanf("%d%d",&N,&K);
	Fr(i,1,N)Fr(j,1,N)scanf("%d",&G[i][j]);
	dfs(1,1,0);
	cout<<ans;
}