#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1<<30;
const ll inf_l = 1LL<<61;
const int MAX = 2 * 1e5 + 5;

ll ans[MAX];
int dis[MAX];
vvint g;

void dfs(int v, int d = 0, int p = -1) {
    dis[v] = d;
    for (int n_v : g[v]) {
        if (n_v == p) continue;
        dfs(n_v, d + 1, v);
    }
}

void solve(int v, int p = -1) {
    for (int n_v : g[v]) {
        if (n_v == p) continue;
        ans[n_v] += ans[v];
        solve(n_v, v);
    }
}

int main() {
    int n; cin >> n;
    g.resize(n);
    vector<P> dat(n);
    rep(i,n-1) {
        int a, b; cin >> a >> b;
        a--; b--;
        dat[i] = P(a, b);
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dfs(0);
    // rep(i,n) cout << dis[i] << endl;
    int q; cin >> q;
    rep(i,q) {
        int t, e, x; cin >> t >> e >> x;
        e--;
        auto [a, b] = dat[e];
        if (t == 1) {
            if (dis[a] < dis[b]) {
                ans[0] += x;
                ans[b] -= x;
            } else {
                ans[a] += x;
            }
        } else {
            if (dis[a] < dis[b]) {
                ans[b] += x;
            } else {
                ans[0] += x;
                ans[a] -= x;
            }
        }
    }
    solve(0);
    rep(i,n) cout << ans[i] << endl;
}
#include <bits/stdc++.h>

using namespace std;

#define LL long long

constexpr LL MOD = 1000000007;

typedef vector<vector<LL>> Mat;

Mat mul(Mat A, Mat B) {
  int N = A.size();
  Mat C(N, vector<LL>(N, 0));

  for (int i = 0; i < N; i++)
    for (int j = 0; j < N; j++)
      for (int k = 0; k < N; k++)
        C[i][j] = (C[i][j] + ((A[i][k] * B[k][j]) % MOD)) % MOD;
  return C;
}

LL extended_euclidean(LL a, LL b, LL &x, LL &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }

  LL x1, y1;
  LL g = extended_euclidean(b, a % b, x1, y1);
  x = y1;
  y = x1 - (a / b) * y1;
  return g;
}

LL invmod(LL a) {
  LL x, y;
  extended_euclidean(a, MOD, x, y);
  return (x % MOD + MOD) % MOD;
}

vector<vector<int>> adj;
Mat A; // weight
Mat m; // transition matrix

int main() {
  int N, M, K;
  cin >> N >> M >> K;

  A.resize(N);
  adj.resize(N);
  m.resize(N);

  for (int i = 0; i < N; i++) {
    A[i].resize(1);
    cin >> A[i][0];
  }

  for (int i = 0; i < M; i++) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }

  // calculate the matrix.
  LL inv2M = invmod(2 * M);
  for (int i = 0; i < N; i++) {
    m[i].assign(N, 0);
    m[i][i] = 1LL;

    for (int j : adj[i]) {
      m[i][j] = inv2M;
      m[i][i] = (m[i][i] - inv2M + MOD) % MOD;
    }
  }

  while (K > 0) {
    if (K & 1)
      A = mul(m, A);
    m = mul(m, m);
    K >>= 1;
  }

  for (int i = 0; i < N; i++)
    cout << A[i][0] << endl;
}