#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr)
//:/
#define pb push_back
#define mp make_pair
#define nt _ll128
#define ld long double
long double PI =3.14159265;
using ll = long long;

const ll modo=1e9+7;
const ll ms=1e5+5;
const ll inf=1e17;


ll dis[100][100];



int main()
{
    idfc;

    int n,k;
    cin>>n>>k;

    vector<int> vv;
    int i;int j;
    for(i=2;i<=n;i++)vv.pb(i);
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)cin>>dis[i][j];
    }
    int ans=0;
    int tot=0;
    do{
       // cout<<"sdsd"<<endl;
        ans=0;
        int pr=1;
        for(i=0;i<n-1;i++)
        {
            ans+=(dis[pr][vv[i]]);
            pr=vv[i];
        }
        ans+=dis[pr][1];
        if(ans==k)tot++;
    }
    while(next_permutation(vv.begin(),vv.end()));
    cout<<tot;
    return 0;
}
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word
//ctrl+end - to break infinite loop in sublime text
 
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
using namespace std; 
#define Fio                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(nullptr);                 \
    cout.tie(nullptr)
#define ll long long int
#define fo(i, a, b) for (long long int i = a; i <= b; i++)
#define w(t)  \
    int t;    \
    cin >> t; \
    while (t--)
#define all(v) v.begin(),v.end()
#define vi vector<int>
#define vl vector<long long int>
#define vvi vector<vector<int>>
#define vvl vector<vector<long long int>>
#define mii map<int, int>
#define umii unordered_map<int, int>
#define mll map<ll,ll>
#define umll unordered_map<ll,ll>
#define newl cout<<"\n"
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const ll inf = 1e9+7;
const ll mod = 1e9+7;
#define MAX 300005

void call_priyanshu(){
    Fio;
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt", "w", stdout);
        //freopen("error.txt","w",stderr);
    #endif
}

ll mini(ll a,ll b){
    if(a>=b)return b;
    return a;
}
 
ll maxi(ll a,ll b){
    if(a>=b)return a;
    return b;
}

bool cmp(pair<ll,string> a,pair<ll,string> b){
    return a.fi>b.fi;
}

void solve(){
    //write your code here
    ll n;
    cin>>n;
    vector<pair<ll,string>>A;
    fo(i,1,n){
        string s;
        ll h;
        cin>>s>>h;
        A.pb(mp(h,s));
    }
    sort(all(A),cmp);
    cout<<A[1].se;
}

int main(){
    call_priyanshu();
    // w(t){
        solve();
    // }
    return 0;
}