#include <bits/stdc++.h>
#define PINT pair<int, int>
#define MP make_pair
#define F first
#define S second

using namespace std;

int n, t, d[100010], x[100010], a[100010], f[100010], tp, lb, rb, length;
int l[100010], g[100010], c[100010], vis[100010], r[100010], gc[100010], nc = 0, ans = 0, gain;
vector<PINT > adj[100010];

void dfs(int curr)
{
    int next;
    c[curr] = nc;
    vis[curr] = 1;
    for (int i = 0; i < adj[curr].size(); ++i)
    {
        next = adj[curr][i].F;
        if (c[next] == c[curr])
        {
            l[c[curr]] += adj[curr][i].S;
            g[c[curr]] += a[curr];
            f[curr] = next;
            nc++;
            return;
        }
        if (vis[next] == 0)
        {
            dfs(next);
            if (c[next] == c[curr])
            {
                l[c[curr]] += adj[curr][i].S;
                g[c[curr]] += a[curr];
                f[curr] = next;
                return;
            }
        }
    }
    c[curr] = -1;
}

int main()
{
    scanf("%i%i", &n, &t);
    tp = t;
    for (int i = 0; i < n; ++i)
        scanf("%i", &a[i]);
    for (int i = 0; i < n; ++i)
        scanf("%i", &x[i]);
    for (int i = 0; i < n; ++i) x[i]--;
    for (int i = 0; i < n; ++i)
        scanf("%i", &d[i]);
    for (int i = 0; i < n; ++i)
        adj[x[i]].push_back(MP(i, d[i]));
    for (int i = 0; i < n; ++i) c[i] = -1;
    for (int i = 0; i < n; ++i)
        if (vis[i] == 0)
            dfs(i);
    for (int i = 0; i < nc; ++i) r[i] = t % l[i];
    for (int i = 0; i < n; ++i) gc[i] = -1;
    for (int i = 0; i < n; ++i)
    {
        if (c[i] == -1) continue;
        if (gc[i] != -1) continue;
        lb = rb = i;
        length = 0;
        gc[lb] = a[lb];
        do
        {
            while (length + d[f[rb]] < r[c[lb]])
            {
                rb = f[rb];
                length += d[f[rb]];
                gc[lb] += a[rb];
            }
            gc[f[lb]] = gc[lb] - a[lb];
            // printf("%i %i\n", lb, rb);
            if (lb == rb)
            {
                rb = f[rb];
                gc[rb] = a[rb];
                length += d[rb];
            }
            lb = f[lb];
            length -= d[lb];
        }
        while (lb != i);
        // printf("\n");
    }
    /*
    for (int i = 0; i < n; ++i) printf("%i ", c[i]);
    printf("\n");
    for (int i = 0; i < nc; ++i) printf("%i ", l[i]);
    printf("\n");
    for (int i = 0; i < nc; ++i) printf("%i ", g[i]);
    printf("\n");
    for (int i = 0; i < nc; ++i) printf("%i ", r[i]);
    printf("\n");
    for (int i = 0; i < n; ++i) printf("%i ", f[i]);
    printf("\n");
    for (int i = 0; i < n; ++i) printf("%i ", gc[i]);
    printf("\n");
    */
    for (int i = 0; i < n; ++i)
        ans = max(g[c[i]] * (t / l[c[i]]) + gc[i], ans);
    printf("%i", ans);
    return 0;
}