#include <bits/stdc++.h>

using ull = unsigned long long int;
using ll = long long;
using ld = long double;
using pii = std::pair<int,int>;
using pll = std::pair<ll, ll>;
using vi = std::vector<int> ;
using vvi = std::vector<vi> ;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vd = std::vector<double> ;
using vvd = std::vector<vd> ;
using qi = std::queue<int> ;
using vpii = std::vector<std::pair<int, int> >;
using vpll = std::vector<pll>;
using namespace std;

#define rep(i,j) for(int (i)=0;(i)<(j);(i)++)
#define drep(i,j) for(int (i)=(j);(i) >= 0;(i)--)


template<class T1, class T2> inline void chmin(T1 &a, T2 b){if(a > b) a = b;}
template<class T1, class T2> inline void chmax(T1 &a, T2 b){if(a < b) a = b;}
template<class T> inline void pri(T a){cout << a << endl;}
template<class Z> using vec = vector<Z>;
template<class T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
 cout << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
cout << first << " " ; 
OUT(rest...);
   return;
}
const int max_n = 3 * (1e5) + 1;
const int max_m = 83 * (1e5) + 1;

int n,m,k;
ll N;
int h,w;
string S;
int a,b,c;
vi v;
int ans;
double x,y,z;

void solve()
{
    int N; IN(N);
    vector<vector<int>> g(N);
    vector<pair<int,int>> edge(N-1);
    rep(i,N-1)
    {
        int a,b; IN(a,b); a--;b--;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
        edge[i] = pii{a,b};
    }
    
    vll depth(N,-1);
    depth[0] = 0;
    queue<pair<int,int>> q;
    q.push({0,-1});
    while(!q.empty())
    {
        int curr = q.front().first; 
        int from = q.front().second;
       // OUT(curr,from);
        q.pop();
        for(auto  &npt : g[curr])
        {
            if(npt == from) continue;
            depth[npt] = depth[curr] + 1;
            q.push({npt,curr});
            //cout << npt << " ";
        }
        //OUT();
    }
    vll s(N);
    int Q; IN(Q);
    rep(_,Q)
    {
        int t,e;
        ll x;
        IN(t,e,x);
        e--;
        int a = edge[e].first;
        int b = edge[e].second;
        if(depth[a] > depth[b])
        {
            swap(a,b);
            t ^= 3;
        }
        if(t == 1)
        {
            s[0] += x;
            s[b] -= x;
        }
        else s[b] += x;
    }

    q.push({0,-1});
    while(!q.empty())
    {
        int curr = q.front().first;
        int from = q.front().second;
        q.pop();
        for(auto & npt: g[curr])
        {
            if(depth[curr] > depth[npt])continue;
            s[npt] += s[curr];
            q.push({npt,curr});
        }
    }
    for(auto &e : s)cout << e << endl;
    
}

signed main (int argc, char* argv[]) {
   cin.tie(0);
   ios::sync_with_stdio(false);
   int cases=1;
   //IN(cases);
   while(cases--)solve();
   //pri(ans);
   //for(auto c : ans){cout << c << endl;}
   //cout << fixed << setprecision(15) << ans << endl;
   return 0;
}
#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for (int i = (a), i##end = (b); i < i##end; ++i)
#define per(i, a, b) for (int i = (a) - 1, i##end = (b); i >= i##end; --i)
#define REP(i, a) rep(i, 0, a)
#define PER(i, a) rep(i, a, 0)

namespace IO {
	const int MAXIOSIZE = 1 << 24 | 1;
	unsigned char buf[MAXIOSIZE], *p1, *p2;
	#define gc (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 24, stdin), p1 == p2) ? EOF : *p1++)
	template <typename T> void read(T& x) {
		x = 0; char ch = gc; bool flg = false;
		for (; ch < '0' || '9' < ch; ch = gc) if (ch == '-') flg |= true;
		for (; '0' <= ch && ch <= '9'; ch = gc) x = x * 10 + ch - '0';
		flg ? x = -x : 0;
	}
	template <typename T> void out(const T& x) { if (x > 9) out(x / 10); putchar(x % 10 + '0'); }
	template <typename T> inline void write(const T& x, const char& ed = ' ') { if (x < 0) putchar('-'), out(-x); else out(x); putchar(ed); }
}

typedef long long ll;

const int MAXN = 100 + 10;

int n;
ll X, a[MAXN], f[MAXN][MAXN], ans = LONG_LONG_MAX;

void chkmax(ll& a, ll b) { a < b ? a = b : 0; }

int main() {
	#ifdef LOCAL
		freopen("in.txt", "r", stdin);
	#endif
	IO::read(n), IO::read(X);
	REP(i, n) IO::read(a[i]);
	rep(cnt, 1, n + 1) {
		memset(f, -1, sizeof f); f[0][0] = 0, f[1][a[0] % cnt] = a[0];
		REP(i, n - 1) per(j, cnt + 1, 1) REP(k, cnt) if (f[j][k] != -1) {
			chkmax(f[j + 1][(k + a[i + 1]) % cnt], f[j][k] + a[i + 1]);
		}
		if (f[cnt][X % cnt] != -1) ans = min(ans, (X - f[cnt][X % cnt]) / cnt);
	}
	IO::write(ans);
	return 0;
}

