#include <iostream>

using namespace std;

int *X, *D, *ocena;
int n, t;

long long saberi(int index){
    int duzina = 0;
    int lepota = 0;
    int pocetniIndex = index;

    while (duzina <= t){
        lepota += ocena[index];
        //index = sledeca(index);
        duzina += D[index];
        index = X[index];
        if (index == pocetniIndex && duzina <= t){
            //cout << "Lepota: " << lepota << "   duzina:" << duzina << endl;
            lepota = (t / duzina) * (lepota);
            //cout << t - t % duzina << endl;
            duzina = t - t % duzina;
        }
    }
    //if (duzina > t){
        //lepota -= poslednjaLepota;
    //}
    //lepota += ocena[index];
    return lepota;
}

int main()
{
    std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> t;

    X = new int[n];
    D = new int[n];
    ocena = new int[n];

    int i;
    for (i = 0; i < n; ++i){
        cin >> ocena[i];
    }
        for (i = 0; i < n; ++i){
            cin >> X[i];
            X[i] -= 1;
        }
        //for (i = 0; i < n; ++i){
            //X[i] = sledeca(i, x);
        //}
        /*for (i = 0; i < n; ++i){
            cout << X[i]  << endl;
        }*/
    for (i = 0; i < n; ++i){
        cin >> D[i];
    }

    long long best = 0;

    for (int i = 0; i < n; ++i){
        best = max(saberi(i), best);
        //cout << i << ": " << saberi(i) << endl;
    }

    cout << best;

    delete X;
    delete D;
    delete ocena;

    return 0;
}