#include<bits/stdc++.h>

using namespace std;

pair<pair<int,int>,pair<int,int> > niz[100000];
/*
int bfs(int cvor,int v,int poc)
{
    if(v < 0 )
        return 0;
    //cout << niz[cvor].second.first << " " << niz[cvor].second.second << " " << v-niz[cvor].second.second <<endl;

    return niz[cvor].second.first + bfs(niz[cvor].first.second,v-niz[cvor].second.second);
}*/

int main()
{
    int n,t;
    cin >> n >> t;
    for(int i = 0;i < n;i++)
    {
        int a;
        cin >> a;
        niz[i] = {{i,0},{a,0}};
    }
    for(int i = 0;i < n;i++)
    {
        int a;
        cin >> a;
        niz[i].first.second = a-1;
    }

    for(int i = 0;i < n;i++)
    {
        int a;
        cin >> a;
        niz[i].second.second = a;
    }
    int ma = -1;
    for(int i = 0;i < n;i++)
    {
        int v = t;
        int cvor = i;
        int a=0;
        //int a = bfs(i,t);
        while(v > 0)
        {
            if(v!=t && cvor == i)
            {
                a += a*(t/(t-v));
                v = v - t/(t-v)*v;
                cvor = niz[cvor].first.second;
                continue;
            }
            cvor = niz[cvor].first.second;
            v = v-niz[cvor].second.second;
            a += niz[cvor].second.first;
        }
        //cout << a << endl;
        if(a > ma)
            ma = a;
    }
    cout << ma;
}
/*
5 7
7 3 1 4 8
4 3 5 2 1
3 2 4 1 7


6 200
1 1 1 1 1 100
3 1 2 5 4 5
1 1 1 10 10 1
*/