#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define RNG(i, from, to) for (ll i = (from); i < (ll)(to); i++)
#define gcd(i, j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vecll;
template <typename S, typename T>
string to_string(pair<S, T> p) { return "(" + to_string(p.first) + "," + to_string(p.second) + ")"; }
template <typename T>
void println(T e) { cout << to_string(e) << endl; }
template <typename T>
void println(const vector<T> &v)
{
    cout << "[";
    for (const auto &e : v)
    {
        cout << to_string(e) << ",";
    }
    cout << "]";
    cout << endl;
}
template <typename T>
void println(const vector<vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        println(v);
    }
}
template <typename Iter>
void println(Iter first, Iter last)
{
    for (auto it = first; it != last; it++)
    {
        cout << *it << " ";
    };
    cout << endl;
}
template <typename T>
T mod_pow(T x, T n, const T &p)
{
    T ret = 1;
    while (n > 0)
    {
        if (n & 1)
            (ret *= x) %= p;
        (x *= x) %= p;
        n >>= 1;
    }
    return ret;
}
template <typename T>
T mod_inv(T x, const T &p) { return mod_pow(x, p - 2, p); }
const ll DVSR = 1e9 + 7;

void dfs(ll i, ll bef, map<ll, vecll> &TR, map<ll, vecll> &DF, vecll &BUF)
{
    for (const auto j : TR[i])
        if (j != bef)
        {
            auto item = DF.find(i + (j << 32));
            if (item != DF.end())
                for (const auto q : item->second)
                {
                    BUF[j] += q;
                    if (q < 0)
                        BUF[0] -= q;
                }
            dfs(j, i, TR, DF, BUF);
        }
}

void dfs2(ll i, ll bef, ll sm, vecll &res, map<ll, vecll> &TR, map<ll, vecll> &DF, const vecll &BUF)
{
    res[i] = sm + BUF[i];
    for (const auto j : TR[i])
    {
        if (j != bef)
        {
            dfs2(j, i, sm + BUF[i], res, TR, DF, BUF);
        }
    }
}
int main(int argc, char const *argv[])
{
    ll N, Q;
    cin >> N;
    vector<vector<ll>> MP;
    vector<pll> INL;
    map<ll, vecll> DF;
    map<ll, vecll> TR;
    vecll BUF;
    BUF.assign(N, 0);
    MP.assign(N, vector<ll>{});

    REP(k, N - 1)
    {
        ll i, j;
        cin >> i >> j;
        i--;
        j--;
        INL.push_back(pll(i, j));
    }
    cin >> Q;

    REP(k, Q)
    {
        ll t, e, x;
        cin >> t >> e >> x;
        e--;
        auto [i, j] = INL[e];
        ll ii = i + (j << 32);
        ll jj = j + (i << 32);

        auto iter = DF.find(ii);
        ll sign = t != 1 ? 1 : -1;
        if (iter == DF.end())
        {
            DF[ii] = vecll{x * sign};
            DF[jj] = vecll{-x * sign};
        }
        else
        {
            DF[ii].push_back(x * sign);
            DF[jj].push_back(-x * sign);
        }
    }
    for (const auto [a, b] : INL)
    {
        const auto nda = TR.find(a);
        const auto ndb = TR.find(b);
        if (nda == TR.end())
        {
            TR[a] = vecll{b};
        }
        else
        {
            nda->second.push_back(b);
        }
        if (ndb == TR.end())
        {
            TR[b] = vecll{a};
        }
        else
        {
            ndb->second.push_back(a);
        }
    }
    dfs(0, 0, TR, DF, BUF);
    vecll res;
    res.assign(N, 0);
    dfs2(0, 0, 0, res, TR, DF, BUF);
    for (const auto i : res)
    {
        cout << i << endl;
    }
    return 0;
}


  #include <bits/stdc++.h>
    // #include <ext/pb_ds/assoc_container.hpp>
  using namespace std;
  // using namespace __gnu_pbds;
  // template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
  #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  #define TRACE
  #ifdef TRACE
  #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
  template <typename Arg1>
  void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
  }
  template <typename Arg1, typename... Args>
  void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
  }
  #else
  #define trace(...) 
  #endif
  template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
  template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
  template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
  typedef long long int ll;
  const ll mod =1e9+7;
  const int maxn = 300005;
  #define endl '\n'
  #define ld long double
  #define int ll
  #define all(x)  (x).begin(),(x).end()

int c(int x,int y){
  int cnt = 0;
  while(x%3 == 0){
    x/=3;
    cnt++;
  }
  x = y;
  while(y%3 == 0){
    y/=3;
    cnt--;
  }
  return cnt;
}

int get(int x){
  while(x%3 == 0) x/=3;
  return x;
}

int32_t main(){

    IOS


    int n;
    cin >> n;
    string s;
    cin >> s;

    vector<int> coef(n);
    coef[0] = 1;
    map<char,int> m;
    m['R'] = 0;
    m['W'] = 1;
    m['B']  = 2; 
    int powers = 0;
    int last = 1;
    for(int i = 1; i < n;i++){
      powers += c(n - i, i);
      last = (last * get(n - i)*get(i))%3;
      assert(powers >= 0);
      if(powers > 0){
        coef[i] = 0;
      }
      else{
        coef[i] = last;
      }
    }


    int ans = 0;
    for(int i = 0; i < n;i++){
      ans = (ans + coef[i] * m[s[i]])%3;
    }


    if((n- 1)%2){
      ans = (3 - ans)%3;
    }

    for(auto i: m){
      if(i.second == ans) cout << i.first << endl;
    }







    



  

    


} 
  