#include <iostream>
#include <deque>
#include <vector>
#include <math.h>
#define N 100001
#define x first
#define y second


using namespace std;

/// PESMA MORA BITI CELA LEPA

int n,time;
int lepota[N]={};
int finale=0;

int lepotacelog=0;
int duzinacelog=0;

pair <int,int> roads[N]={};

int solve(int node)
{
    int res=lepota[node];
    int local=0;
    int a=node;
    while(local + roads[a].y <=time)
    {
        ///cout<<roads[a].y<<" ";
        local += roads[a].y;
        a = roads[a].x;
        res += lepota[a];
    }
    ///cout<<endl;
    return res;
}

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

    cin>>n>>time;

    for(int i=1;i<=n;i++){
        cin>>lepota[i];
        lepotacelog+=lepota[i];
    }

    for(int i=1;i<=n;i++)
    {
        cin>>roads[i].x;
    }
    for(int i=1;i<=n;i++)
    {
        cin>>roads[i].y;
        duzinacelog += roads[i].y;
    }

    ///cout<<duzinacelog<<endl;

    //cout<<solve(1)<<endl;
    //cout<<solve(2)<<endl;
    //cout<<solve(3)<<endl;
    //cout<<solve(4)<<endl;
    //cout<<solve(5)<<endl;

    int ciklovv = (time/duzinacelog)*lepotacelog;

    time = time % duzinacelog;

    for(int i=1;i<=n;i++)
    {
        finale = max(finale, solve(i)+ciklovv);
    }

    cout<<finale<<endl;

}