#include <bits/stdc++.h>
using namespace std;
#define fst ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endk cout<<"\n";
typedef long long int ll;
typedef long int l;
#define l(i,a,b) for(i=a;i<b;i++)
#define lo(i,a,b) for(i=a;i>=b;i--)
#define s(v) sort(v.begin(),v.end());
#define pb push_back;
#define vll vector<ll>
#define vint vector<int>
#define test() ll t;cin>>t;while(t--){solve();};
#define test1() int t=1;while(t--){solve();};
bool isprime(ll x)
{
    if(x==1) return false;
    if(x==2 || x==3) return true;
    if(x%2==0 || x%3==0) return false;
    for(ll i=5;i*i<=x;i+=6)
    {
        if(x%i==0 || x%(i+2)==0) return false;
    }
    return true;
}
ll power(ll x,ll y)
{
	ll ans=1;
	while(y>0)
	{
		if(y&1) ans=ans*x;
		x=x*x;
		y=y>>1;
	}
	return ans;
}
int solve()
{
    int h,w,x,y,i,j,ans=0;
    cin>>h>>w>>x>>y;
    vector<string> v(h);
    for(i=0;i<h;i++)
    {
        cin>>v[i];
    }
    for(i=y-1;i<w;i++)
    {
        if(v[x-1][i]=='#') break;
        ans++;
    }
    for(i=y-2;i>=0;i--)
    {
        if(v[x-1][i]=='#') break;
        ans++;
    }
    for(i=x;i<h;i++)
    {
        if(v[i][y-1]=='#') break;
        ans++;
    }
    for(i=x-2;i>=0;i--)
    {
        if(v[i][y-1]=='#') break;
        ans++;
    }
    cout<<ans;
    return 0;
}
int main()
{
    fst;
    test1();
    return 0;
}

#include <bits/stdc++.h>
#define M 1000000007
#define pii 3.14159265359 
#define pb push_back
#define pob pop_back 
#define forr(i,n) for(i=0;i<n;i++)
#define fors(i,j,n) for(i=j;i<n;i++)
#define pi pair<int,int>
#define ff first
#define ss second
#define tcase 0
#define all(v) v.begin(),v.end()
typedef long long int ll;
using namespace std;
#define sc(n) scanf("%lld",&n)
#define scn(n) scanf("%d",&n)
#define prt(n) printf("%lld ",n)
#define prtln(n) printf("%lld\n",n)

vector<pi> edges;
vector<vector<int>> v;
vector<int> prt;
vector<ll> val;
vector<ll> ans;

void assign_prt(int node,int p) {
	prt[node] = p;
	for(auto x : v[node]) {
		if(x==prt[node]) continue;
		assign_prt(x,node);
	}
}	

void find_ans(int node,int p,ll c) {
	ans[node] += c + val[node];
	for(auto x : v[node]) {
		if(x==prt[node]) continue;
		find_ans(x,node,c+val[node]);
	}
}

void solve() {
    int n,i;
    scn(n);

    v.clear(); edges.clear(); prt.clear(); val.clear(); ans.clear();
    v.resize(n+1); prt.resize(n+1); val.resize(n+1,0ll);
    forr(i,n-1) {
    	int a,b;
    	scn(a); scn(b);
    	edges.pb({a,b});
    	v[a].pb(b); v[b].pb(a);
    }

    assign_prt(1,-1);

    int q;
    scn(q);

    forr(i,q) {
    	int a,b; ll value;
    	scn(a); scn(b); sc(value);

 		int v1,v2;
    	if(a==1) {
    		v1 = edges[b-1].ff;
    		v2 = edges[b-1].ss;
    	}
    	else {
    		v1 = edges[b-1].ss;
    		v2 = edges[b-1].ff;
    	}

    	if(v2==prt[v1]) {
    		val[v1] += value;
    	}
    	else {
    		val[1] += value;
    		val[v2] += -value;
    	}
    }

    ans.resize(n+1,0ll);
    find_ans(1,-1,0);

    fors(i,1,n+1) prtln(ans[i]);
}

int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    int t = 1; 
    if(tcase) scn(t); 
    while(t--) solve();
    return 0;
}
