#include<iostream>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include <cstdio>
#include<map>
#include<string>
#include<assert.h>
#include<unordered_map>
#include <cstring>//memset();
#define Amr_Abdelazim ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define pp pop_back
#define ll long long
#define ld long double
#define pll pair<ll,ll>
#define vll vector<ll>
#define vvll vector<vector<ll> >
#define vpll vector<pair<ll,ll> >
#define all(v) v.begin(),v.end()
#define rep(i,n)   for(int i=0;i<n;i++)
#define repp(s,i,n)   for(int i=s;i<n;i++)
#define print(v) for(auto i:v)cout<<i<<" ";cout<<"\n";
#define mkp make_pair
#define clr(ar,v) memset(ar,v,sizeof(ar));
#define TC ll t;cin>>t;while(t--)
#define in_vec ll n;cin>>n;vll v(n);rep(i,n)cin >> v[i];
#define EPS 1e-9
using namespace std;
const int mod = 1000000007;
const int N = 1000005;
class cmp{
public:
	bool operator() (pair<ll, pll> &A, pair<ll, pll> &B){
		return A > B;
	}
};
bool by_sec(pll &A, pll &B){
	return A.second < B.second;
}
bool is(pll a, pll b){
	return !((a.first > b.second&&a.second > b.second) || (a.first < b.first&&a.second < b.first));
}
ld dist(pll p1, pll p2){
	return (ld)sqrt((ld)(p1.first - p2.first)*(p1.first - p2.first) + (ld)(p1.second - p2.second)*(p1.second - p2.second));
}
ll dp[1000000 + 9],dp2[1000000+9];
int main()
{
	Amr_Abdelazim
		ll n, c;
	cin >> n >> c;
	bool rv = 0;
	vll v(n), b(n),sm(n);
	repp(1,i, n)cin >> v[i];
	repp(1, i, n)cin >> b[i],sm[i]=b[i]+sm[i-1];
	ll a = 0, f = 0;
	dp2[0] = c;
	repp(1,i, n){
		dp[i] = v[i] + min(dp[i - 1], dp2[i - 1]);
		dp2[i] = b[i] + min(dp[i - 1] + c, dp2[i - 1]);
	}
	repp(0, i, n)cout << min(dp[i],dp2[i]) << " ";
	return 0;
}


#include<iostream>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include <cstdio>
#include<map>
#include<string>
#include<assert.h>
#include<unordered_map>
#include <cstring>//memset();
#define Amr_Abdelazim ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define pp pop_back
#define ll long long
#define ld long double
#define pll pair<ll,ll>
#define vll vector<ll>
#define vvll vector<vector<ll> >
#define vpll vector<pair<ll,ll> >
#define all(v) v.begin(),v.end()
#define rep(i,n)   for(int i=0;i<n;i++)
#define repp(s,i,n)   for(int i=s;i<n;i++)
#define print(v) for(auto i:v)cout<<i<<" ";cout<<"\n";
#define mkp make_pair
#define clr(ar,v) memset(ar,v,sizeof(ar));
#define TC ll t;cin>>t;while(t--)
#define in_vec ll n;cin>>n;vll v(n);rep(i,n)cin >> v[i];
#define EPS 1e-9
using namespace std;
const int mod = 1000000007;
const int N = 1000005;
class cmp{
public:
	bool operator() (pair<ll, pll> &A, pair<ll, pll> &B){
		return A > B;
	}
};
bool by_sec(pll &A, pll &B){
	return A.second < B.second;
}
bool is(pll a, pll b){
	return !((a.first > b.second&&a.second > b.second) || (a.first < b.first&&a.second < b.first));
}
ld dist(pll p1, pll p2){
	return (ld)sqrt((ld)(p1.first - p2.first)*(p1.first - p2.first) + (ld)(p1.second - p2.second)*(p1.second - p2.second));
}
ll dp[1000000 + 9];
int main()
{
	Amr_Abdelazim
		ll n, c;
	cin >> n >> c;
	bool rv = 1;
	vll v(n), b(n),sm(n);
	repp(1,i, n)cin >> v[i];
	repp(1, i, n)cin >> b[i],sm[i]=b[i]+sm[i-1];
	repp(1,i, n){

		dp[i] = min(c + sm[i], min((rv?c:0) + b[i] + dp[i - 1], v[i] + dp[i - 1]));
		if (c + b[i] + dp[i - 1] < v[i] + dp[i - 1])rv = 0;
		else rv = 1;
	}
	repp(0, i, n)cout << dp[i] << " ";
	return 0;
}


#include <bits/stdc++.h>
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define rep(i,l,r) for(int i=l;i<r;i++)
#define bep(i,l,r) for(int i=l;i>=r;i--)
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define el '\n'
#define sz(s) s.size()
#define all(v) v.begin(),v.end()
#define mii map<int,int>
#define mr  make_pair
using namespace std;

int inf = 1e18;
const int N = 5e5+999;
int mod = 1e9+7;
//int powmod(int a,int b) {int res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}
int dp[N][2];
int arr[N],brr[N];
signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
       int n,c;
       cin>>n>>c;
       rep(i,1,n)
       cin>>arr[i];
       rep(i,1,n)
       cin>>brr[i];
       // 0 for stairs
       // 1 for elevator
       dp[0][0] = 0;
       dp[0][1] = c;
       for(int i=1;i<n;++i)
       {
           int xxx = min(dp[i-1][0],dp[i-1][1]);
           dp[i][0] =   arr[i] +  xxx ;
           if(xxx==dp[i-1][1]&&xxx!=dp[i-1][0])
            dp[i][1] = brr[i] + xxx;
           else
            dp[i][1] = brr[i] + xxx+c;
       }
       for(int i=0;i<n;++i)
        cout<<min(dp[i][0],dp[i][1])<<" ";

    }

    return 0;
    }


#include <bits/stdc++.h>
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define rep(i,l,r) for(int i=l;i<r;i++)
#define bep(i,l,r) for(int i=l;i>=r;i--)
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define el '\n'
#define sz(s) s.size()
#define all(v) v.begin(),v.end()
#define mii map<int,int>
#define mr  make_pair
using namespace std;

int inf = 1e18;
const int N = 5e5+999;
int mod = 1e9+7;
//int powmod(int a,int b) {int res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}
int dp[N][2];
int arr[N],brr[N];
signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
       int n,c;
       cin>>n>>c;
       rep(i,1,n)
       cin>>arr[i];
       rep(i,1,n)
       cin>>brr[i];
       // 0 for stairs
       // 1 for elevator
       dp[0][0] = 0;
       dp[0][1] = 0;
       for(int i=1;i<n;++i)
       {
           int xxx = min(dp[i-1][0],dp[i-1][1]);
           dp[i][0] =   arr[i] +  xxx ;
           if(xxx==dp[i-1][0])
           dp[i][1] =   c+brr[i] + xxx;
           else
            dp[i][1] =   brr[i] + xxx;
       }
       for(int i=0;i<n;++i)
        cout<<min(dp[i][0],dp[i][1])<<" ";

    }

    return 0;
    }


#include <bits/stdc++.h>
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define rep(i,l,r) for(int i=l;i<r;i++)
#define bep(i,l,r) for(int i=l;i>=r;i--)
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define el '\n'
#define sz(s) s.size()
#define all(v) v.begin(),v.end()
#define mii map<int,int>
#define mr  make_pair
using namespace std;

int inf = 1e18;
const int N = 5e5+999;
int mod = 1e9+7;
//int powmod(int a,int b) {int res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}
int dp[N][2];
int arr[N],brr[N];
signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
       int n,c;
       cin>>n>>c;
       rep(i,1,n)
       cin>>arr[i];
       rep(i,1,n)
       cin>>brr[i];
       // 0 for stairs
       // 1 for elevator
       dp[0][0] = 0;
       dp[0][1] = 0;
       for(int i=1;i<n;++i)
       {
           int xxx = min(dp[i-1][0],dp[i-1][1]);
           dp[i][0] =   arr[i] +  xxx ;
           if(dp[i-1][1]==dp[i-1][0])
            dp[i][1] = c+brr[i] + xxx;
           else if(xxx==dp[i-1][1])
            dp[i][1] = brr[i] + xxx;
           else
            dp[i][1] = c+brr[i] + xxx;
       }
       for(int i=0;i<n;++i)
        cout<<min(dp[i][0],dp[i][1])<<" ";

    }

    return 0;
    }


#include <bits/stdc++.h>
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define rep(i,l,r) for(int i=l;i<r;i++)
#define bep(i,l,r) for(int i=l;i>=r;i--)
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define el '\n'
#define sz(s) s.size()
#define all(v) v.begin(),v.end()
#define mii map<int,int>
#define mr  make_pair
using namespace std;

int inf = 1e18;
const int N = 5e5+999;
int mod = 1e9+7;
//int powmod(int a,int b) {int res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}
int dp[N][2];
int arr[N],brr[N];
signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
       int n,c;
       cin>>n>>c;
       rep(i,1,n)
       cin>>arr[i];
       rep(i,1,n)
       cin>>brr[i];
       // 0 for stairs
       // 1 for elevator
       dp[0][0] = 0;
       dp[0][1] = c;
       for(int i=1;i<n;++i)
       {
           int xxx = min(dp[i-1][0],dp[i-1][1]);
           dp[i][0] =   arr[i] +  xxx ;
           if(dp[i-1][1]==dp[i-1][0])
            dp[i][1] = brr[i] + xxx;
           else if(xxx==dp[i-1][1])
            dp[i][1] = brr[i] + xxx;
           else
            dp[i][1] = c+brr[i] + xxx;
       }
       for(int i=0;i<n;++i)
        cout<<min(dp[i][0],dp[i][1])<<" ";

    }

    return 0;
    }


#include <bits/stdc++.h>
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define rep(i,l,r) for(int i=l;i<r;i++)
#define bep(i,l,r) for(int i=l;i>=r;i--)
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define el '\n'
#define sz(s) s.size()
#define all(v) v.begin(),v.end()
#define mii map<int,int>
#define mr  make_pair
using namespace std;

int inf = 1e18;
const int N = 5e5+999;
int mod = 1e9+7;
//int powmod(int a,int b) {int res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}
int dp[N][2];
int arr[N],brr[N];
signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
       int n,c;
       cin>>n>>c;
       rep(i,1,n)
       cin>>arr[i];
       rep(i,1,n)
       cin>>brr[i];
       // 0 for stairs
       // 1 for elevator
       dp[0][0] = 0;
       dp[0][1] = inf;
       for(int i=1;i<n;++i)
       {

           dp[i][0] =   arr[i] +  min(dp[i-1][0],dp[i-1][1]) ;
           dp[i][1] = min(brr[i]+c+dp[i-1][0],brr[i]+dp[i-1][1]);
       }
       for(int i=0;i<n;++i)
        cout<<min(dp[i][0],dp[i][1])<<" ";

    }

    return 0;
    }


#include <bits/stdc++.h>
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define rep(i,l,r) for(int i=l;i<r;i++)
#define bep(i,l,r) for(int i=l;i>=r;i--)
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define el '\n'
#define sz(s) s.size()
#define all(v) v.begin(),v.end()
#define mii map<int,int>
#define mr  make_pair
using namespace std;

int inf = 1e18;
const int N = 5e5+999;
int mod = 1e9+7;
//int powmod(int a,int b) {int res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}
int dp[N][2];
int arr[N],brr[N];
signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
       int n,c;
       cin>>n>>c;
       rep(i,1,n)
       cin>>arr[i];
       rep(i,1,n)
       cin>>brr[i];
       // 0 for stairs
       // 1 for elevator
       dp[0][0] = 0;
       dp[0][1] = 0;
       for(int i=1;i<n;++i)
       {
           int xxx = min(dp[i-1][0],dp[i-1][1]);
           dp[i][0] =   arr[i] +  xxx ;
           if(dp[i-1][1]==dp[i-1][0])
            dp[i][1] = brr[i] + xxx;
           else if(xxx==dp[i-1][1])
            dp[i][1] = brr[i] + xxx;
           else
            dp[i][1] = c+brr[i] + xxx;
       }
       for(int i=0;i<n;++i)
        cout<<min(dp[i][0],dp[i][1])<<" ";

    }

    return 0;
    }


#include <bits/stdc++.h>
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define rep(i,l,r) for(int i=l;i<r;i++)
#define bep(i,l,r) for(int i=l;i>=r;i--)
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define el '\n'
#define sz(s) s.size()
#define all(v) v.begin(),v.end()
#define mii map<int,int>
#define mr  make_pair
using namespace std;

int inf = 1e18;
const int N = 5e5+999;
int mod = 1e9+7;
//int powmod(int a,int b) {int res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}
int dp[N][2];
int arr[N],brr[N];
signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
       int n,c;
       cin>>n>>c;
       rep(i,1,n)
       cin>>arr[i];
       rep(i,1,n)
       cin>>brr[i];
       // 0 for stairs
       // 1 for elevator
       dp[0][0] = 0;
       dp[0][1] = 0;
       for(int i=1;i<n;++i)
       {
           int xxx = min(dp[i-1][0],dp[i-1][1]);
           dp[i][0] =   arr[i] +  xxx ;
           if(xxx==dp[i-1][1]&&xxx!=dp[i-1][0])
            dp[i][1] = brr[i] + xxx;
           else
            dp[i][1] = brr[i] + xxx+c;
       }
       for(int i=0;i<n;++i)
        cout<<min(dp[i][0],dp[i][1])<<" ";

    }

    return 0;
    }


#include <bits/stdc++.h>
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define rep(i,l,r) for(int i=l;i<r;i++)
#define bep(i,l,r) for(int i=l;i>=r;i--)
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define el '\n'
#define sz(s) s.size()
#define all(v) v.begin(),v.end()
#define mii map<int,int>
#define mr  make_pair
using namespace std;

int inf = 1e18;
const int N = 5e5+999;
int mod = 1e9+7;
//int powmod(int a,int b) {int res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}
int dp[N][2];
int arr[N],brr[N];
signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
       int n,c;
       cin>>n>>c;
       rep(i,1,n)
       cin>>arr[i];
       rep(i,1,n)
       cin>>brr[i];
       // 0 for stairs
       // 1 for elevator
       dp[0][0] = 0;
       dp[0][1] = inf;
       for(int i=1;i<n;++i)
       {
           int xxx = min(dp[i-1][0],dp[i-1][1]);
           dp[i][0] =   arr[i] +  xxx ;
           if(dp[i-1][1]==dp[i-1][0])
            dp[i][1] = brr[i] + xxx;
           else if(xxx==dp[i-1][1])
            dp[i][1] = brr[i] + xxx;
           else
            dp[i][1] = c+brr[i] + xxx;
       }
       for(int i=0;i<n;++i)
        cout<<min(dp[i][0],dp[i][1])<<" ";

    }

    return 0;
    }


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
#define boost ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL)
int main()
{
int n,k;
cin>>n>>k;
int a[n+1],b[n+1],i,c[n+1];
for(i=1;i<n;i++)
{
    cin>>a[i];
}
for(i=1;i<n;i++)
{
    cin>>b[i];
}
c[0]=0;
int m=0;
for(i=1;i<n;i++)
{
    if(m==1 && a[i]>b[i])
    {
        c[i]=c[i-1]+b[i];
    }
    else if(m==1 && a[i]<b[i])
    {
        c[i]=c[i-1]+a[i];
        m=0;
    }
    else if(m==0 && a[i]>=b[i]+k)
    {
        c[i]=c[i-1]+b[i]+k;
        m=1;
    }
    else
    {
        c[i]=c[i-1]+a[i];
    }
}
for(i=0;i<n;i++)
{
    cout<<c[i]<<" ";
}

}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
#define boost ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL)
int main()
{
int n,k;
cin>>n>>k;
int a[n+1],b[n+1],i,c[n+1];
for(i=1;i<n;i++)
{
    cin>>a[i];
}
for(i=1;i<n;i++)
{
    cin>>b[i];
}
c[0]=0;
for(i=1;i<n;i++)
{
c[i]=c[i-1]+min(a[i],b[i]+k);
}
for(i=0;i<n;i++)
{
    cout<<c[i]<<" ";
}

}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
#define boost ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL)
int main()
{
int n,k;
cin>>n>>k;
int a[n+1],b[n+1],i,c[n+1];
for(i=1;i<n;i++)
{
    cin>>a[i];
}
for(i=1;i<n;i++)
{
    cin>>b[i];
}
c[0]=0;
int m=0;
for(i=1;i<n;i++)
{
    if(m==1 && a[i]>=b[i])
    {
        c[i]=c[i-1]+b[i];
    }
    else if(m==1 && a[i]<b[i])
    {
        c[i]=c[i-1]+a[i];
        m=0;
    }
    else if(m==0 && a[i]>=b[i]+k)
    {
        c[i]=c[i-1]+b[i]+k;
        m=1;
    }
    else
    {
        c[i]=c[i-1]+a[i];
    }
}
for(i=0;i<n;i++)
{
    cout<<c[i]<<" ";
}

}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
#define boost ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL)
int main()
{
int n,k;
cin>>n>>k;
int a[n+1],b[n+1],i,c[n+1];
for(i=1;i<n;i++)
{
    cin>>a[i];
}
for(i=1;i<n;i++)
{
    cin>>b[i];
}
c[0]=0;
int m=0;
for(i=1;i<n;i++)
{
    if(m==1 && a[i]>b[i])
    {
        c[i]=c[i-1]+b[i];
    }
    else if(m==1 && a[i]<b[i])
    {
        c[i]=c[i-1]+a[i];
        m=0;
    }
    else if(m==0 && a[i]>b[i]+k)
    {
        c[i]=c[i-1]+b[i]+k;
        m=1;
    }
    else
    {
        c[i]=c[i-1]+a[i];
    }
}
for(i=0;i<n;i++)
{
    cout<<c[i]<<" ";
}

}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
#define boost ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL)
int main()
{
int n,k;
cin>>n>>k;
int a[n+1],b[n+1],i,c[n+1];
for(i=1;i<n;i++)
{
    cin>>a[i];
}
for(i=1;i<n;i++)
{
    cin>>b[i];
}
c[0]=0;
int m=0;
for(i=1;i<n;i++)
{
    if(m==1 && a[i]>=b[i])
    {
        c[i]=c[i-1]+b[i];
    }
    else if(m==1 && a[i]<b[i])
    {
        c[i]=c[i-1]+a[i];
        m=0;
    }
    else if(m==0 && a[i]>b[i]+k)
    {
        c[i]=c[i-1]+b[i]+k;
        m=1;
    }
    else
    {
        c[i]=c[i-1]+a[i];
    }
}
for(i=0;i<n;i++)
{
    cout<<c[i]<<" ";
}

}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
#define boost ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL)
int main()
{
int n,k;
cin>>n>>k;
int a[n+1],b[n+1],i,c[n+1],dp1[n+1]={},dp2[n+1]={};
for(i=0;i<n-1;i++)cin>>a[i];
for(i=0;i<n-1;i++)cin>>b[i];
c[0]=0;
dp1[0]=0;
dp2[0]=k;
for(i=1;i<n;i++)
{
dp1[i]=min(dp1[i-1],dp2[i-1])+a[i-1];
dp2[i]=min(dp1[i-1]+k+b[i-1],dp2[i-1]+b[i-1]);
c[i]=min(dp1[i],dp2[i]);
}
for(i=0;i<n;i++)
{
    cout<<c[i]<<" ";
}

}


#include <bits/stdc++.h>

using namespace std;

const int N = 2e5 + 5;
const int INF = 1e9;

int n;
int c;
int a[N];
int b[N];

int dp[N][2]; // minimum time required to get from the bottom floor to the i_th floor

main(){

    scanf("%d %d" , &n , &c);

    for(int i = 1 ; i < n ; i ++){
            scanf("%d" , &a[i]);
    }

    for(int i = 1 ; i < n ; i ++){
            scanf("%d" , &b[i]);
    }

    for(int i = 1 ; i <= n ; i ++){
            dp[i][0] = dp[i][1] = INF;
    }
    dp[0][1] = INF; // we can't be in elevator initially

    for(int i = 1 ; i <= n ; i ++){

            dp[i][0] = a[i-1] + min(dp[i-1][0] , dp[i-1][1]);
            dp[i][1] = b[i-1] + min(c + dp[i-1][0] , dp[i-1][1]);

            printf("%d%c" , min(dp[i][0] , dp[i][1]) , i == n ? '\n' : ' ');
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 2e5 + 5;
const int INF = 1e9;

int n;
int c;
int a[N];

int dp[2][2]; // minimum time required to get from the bottom floor to the i_th floor

main(){

    scanf("%d %d" , &n , &c);

    for(int i = 1 ; i < n ; i ++){
            scanf("%d" , &a[i]);
    }

    dp[0][1] = INF; // we can't be in elevator initially

    // we go from previous floor to this floor, (i - 1) -> (i)
    for(int i = 1 ; i < n ; i ++){
            int b; scanf("%d" , &b);

            dp[i&1][0] = a[i-1] + min(    dp[!(i&1)][0] , dp[!(i&1)][1]);
            dp[i&1][1] = b      + min(c + dp[!(i&1)][0] , dp[!(i&1)][1]);

            printf("%d%c" , min(dp[i&1][0] , dp[i&1][1]) , i == n ? '\n' : ' ');
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 2e5 + 5;
const int INF = 1e9;

int n;
int c;
int a[N];

main(){

    scanf("%d %d" , &n , &c);

    for(int i = 1 ; i < n ; i ++){
            scanf("%d" , &a[i]);
    }

    int curr_without_elevator = 0  ;
    int curr_with_elevator    = INF;

    for(int i = 1 ; i <= n ; i ++){
            int b = 0;

            if(i < n) scanf("%d" , &b);

            int next_without_elevator = a[i] + min(    curr_without_elevator , curr_with_elevator);
            int next_with_elevator    = b    + min(c + curr_without_elevator , curr_with_elevator);

            printf("%d%c" , min(curr_without_elevator , curr_with_elevator) , i == n ? '\n' : ' ');

            // pass values for the next iteration
            curr_without_elevator = next_without_elevator;
            curr_with_elevator    = next_with_elevator;
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 2e5 + 5;

int n;
int c;
int a[N];
int b[N];

int mem[N][2]; // dp[i][elv]: minimum time required to go from the i_th floor to the bottom floor
// elv is to know that we are currently in the elevator or not

int dp(int i , bool elv){

    if(i == 1) return 0;

    if(mem[i][elv] != -1) return mem[i][elv];

    // go by stairs from last position to this position: (i-1) -> (i);
    int ans = a[i-1] + dp(i - 1 , 0);

    // try taking elevator
    if(elv){ // we are already in the elevator so no need to pay c time
            ans = min(ans , b[i-1] + dp(i - 1 , 1));
    }
    else { // we need to wait for the elevator and that costs c time
            ans = min(ans , c + b[i-1] + dp(i - 1 , 1));
    }

    return mem[i][elv] = ans;
}

main(){

    scanf("%d %d" , &n , &c);

    for(int i = 1 ; i < n ; i ++){
            scanf("%d" , &a[i]);
    }

    for(int i = 1 ; i < n ; i ++){
            scanf("%d" , &b[i]);
    }

    memset(mem , -1 , sizeof mem);

    // dp from each floor to the beginning
    for(int i = 1 ; i <= n ; i ++){
            printf("%d%c" , dp(i , 0) , i == n ? '\n' : ' ');
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 2e5 + 5;
const int INF = 1e9;

int n;
int c;
int a[N];
int b[N];

int dp[2][2]; // minimum time required to get from the bottom floor to the i_th floor

main(){

    scanf("%d %d" , &n , &c);

    for(int i = 1 ; i < n ; i ++){
            scanf("%d" , &a[i]);
    }

    for(int i = 1 ; i < n ; i ++){
            scanf("%d" , &b[i]);
    }

    for(int i = 1 ; i <= n ; i ++){
            dp[i][0] = dp[i][1] = INF;
    }
    dp[0][1] = INF; // we can't be in elevator initially

    // we go from previous floor to this floor, (i - 1) -> (i)
    for(int i = 1 ; i <= n ; i ++){

            dp[i&1][0] = a[i-1] + min(    dp[!(i&1)][0] , dp[!(i&1)][1]);
            dp[i&1][1] = b[i-1] + min(c + dp[!(i&1)][0] , dp[!(i&1)][1]);

            printf("%d%c" , min(dp[i&1][0] , dp[i&1][1]) , i == n ? '\n' : ' ');
    }

    return 0;
}


#include<bits/stdc++.h>

using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vli  = vector < li        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;

const int N = 2e5 + 5;
const ll INF = 1e17 + 7;
const double eps = 1e-9 , PI = acos(-1);

int n;
ll c;
ll a[N];
ll b[N];

ll mem[N][3];

ll dp(int i , int elv){

    if(i == 1) return 0;

    ll &ret = mem[i][elv];

    if(ret != -1) return ret;

    ret = a[i-1] + dp(i - 1 , 0);
    if(elv){
            ret = min(ret , b[i-1] + dp(i - 1 , 1));
    }
    else {
            ret = min(ret , c + b[i-1] + dp(i - 1 , 1));
    }

    return ret;
}

void solve(int testCase){

    scanf("%d %lld" , &n , &c);

    for(int i = 1 ; i < n ; i ++){
            scanf("%lld" , &a[i]);
    }

    for(int i = 1 ; i < n ; i ++){
            scanf("%lld" , &b[i]);
    }

    memset(mem , -1 , sizeof mem);
    for(int i = 1 ; i <= n ; i ++){
            printf("%lld%c" , dp(i , 0) , i == n ? '\n' : ' ');
    }

}

main(){

    int t = 1;
    // scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 2e5 + 5;
const int INF = 1e9;

int n;
int c;
int a[N];
int b[N];

int dp[2][2]; // minimum time required to get from the bottom floor to the i_th floor

main(){

    scanf("%d %d" , &n , &c);

    for(int i = 1 ; i < n ; i ++){
            scanf("%d" , &a[i]);
    }

    for(int i = 1 ; i < n ; i ++){
            scanf("%d" , &b[i]);
    }

    dp[0][1] = INF; // we can't be in elevator initially

    // we go from previous floor to this floor, (i - 1) -> (i)
    for(int i = 1 ; i <= n ; i ++){

            dp[i&1][0] = a[i-1] + min(    dp[!(i&1)][0] , dp[!(i&1)][1]);
            dp[i&1][1] = b[i-1] + min(c + dp[!(i&1)][0] , dp[!(i&1)][1]);

            printf("%d%c" , min(dp[i&1][0] , dp[i&1][1]) , i == n ? '\n' : ' ');
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 2e5 + 5;
const int INF = 1e9;

int n;
int c;
int a[N];

int dp[2][2]; // minimum time required to get from the bottom floor to the i_th floor

main(){

    scanf("%d %d" , &n , &c);

    for(int i = 1 ; i < n ; i ++){
            scanf("%d" , &a[i]);
    }

    dp[1][1] = INF; // we can't be in elevator initially

    // we go from previous floor to this floor, (i - 1) -> (i)
    for(int i = 1 ; i <= n ; i ++){
            int b = 0;

            if(i < n)scanf("%d" , &b);

            dp[!(i&1)][0] = a[i] + min(    dp[i&1][0] , dp[i&1][1]);
            dp[!(i&1)][1] = b    + min(c + dp[i&1][0] , dp[i&1][1]);

            printf("%d%c" , min(dp[i&1][0] , dp[i&1][1]) , i == n ? '\n' : ' ');
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int INF = 1e9;

main(){

    int n , c;
    scanf("%d %d" , &n , &c);

    vector < int > a(n + 1 , 0);

    for(int i = 1 ; i < n ; i ++){
            scanf("%d" , &a[i]);
    }

    int curr_without_elevator = 0  ;
    int curr_with_elevator    = INF;

    for(int i = 1 ; i <= n ; i ++){
            int b = 0;

            if(i < n) scanf("%d" , &b);

            int next_without_elevator = a[i] + min(    curr_without_elevator , curr_with_elevator);
            int next_with_elevator    = b    + min(c + curr_without_elevator , curr_with_elevator);

            printf("%d%c" , min(curr_without_elevator , curr_with_elevator) , i == n ? '\n' : ' ');

            // pass values for the next iteration
            curr_without_elevator = next_without_elevator;
            curr_with_elevator    = next_with_elevator;
    }

    return 0;
}


#include <bits/stdc++.h>
#define s second
#define f first
#define endl '\n'
using namespace std;

void solve () {
	int n, c; cin >> n >> c;
	vector<int> a(n - 1), b(n - 1);
	vector<pair<int, bool>> dp(n, {0, 0});
	for(int i = 0; i < n - 1; ++i) cin >> a[i];
	for(int i = 0; i < n - 1; ++i) cin >> b[i];
	for(int i = 0; i < n - 1; ++i) {
		int t; bool e = false;
		if(dp[i].s && b[i] <= a[i]) {
			t = b[i];
			e = true;
		} else if(!dp[i].s && b[i] + c <= a[i]) {
			t = b[i] + c;
			e = true;
		} else {
			t = a[i];
			e = false;
		}
		dp[i + 1] = {dp[i].f + t, e};
	} for(int i = 0; i < n; ++i) {
		cout << dp[i].f << ' ';
	} cout << endl;
}

int main() {
	solve();
}


#include <bits/stdc++.h>
#define s second
#define f first
#define endl '\n'
using namespace std;

void solve () {
	int n, c; cin >> n >> c;
	vector<int> a(n - 1), b(n - 1);
	vector<pair<int, bool>> dp(n, {0, 0});
	for(int i = 0; i < n - 1; ++i) cin >> a[i];
	for(int i = 0; i < n - 1; ++i) cin >> b[i];
	for(int i = 0; i < n - 1; ++i) {
		int t = a[i];
		bool e = false;
		if(!dp[i].s && b[i] + c < t) {
			t = b[i] + c;
			e = true;
		} else if(dp[i].s && b[i] < t) {
			t = b[i];
			e = true;
		}
		dp[i + 1] = {dp[i].f + t, e};
	} for(int i = 0; i < n; ++i) {
		cout << dp[i].f << ' ';
	} cout << endl;
}

int main() {
	solve();
}


#include <bits/stdc++.h>
#define s second
#define f first
#define endl '\n'
using namespace std;

void solve () {
	int n, c; cin >> n >> c;
	vector<int> a(n - 1), b(n - 1);
	vector<vector<int>> dp(n, vector<int> (2, 0));
	for(int i = 0; i < n - 1; ++i) cin >> a[i];
	for(int i = 0; i < n - 1; ++i) cin >> b[i];
	for(int i = 0; i < n - 1; ++i) {
		dp[i+1][1] = min(dp[i][0]+b[i]+c, dp[i][1]+b[i]);
		dp[i+1][0] = min(dp[i][1]+a[i], dp[i][0]+a[i]);
	} for(int i = 0; i < n; ++i) {
		cout << (i == 0 ? min(dp[i][0], dp[i][1]) : min(dp[i][0], dp[i][1]) + 1)  << ' ';
	} cout << endl;
}

int main() {
	solve();
}


#include <bits/stdc++.h>
#define s second
#define f first
#define endl '\n'
using namespace std;

void solve () {
	int n, c; cin >> n >> c;
	vector<int> a(n - 1), b(n - 1);
	vector<pair<int, bool>> dp(n, {0, 0});
	for(int i = 0; i < n - 1; ++i) cin >> a[i];
	for(int i = 0; i < n - 1; ++i) cin >> b[i];
	for(int i = 0; i < n - 1; ++i) {
		int t; bool e = false;
		if(dp[i].s && b[i] < t) {
			t = b[i];
			e = true;
		} else if(!dp[i].s && b[i] + c < a[i]) {
			t = b[i] + c;
			e = true;
		} else {
			t = a[i];
			e = false;
		}
		dp[i + 1] = {dp[i].f + t, e};
	} for(int i = 0; i < n; ++i) {
		cout << dp[i].f << ' ';
	} cout << endl;
}

int main() {
	solve();
}


#include <functional>
#include <algorithm>
#include <iostream>
#include <memory.h>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstdio>
#include <complex>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <set>
#include <map>
using namespace std;

#define int64 long long
#define mp make_pair

const int inf = 1e9;

#ifdef _DEBUG
    const int N = 10010;
#else
    const int N = 100010;
#endif

int n, m, t[N], t1[N], lt[N], rt[N], tcur, treeRes[4 * N], treeUpd[4 * N], treeSum[4 * N], a[N], b[N], ans[N];
vector <int> g[N], qstart[N], qend[N];
pair <int, int> q[N];

void dfs(int v, int p)
{
    tcur++;
    t[v] = tcur;
    t1[tcur] = v;
    lt[tcur] = tcur;
    rt[tcur] = tcur;
    for (int i = 0; i < g[v].size(); i++)
        if (g[v][i] != p)
        {
            dfs(g[v][i], v);
            rt[t[v]] = rt[t[g[v][i]]];
        }
}

void push(int v, int tl, int tr)
{
    int tm = (tl + tr) / 2;
    if (treeUpd[v] != 0)
    {
        treeSum[v * 2] += treeUpd[v];
        treeSum[v * 2 + 1] += treeUpd[v];
        treeUpd[v * 2] += treeUpd[v];
        treeUpd[v * 2 + 1] += treeUpd[v];
        if (treeSum[v * 2] > 0) treeRes[v * 2] = tm - tl + 1;
        else treeRes[v * 2] = 0;
        if (treeSum[v * 2 + 1] > 0) treeRes[v * 2 + 1] = tr - tm;
        else treeRes[v * 2 + 1] = 0;
        treeUpd[v] = 0;
    }
}

void update(int v, int tl, int tr, int l, int r, int val)
{
    if (l > r) return;
    if (l == tl && r == tr)
    {
        treeSum[v] += val;
        treeUpd[v] += val;
        if (treeSum[v] > 0) treeRes[v] = tr - tl + 1;
        else treeRes[v] = 0;
        return;
    }
    int tm = (tl + tr) / 2;
    push(v, tl, tr);
    update(v * 2, tl, tm, l, min(r, tm), val);
    update(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r, val);
    if (treeSum[v] > 0) treeRes[v] = tr - tl + 1;
    else treeRes[v] = treeRes[v * 2] + treeRes[v * 2 + 1];
}

int getRes(int v, int tl, int tr, int l, int r)
{
    if (l > r) return 0;
    if (l == tl && r == tr) return treeRes[v];
    int tm = (tl + tr) / 2;
    push(v, tl, tr);
    return getRes(v * 2, tl, tm, l, min(r, tm)) + getRes(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r);
}

int main()
{
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    scanf("%d%d", &n, &m);
    for (int i = 1; i < n; i++)
    {
        int u, v;
        scanf("%d%d", &u, &v);
        g[u].push_back(v);
        g[v].push_back(u);
    }
    tcur = 0;
    dfs(1, -1);
    for (int i = 1; i <= m; i++) scanf("%d%d", &a[i], &b[i]);
    for (int i = 1; i <= m; i++)
    {
        int l = lt[t[a[i]]], r = rt[t[a[i]]];
        qstart[l].push_back(i);
        qend[r].push_back(i);
    }
    for (int i = 1; i <= m; i++)
    {
        int l = lt[t[b[i]]], r = rt[t[b[i]]];
        qstart[l].push_back(i);
        qend[r].push_back(i);
    }
    for (int i = 1; i <= m; i++) qstart[q[i].first].push_back(i);
    for (int i = 1; i <= m; i++) qend[q[i].second].push_back(i);
    for (int i = 1; i <= n; i++)
    {
        for (int j = 0; j < qstart[i].size(); j++)
        {
            int k = qstart[i][j];
            update(1, 1, n, lt[t[a[k]]], rt[t[a[k]]], 1);
            update(1, 1, n, lt[t[b[k]]], rt[t[b[k]]], 1);
        }
        ans[t1[i]] = getRes(1, 1, n, 1, n) - getRes(1, 1, n, i, i);
        for (int j = 0; j < qend[i].size(); j++)
        {
            int k = qend[i][j];
            update(1, 1, n, lt[t[a[k]]], rt[t[a[k]]], -1);
            update(1, 1, n, lt[t[b[k]]], rt[t[b[k]]], -1);
        }
    }
    for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
    return 0;
}


#include <functional>
#include <algorithm>
#include <iostream>
#include <memory.h>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstdio>
#include <complex>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <set>
#include <map>
using namespace std;

#define int64 long long
#define mp make_pair

const int inf = 1e9;

#ifdef _DEBUG
    const int N = 10010;
#else
    const int N = 100010;
#endif

int n, m, t[N], t1[N], lt[N], rt[N], tcur, treeRes[4 * N], treeUpd[4 * N], treeSum[4 * N], a[N], b[N], ans[N];
vector <int> g[N], qstart[N], qend[N];
pair <int, int> q[N];

void dfs(int v, int p)
{
    tcur++;
    t[v] = tcur;
    t1[tcur] = v;
    lt[tcur] = tcur;
    rt[tcur] = tcur;
    for (int i = 0; i < g[v].size(); i++)
        if (g[v][i] != p)
        {
            dfs(g[v][i], v);
            rt[t[v]] = rt[t[g[v][i]]];
        }
}

void push(int v, int tl, int tr)
{
    int tm = (tl + tr) / 2;
    if (treeUpd[v] != 0)
    {
        treeSum[v * 2] += treeUpd[v];
        treeSum[v * 2 + 1] += treeUpd[v];
        treeUpd[v * 2] += treeUpd[v];
        treeUpd[v * 2 + 1] += treeUpd[v];
        if (treeSum[v * 2] > 0) treeRes[v * 2] = tm - tl + 1;
        else treeRes[v * 2] = 0;
        if (treeSum[v * 2 + 1] > 0) treeRes[v * 2 + 1] = tr - tm;
        else treeRes[v * 2 + 1] = 0;
        treeUpd[v] = 0;
    }
}

void update(int v, int tl, int tr, int l, int r, int val)
{
    if (l > r) return;
    if (l == tl && r == tr)
    {
        treeSum[v] += val;
        treeUpd[v] += val;
        if (treeSum[v] > 0) treeRes[v] = tr - tl + 1;
        else treeRes[v] = 0;
        return;
    }
    int tm = (tl + tr) / 2;
    push(v, tl, tr);
    update(v * 2, tl, tm, l, min(r, tm), val);
    update(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r, val);
    if (treeSum[v] > 0) treeRes[v] = tr - tl + 1;
    else treeRes[v] = treeRes[v * 2] + treeRes[v * 2 + 1];
}

int getRes()
{
    return treeRes[1];
}

int main()
{
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    scanf("%d%d", &n, &m);
    for (int i = 1; i < n; i++)
    {
        int u, v;
        scanf("%d%d", &u, &v);
        g[u].push_back(v);
        g[v].push_back(u);
    }
    tcur = 0;
    dfs(1, -1);
    for (int i = 1; i <= m; i++) scanf("%d%d", &a[i], &b[i]);
    for (int i = 1; i <= m; i++)
    {
        int l = lt[t[a[i]]], r = rt[t[a[i]]];
        qstart[l].push_back(i);
        qend[r].push_back(i);
    }
    for (int i = 1; i <= m; i++)
    {
        int l = lt[t[b[i]]], r = rt[t[b[i]]];
        qstart[l].push_back(i);
        qend[r].push_back(i);
    }
    for (int i = 1; i <= m; i++) qstart[q[i].first].push_back(i);
    for (int i = 1; i <= m; i++) qend[q[i].second].push_back(i);
    for (int i = 1; i <= n; i++)
    {
        for (int j = 0; j < qstart[i].size(); j++)
        {
            int k = qstart[i][j];
            update(1, 1, n, lt[t[a[k]]], rt[t[a[k]]], 1);
            update(1, 1, n, lt[t[b[k]]], rt[t[b[k]]], 1);
        }
        ans[t1[i]] = max(0, getRes() - 1);
        for (int j = 0; j < qend[i].size(); j++)
        {
            int k = qend[i][j];
            update(1, 1, n, lt[t[a[k]]], rt[t[a[k]]], -1);
            update(1, 1, n, lt[t[b[k]]], rt[t[b[k]]], -1);
        }
    }
    for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
    return 0;
}


#include <functional>
#include <algorithm>
#include <iostream>
#include <memory.h>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstdio>
#include <complex>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <set>
#include <map>
using namespace std;

#define int64 long long
#define mp make_pair

const int inf = 1e9;

#ifdef _DEBUG
    const int N = 1010;
#else
    const int N = 100010;
#endif

int n, m, t[N], t1[N], lt[N], rt[N], tcur, treeRes[4 * N], treeUpd[4 * N], treeSum[4 * N], a[N], b[N], ans[N];
vector <int> g[N], qstart[N], qend[N];
pair <int, int> q[N];

void dfs(int v, int p)
{
    tcur++;
    t[v] = tcur;
    t1[tcur] = v;
    lt[tcur] = tcur;
    rt[tcur] = tcur;
    for (int i = 0; i < g[v].size(); i++)
        if (g[v][i] != p)
        {
            dfs(g[v][i], v);
            rt[t[v]] = rt[t[g[v][i]]];
        }
}

void push(int v, int tl, int tr)
{
    int tm = (tl + tr) / 2;
    if (treeUpd[v] != 0)
    {
        treeSum[v * 2] += treeUpd[v];
        treeSum[v * 2 + 1] += treeUpd[v];
        treeUpd[v * 2] += treeUpd[v];
        treeUpd[v * 2 + 1] += treeUpd[v];
        if (treeSum[v * 2] > 0) treeRes[v * 2] = tm - tl + 1;
        else treeRes[v * 2] = 0;
        if (treeSum[v * 2 + 1] > 0) treeRes[v * 2 + 1] = tr - tm;
        else treeRes[v * 2 + 1] = 0;
        treeUpd[v] = 0;
    }
}

void update(int v, int tl, int tr, int l, int r, int val)
{
    if (l > r) return;
    if (l == tl && r == tr)
    {
        treeSum[v] += val;
        treeUpd[v] += val;
        if (treeSum[v] > 0) treeRes[v] = tr - tl + 1;
        else treeRes[v] = 0;
        return;
    }
    int tm = (tl + tr) / 2;
    push(v, tl, tr);
    update(v * 2, tl, tm, l, min(r, tm), val);
    update(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r, val);
    treeRes[v] = treeRes[v * 2] + treeRes[v * 2 + 1];
}

int getRes()
{
    return treeRes[1];
}

int main()
{
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    scanf("%d%d", &n, &m);
    for (int i = 1; i < n; i++)
    {
        int u, v;
        scanf("%d%d", &u, &v);
        g[u].push_back(v);
        g[v].push_back(u);
    }
    tcur = 0;
    dfs(1, -1);
    for (int i = 1; i <= m; i++) scanf("%d%d", &a[i], &b[i]);
    for (int i = 1; i <= m; i++)
    {
        int l = lt[t[a[i]]], r = rt[t[a[i]]];
        qstart[l].push_back(i);
        qend[r].push_back(i);
    }
    for (int i = 1; i <= m; i++)
    {
        int l = lt[t[b[i]]], r = rt[t[b[i]]];
        qstart[l].push_back(i);
        qend[r].push_back(i);
    }
    for (int i = 1; i <= m; i++) qstart[q[i].first].push_back(i);
    for (int i = 1; i <= m; i++) qend[q[i].second].push_back(i);
    for (int i = 1; i <= n; i++)
    {
        for (int j = 0; j < qstart[i].size(); j++)
        {
            int k = qstart[i][j];
            update(1, 1, n, lt[t[a[k]]], rt[t[a[k]]], 1);
            update(1, 1, n, lt[t[b[k]]], rt[t[b[k]]], 1);
        }
        ans[t1[i]] = max(0, getRes() - 1);
        for (int j = 0; j < qend[i].size(); j++)
        {
            int k = qend[i][j];
            update(1, 1, n, lt[t[a[k]]], rt[t[a[k]]], -1);
            update(1, 1, n, lt[t[b[k]]], rt[t[b[k]]], -1);
        }
    }
    for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
    return 0;
}


#define _CRT_SECURE_NO_DEPRECATE
#define _SECURE_SCL 0

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#include <iostream>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <cctype>
#include <sstream>
#include <cassert>
#include <bitset>
#include <memory.h>
#include <complex>

using namespace std;

#pragma comment(linker, "/STACK:200000000")

typedef long long int64;

#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define fore(i, a, n) for(int i = (int)(a); i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define last(a) (int(a.size()) - 1)
#define all(a) a.begin(), a.end()

const double EPS = 1E-9;
const int INF = 1000000000;
const int64 INF64 = (int64) 1E18;
const double PI = 3.1415926535897932384626433832795;

const int NMAX = 810000;

struct event {
  int vert, tl, tr, type;
};

int md[NMAX], a[NMAX], in[NMAX], out[NMAX], tt, h[NMAX], ans[NMAX];
vector<int> g[NMAX];
event e[NMAX];

void dfs(int v, int pr, int hh) {
  if (pr != -1)
    g[v].erase(find(all(g[v]), pr));

  h[v] = hh;
  in[v] = tt;
  a[tt++] = v;

  forn(i, g[v].size())
    dfs(g[v][i], v, hh + 1);

  out[v] = tt;
  a[tt++] = v;
}

set<pair<int, int> > s;
int len = 0;
vector<int> q[NMAX];

void dfs2(int v) {
  vector<pair<int, int> > ba, to_del;
  int old_len = len;
  forn(i, q[v].size()) {
    int l = in[q[v][i]];
    int r = out[q[v][i]];
    set<pair<int, int> >::iterator it = s.lower_bound(mp(l, r)), pr;
    if (it != s.end() && *it == mp(l, r))
      continue;

    pr = it;
    if (pr != s.begin()) {
      pr--;
      if (l <= pr->sc)
        continue;
    }

    len += r - l + 1;
    while (it != s.end() && it->fs <= r) {
      len -= it->sc - it->fs + 1;
      ba.pb(*it);
      it = s.erase(it);
    }

    s.insert(it, mp(l, r));
    to_del.pb(mp(l, r));
  }

  ans[v] = len / 2;

  forn(i, g[v].size())
    dfs2(g[v][i]);

  len = old_len;
  s.insert(all(ba));
  forn(i, to_del.size())
    s.erase(to_del[i]);
}

bool is_anc(int v1, int v2) {
  return in[v1] <= in[v2] && out[v2] <= out[v1];
}

bool cmp_h(int v1, int v2) {
  return h[v1] < h[v2];
}

int main() {
#ifdef RADs_project
  freopen("input.txt", "rt", stdin);
  freopen("output.txt", "wt", stdout);
#endif

  int n, m;
  cin >> n >> m;
  forn(i, n - 1) {
    int v1, v2;
    scanf("%d%d", &v1, &v2);
    v1--;
    v2--;

    g[v1].pb(v2);
    g[v2].pb(v1);
  }

  dfs(0, -1, 0);

  int ne = 0;
  forn(i, m) {
    int v1, v2;
    scanf("%d%d", &v1, &v2);
    v1--;
    v2--;

    if (is_anc(v1, v2))
      q[v1].pb(v1);
    else
    if (is_anc(v2, v1))
      q[v2].pb(v2);
    else {
      q[v1].pb(v1);
      q[v1].pb(v2);
      q[v2].pb(v1);
      q[v2].pb(v2);
    }
  }

  forn(i, n) {
    sort(all(q[i]));
    q[i].erase(unique(all(q[i])), q[i].end());
    sort(all(q[i]), cmp_h);
  }

  dfs2(0);

  forn(i, n)
    printf("%d ", max(ans[i] - 1, 0));

  return 0;
}


#pragma comment(linker,"/STACK:256000000")
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cstdlib>
#include <cstring>
#include <memory.h>
using namespace std;
#define sz(v) ((int)(v).size())
#define forn(i,n) for(int i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define pb push_back
#define mp make_pair
#define istr stringstream
#define fi first
#define se second
#define X first
#define Y second
#define clr(a,v) memset((a),(v),sizeof(a))
#define y0 asdy0
#define y1 asdy1
#define j0 asdj0
#define j1 asdj1
#define next asdnext
#define prev asdprev
#define link asdlink
#define unlink asdunlink
#define left asdleft
#define right asdright
#define hash asdhash
#define div asddiv
#define all(v) (v).begin(),(v).end()
typedef long long lng;
typedef unsigned int uint;
typedef unsigned long long ulng;
typedef unsigned char uchar;
typedef double ld;
typedef pair<int,int> PII;
typedef pair<ld,ld> PDD;
typedef pair<lng,lng> PLL;
typedef complex<double> com;
const ld PI=3.1415926535897932384626433832795;
const ld EPS=1e-12;
const int inf=1000000000;
const lng linf=1000000000000000000LL;
template<class T> inline T sqr(T x) { return x * x; }
int gcd(int a,int b){return a?gcd(b%a,a):b;}

PII tree[2100000];
int delta[2100000];

void pre(int k){
	if(!delta[k])
		return;
	tree[k].X+=delta[k];
	delta[k*2+1]+=delta[k];
	delta[k*2+2]+=delta[k];
	delta[k]=0;
}

PII add(PII a,PII b){
	if(a.X==b.X)
		return mp(a.X,a.Y+b.Y);
	return min(a,b);
}

void post(int k){
	pre(k);
	pre(k*2+1);
	pre(k*2+2);
	tree[k]=add(tree[k*2+1],tree[k*2+2]);
}

void init(int a,int b,int k){
	if(b==a+1){
		tree[k]=mp(0,1);
		return;
	}
	int c=(a+b)/2;
	init(a,c,k*2+1);
	init(c,b,k*2+2);
	post(k);
}

void inc(int l,int r,int v,int a,int b,int k){
	pre(k);
	if(l<=a&&r>=b){
		delta[k]+=v;
		pre(k);
		return;
	}
	if(l>=b||r<=a)
		return;
	int c=(a+b)/2;
	inc(l,r,v,a,c,k*2+1);
	inc(l,r,v,c,b,k*2+2);
	post(k);
}

vector<int> gr[110000];
vector<int> bs[110000];
int pos1[110000];
int pos2[110000];
int cnt;
int n;
int res[110000];

void dfs1(int v,int pr){
	pos1[v]=cnt++;
	forv(i,gr[v]){
		int p=gr[v][i];
		if(p==pr)
			continue;
		dfs1(p,v);
	}
	pos2[v]=cnt;
}

void dfs2(int v,int pr){
	forv(i,bs[v]){
		int p=bs[v][i];
		inc(pos1[v],pos2[v],1,0,n,0);
		inc(pos1[p],pos2[p],1,0,n,0);
	}
	PII t=tree[0];
	res[v]=n;
	if(!t.X)
		res[v]-=t.Y;
	forv(i,gr[v]){
		int p=gr[v][i];
		if(p==pr)
			continue;
		dfs2(p,v);
	}
	forv(i,bs[v]){
		int p=bs[v][i];
		inc(pos1[v],pos2[v],-1,0,n,0);
		inc(pos1[p],pos2[p],-1,0,n,0);
	}
}

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

	int m;
	cin>>n>>m;
	forn(i,n-1){
		int a,b;
		scanf("%d%d",&a,&b);
		--a;--b;
		gr[a].pb(b);
		gr[b].pb(a);
	}
	forn(i,m){
		int a,b;
		scanf("%d%d",&a,&b);
		--a;--b;
		bs[a].pb(b);
		bs[b].pb(a);
	}
	init(0,n,0);
	dfs1(0,-1);
	dfs2(0,-1);

	forn(i,n){
		if(res[i])
			--res[i];
		printf("%d ",res[i]);
	}

	return 0;
}


// In the Name Of God

#include <iostream>
#include <fstream>

#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <istream>
#include <queue>
#include <cmath>
#include <stack>
#include <sstream>
#include <bitset>

#define inf (int)(~0u/2)
#define ll_inf (long long)1ll << 62
//#define int long long
#define float long double
#define eps (1e-8)
#define for2(i, a, b) for ( int (i) = (a); (i)<(b); (i)++ )
#define mp make_pair
#define f1 first
#define f2 second
#define pb push_back
#define po pop_back
#define pii pair<int,int>
#define vpii vector <pii>
#define vi vector<int>
#define sz(a) (int) a.size( )
#define fillArr(n, a) for2(i, 0, n) cin >> a[i];
#define print(a) cout << #a << endl;
#define umax(a,b) a = max ( a, b )
#define umin(a,b) a = min ( a, b )
#define all(k) k.begin ( ), k.end( )
#define rall(k) k.rbegin ( ), k.rend( )
#define ll long long
#define clean(k) memset( k, 0, sizeof(k) )
using namespace std;

const int maxn = 1e5+45;
vi adlist[maxn];
int st[maxn], e[maxn];
int c[maxn];
bool visited[maxn];
int tim;
vi q[maxn];

void dfs ( int root ){
    visited[root] = 1;
    st[root] = tim++;
    for2 ( i, 0, sz(adlist[root]) ){
        int j = adlist[root][i];
        if ( !visited[j] )
            dfs ( j );
    }
    e[root] = tim;
}

int sum[maxn<<2], f[maxn<<2];

void upd ( int st, int e, int l, int r, int t, int ind = 1 ){
    if ( st >= r || e <= l )
        return;
    if ( st >= l && e <= r )
        return f[ind] += t, void ( );
    int mid = st + e >> 1, left = ind << 1, right = left + 1;
    upd ( st, mid, l, r, t, left );
    upd ( mid, e, l, r, t, right );
    sum[ind] = (f[left] ? mid - st : sum[left]) + (f[right] ? e - mid : sum[right]);
}

int n;

void dfs2 ( int root ){
    visited[root] = 1;
    for2 ( i, 0, sz(q[root]) ){
        int j = q[root][i];
        upd ( 0, n, st[j], e[j], 1 );
        upd ( 0, n, st[root], e[root], 1 );
    }
    c[root] = f[1] ? n-1 : max ( sum[1] - 1, 0 );
    for2 ( i, 0, sz(adlist[root]) ){
        int j = adlist[root][i];
        if ( !visited[j] )
            dfs2 ( j );
    }
    for2 ( i, 0, sz(q[root]) ){
        int j = q[root][i];
        upd ( 0, n, st[j], e[j], -1 );
        upd ( 0, n, st[root], e[root], -1 );
    }
}

void main ( ){
    int m;
    cin >> n >> m;
    for2 ( i, 0, n-1 ){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        adlist[b].pb ( a );
        adlist[a].pb ( b );
    }

    dfs ( 0 );

    for2 ( i, 0, m ){
        int a, b;
        cin >> a >> b;
        a--, b--;
        q[a].pb ( b );
        q[b].pb ( a );
    }

    clean ( visited );
    dfs2 ( 0 );

    for2 ( i, 0, n )
        cout << c[i] << ' ';
}


/*
ID: nbuacm09
LANG: C++
TASK: cryptcow
*/
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;
//#define BIGINTEGER
//#define PRIME
//#define GEOMETRY
template<class T> T f_min(T x,T y){return x<y?x:y;}
template<class T> T f_max(T x,T y){return x>y?x:y;}
template<class T> T f_abs(T x){return x<0?-x:x;}
template<class T> T gcd(T x,T y){while(T t=x%y)x=y,y=t;return y;}
const double eps = 1e-9;
const double PI = acos(-1.);
const int INF = 1000000000;
const int MOD = 1000000007;
const double E = 2.7182818284590452353602874713527;

#define pmul(x1,y1,x2,y2) ((x1)*(x2)+(y1)*(y2))
#define xmul(x1,y1,x2,y2) ((x1)*(y2)-(x2)*(y1))
#define sqr(x) ((x)*(x))

#define FR(i,N) for(int i=0;i<N;i++)
#define FRS(i,S,E) for(int i=S;i<=E;i++)
#define FRD(i,S,E) for(int i=S;i>=E;i--)
#define SZ(x) ((int)(x).size())
#define fill(a,b) memset(a,b,sizeof(a));
#define MP(a,b) make_pair(a,b)
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define PB push_back
#define lowbit(x) ((x)&(-(x)))

bool isdig(char x){return x>='0'&&x<='9';}
bool isup(char x){return x>='A'&&x<='Z';}
bool isdown(char x){return x>='a'&&x<='z';}
bool islet(char x){return isup(x)||isdown(x);}
#ifdef BIGINTEGER
//big integer +
struct Bint{
	int v[2005],l;
	void set(int x){
		l=0;
		while(x)v[l++]=x%10,x/=10;
	}
	void get(){
		char s[1005];
		scanf("%s",s);
		l=strlen(s);
		FR(i,l)v[i]=s[l-1-i]-'0';
	}
	Bint friend operator+(Bint &a,Bint &b){
		Bint r;
		r.l=f_max(a.l,b.l);
		FR(i,r.l){
			r.v[i]=0;
			if(i<a.l)r.v[i]+=a.v[i];
			if(i<b.l)r.v[i]+=b.v[i];
		}
		FR(i,r.l){
			if(r.v[i]>=10){
				if(i+1==r.l)r.v[r.l++]=0;
				r.v[i+1]++;
				r.v[i]-=10;
			}
		}
		return r;
	}
	void disp(){
		FR(i,l)cout<<v[l-1-i];
		cout<<endl;
	}
};
#endif
#ifdef PRIME
//get prime under PRIMEN
#define PRIMEN 10000000
bool unprime[PRIMEN+5];
ll prime[PRIMEN+5],pn;
void get_prime(){
	fill(unprime,0);pn=0;
	unprime[1]=1;
	FRS(i,2,PRIMEN+5){
		if(unprime[i])continue;
		prime[pn++]=i;
		if(i>40000)continue;
		for(int j=i*i;j<PRIMEN+5;j+=i)unprime[j]=1;
	}
}
ll fac[105];
int fn,cnt[105];
void get_fac(ll x){
	fn=0;
	for(int i=0;i<pn&&prime[i]*prime[i]<=x;i++){
		if(x%prime[i])continue;
		cnt[fn]=0;
		fac[fn]=prime[i];
		while(x%prime[i]==0){
			x/=prime[i];
			cnt[fn]++;
		}
		fn++;
	}
	if(x>1){
		fac[fn]=x;
		cnt[fn++]=1;
	}
}
#endif
#ifdef GEOMETRY
//-------GEOMETRY-------
struct Point{
	double x,y;
	Point(){}
	Point(double _x,double _y){x=_x;y=_y;}
};
struct Line{
	Point s,e;
	Line(){}
	Line(Point _s,Point _e){s=_s;e=_e;}
	double dis(){
		return sqrt(sqr(e.x-s.x)+sqr(e.y-s.y));
	}
};
double x_mul(Line a,Line b){
	double x1,y1,x2,y2;
	x1=a.e.x-a.s.x;
	y1=a.e.y-a.s.y;
	x2=b.e.x-b.s.x;
	y2=b.e.y-b.s.y;
	return x1*y2-x2*y1;
}
double p_mul(Line a,Line b){
	double x1,y1,x2,y2;
	x1=a.e.x-a.s.x;
	y1=a.e.y-a.s.y;
	x2=b.e.x-b.s.x;
	y2=b.e.y-b.s.y;
	return x1*x2+y1*y2;
}
void rotate(double &x,double &y,double ang){
	double tx,ty;
	tx=x*cos(ang)-y*sin(ang);
	ty=y*cos(ang)+x*sin(ang);
	x=tx;y=ty;
}
#endif

//--------CODE----------
struct Edge{
	int u,v,next;
	bool mk;
};
Edge edge[200005];
int head[100005],en;
int num[100005],nn,SS[100005],EE[100005];
int N,Q;
void insert(int u,int v){
	edge[en].u=u;edge[en].v=v;
	edge[en].next=head[u];head[u]=en++;
}
void dfs2(int u){
	int i,v;
	num[nn++]=u;SS[u]=nn-1;
	for(i=head[u];i!=-1;i=edge[i].next){
		if(edge[i].mk)continue;
		edge[i^1].mk=1;
		v=edge[i].v;
		dfs2(v);
	}
	EE[u]=nn-1;
}
vector<int>qry[100005];
void get_data(){
	fill(head,-1);en=0;
	cin>>N>>Q;
	int u,v;
	FR(i,N-1){
		cin>>u>>v;u--;v--;
		insert(u,v);
		insert(v,u);
	}
	FR(i,N)qry[i].clear();
	nn=0;
	dfs2(0);
	int a,b;
	FR(i,Q){
		cin>>a>>b;a--;b--;
		qry[a].PB(b);
		qry[b].PB(a);
	}
}
struct Node{
	int s,e,v,cnt;
};
Node nd[400005];
int res[100005];
void bd_t(int l,int s,int e){
	nd[l].s=s;nd[l].e=e;nd[l].v=0;nd[l].cnt=0;
	if(s==e)return;
	int mid=(s+e)>>1;
	bd_t(l<<1,s,mid);
	bd_t(l<<1|1,mid+1,e);
}
void f_insert(int l,int s,int e,int ad){
	if(nd[l].s==s&&nd[l].e==e){
		nd[l].v+=ad;
	//	if(nd[l].v<0)while(1);
		if(nd[l].v)nd[l].cnt=e-s+1;
		else{
			if(s==e)nd[l].cnt=0;
			else nd[l].cnt=nd[l<<1].cnt+nd[l<<1|1].cnt;
		}
		return;
	}
	int mid=(nd[l].s+nd[l].e)>>1;
	if(e<=mid)f_insert(l<<1,s,e,ad);
	else if(s>mid)f_insert(l<<1|1,s,e,ad);
	else{
		f_insert(l<<1,s,mid,ad);
		f_insert(l<<1|1,mid+1,e,ad);
	}
	if(nd[l].v)nd[l].cnt=nd[l].e-nd[l].s+1;
	else nd[l].cnt=nd[l<<1].cnt+nd[l<<1|1].cnt;
}
void dfs(int u){
	int i,v;
	if(qry[u].size()){
		for(i=0;i<qry[u].size();i++){
			v=qry[u][i];
			f_insert(1,SS[v],EE[v],1);
		}
		f_insert(1,SS[u],EE[u],1);
	}
	res[u]=nd[1].cnt;
	if(res[u])res[u]--;
	for(i=head[u];i!=-1;i=edge[i].next){
		if(edge[i].mk)continue;
		v=edge[i].v;
		dfs(v);
	}
	if(qry[u].size()){
		for(i=0;i<qry[u].size();i++){
			v=qry[u][i];
			f_insert(1,SS[v],EE[v],-1);
		}
		f_insert(1,SS[u],EE[u],-1);
	}
}
void run(){
	fill(res,0);
	bd_t(1,0,N-1);
	dfs(0);
	FR(i,N)printf("%d ",res[i]);
	printf("\n");
}
int main(){
//	get_prime();
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	get_data();
	run();
	return 0;
}


/*
ID: nbuacm09
LANG: C++
TASK: cryptcow
*/
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;
//#define BIGINTEGER
//#define PRIME
//#define GEOMETRY
template<class T> T f_min(T x,T y){return x<y?x:y;}
template<class T> T f_max(T x,T y){return x>y?x:y;}
template<class T> T f_abs(T x){return x<0?-x:x;}
template<class T> T gcd(T x,T y){while(T t=x%y)x=y,y=t;return y;}
const double eps = 1e-9;
const double PI = acos(-1.);
const int INF = 1000000000;
const int MOD = 1000000007;
const double E = 2.7182818284590452353602874713527;

#define pmul(x1,y1,x2,y2) ((x1)*(x2)+(y1)*(y2))
#define xmul(x1,y1,x2,y2) ((x1)*(y2)-(x2)*(y1))
#define sqr(x) ((x)*(x))

#define FR(i,N) for(int i=0;i<N;i++)
#define FRS(i,S,E) for(int i=S;i<=E;i++)
#define FRD(i,S,E) for(int i=S;i>=E;i--)
#define SZ(x) ((int)(x).size())
#define fill(a,b) memset(a,b,sizeof(a));
#define MP(a,b) make_pair(a,b)
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define PB push_back
#define lowbit(x) ((x)&(-(x)))

bool isdig(char x){return x>='0'&&x<='9';}
bool isup(char x){return x>='A'&&x<='Z';}
bool isdown(char x){return x>='a'&&x<='z';}
bool islet(char x){return isup(x)||isdown(x);}
#ifdef BIGINTEGER
//big integer +
struct Bint{
	int v[2005],l;
	void set(int x){
		l=0;
		while(x)v[l++]=x%10,x/=10;
	}
	void get(){
		char s[1005];
		scanf("%s",s);
		l=strlen(s);
		FR(i,l)v[i]=s[l-1-i]-'0';
	}
	Bint friend operator+(Bint &a,Bint &b){
		Bint r;
		r.l=f_max(a.l,b.l);
		FR(i,r.l){
			r.v[i]=0;
			if(i<a.l)r.v[i]+=a.v[i];
			if(i<b.l)r.v[i]+=b.v[i];
		}
		FR(i,r.l){
			if(r.v[i]>=10){
				if(i+1==r.l)r.v[r.l++]=0;
				r.v[i+1]++;
				r.v[i]-=10;
			}
		}
		return r;
	}
	void disp(){
		FR(i,l)cout<<v[l-1-i];
		cout<<endl;
	}
};
#endif
#ifdef PRIME
//get prime under PRIMEN
#define PRIMEN 10000000
bool unprime[PRIMEN+5];
ll prime[PRIMEN+5],pn;
void get_prime(){
	fill(unprime,0);pn=0;
	unprime[1]=1;
	FRS(i,2,PRIMEN+5){
		if(unprime[i])continue;
		prime[pn++]=i;
		if(i>40000)continue;
		for(int j=i*i;j<PRIMEN+5;j+=i)unprime[j]=1;
	}
}
ll fac[105];
int fn,cnt[105];
void get_fac(ll x){
	fn=0;
	for(int i=0;i<pn&&prime[i]*prime[i]<=x;i++){
		if(x%prime[i])continue;
		cnt[fn]=0;
		fac[fn]=prime[i];
		while(x%prime[i]==0){
			x/=prime[i];
			cnt[fn]++;
		}
		fn++;
	}
	if(x>1){
		fac[fn]=x;
		cnt[fn++]=1;
	}
}
#endif
#ifdef GEOMETRY
//-------GEOMETRY-------
struct Point{
	double x,y;
	Point(){}
	Point(double _x,double _y){x=_x;y=_y;}
};
struct Line{
	Point s,e;
	Line(){}
	Line(Point _s,Point _e){s=_s;e=_e;}
	double dis(){
		return sqrt(sqr(e.x-s.x)+sqr(e.y-s.y));
	}
};
double x_mul(Line a,Line b){
	double x1,y1,x2,y2;
	x1=a.e.x-a.s.x;
	y1=a.e.y-a.s.y;
	x2=b.e.x-b.s.x;
	y2=b.e.y-b.s.y;
	return x1*y2-x2*y1;
}
double p_mul(Line a,Line b){
	double x1,y1,x2,y2;
	x1=a.e.x-a.s.x;
	y1=a.e.y-a.s.y;
	x2=b.e.x-b.s.x;
	y2=b.e.y-b.s.y;
	return x1*x2+y1*y2;
}
void rotate(double &x,double &y,double ang){
	double tx,ty;
	tx=x*cos(ang)-y*sin(ang);
	ty=y*cos(ang)+x*sin(ang);
	x=tx;y=ty;
}
#endif

//--------CODE----------
struct Edge{
	int u,v,next;
	bool mk;
};
Edge edge[200005];
int head[100005],en;
int num[100005],nn,SS[100005],EE[100005];
int N,Q;
void insert(int u,int v){
	edge[en].u=u;edge[en].v=v;
	edge[en].next=head[u];head[u]=en++;
}
void dfs2(int u){
	int i,v;
	num[nn++]=u;SS[u]=nn-1;
	for(i=head[u];i!=-1;i=edge[i].next){
		if(edge[i].mk)continue;
		edge[i^1].mk=1;
		v=edge[i].v;
		dfs2(v);
	}
	EE[u]=nn-1;
}
vector<int>qry[100005];
void get_data(){
	fill(head,-1);en=0;
	cin>>N>>Q;
	int u,v;
	FR(i,N-1){
		cin>>u>>v;u--;v--;
		insert(u,v);
		insert(v,u);
	}
	FR(i,N)qry[i].clear();
	nn=0;
	dfs2(0);
	int a,b;
	FR(i,Q){
		cin>>a>>b;a--;b--;
		qry[a].PB(b);
		qry[b].PB(a);
	}
}
struct Node{
	int s,e,v,cnt;
};
Node nd[400005];
int res[100005];
void bd_t(int l,int s,int e){
	nd[l].s=s;nd[l].e=e;nd[l].v=0;nd[l].cnt=0;
	if(s==e)return;
	int mid=(s+e)>>1;
	bd_t(l<<1,s,mid);
	bd_t(l<<1|1,mid+1,e);
}
void f_insert(int l,int s,int e,int ad){
	if(nd[l].s==s&&nd[l].e==e){
		nd[l].v+=ad;
		if(nd[l].v)nd[l].cnt=e-s+1;
		else nd[l].cnt=0;
		return;
	}
	int mid=(nd[l].s+nd[l].e)>>1;
	if(e<=mid)f_insert(l<<1,s,e,ad);
	else if(s>mid)f_insert(l<<1|1,s,e,ad);
	else{
		f_insert(l<<1,s,mid,ad);
		f_insert(l<<1|1,mid+1,e,ad);
	}
	if(nd[l].v)nd[l].cnt=nd[l].e-nd[l].s+1;
	else nd[l].cnt=nd[l<<1].cnt+nd[l<<1|1].cnt;
}
void dfs(int u){
	int i,v;
	if(qry[u].size()){
		for(i=0;i<qry[u].size();i++){
			v=qry[u][i];
			f_insert(1,SS[v],EE[v],1);
		}
		f_insert(1,SS[u],EE[u],1);
	}
	res[u]=nd[1].cnt;
	if(res[u])res[u]--;
	for(i=head[u];i!=-1;i=edge[i].next){
		if(edge[i].mk)continue;
		v=edge[i].v;
		dfs(v);
	}
	if(qry[u].size()){
		for(i=0;i<qry[u].size();i++){
			v=qry[u][i];
			f_insert(1,SS[v],EE[v],-1);
		}
		f_insert(1,SS[u],EE[u],-1);
	}
}
void run(){
	fill(res,0);
	bd_t(1,0,N-1);
	dfs(0);
	FR(i,N)printf("%d ",res[i]);
	printf("\n");
}
int main(){
//	get_prime();
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	get_data();
	run();
	return 0;
}


/*
ID: nbuacm09
LANG: C++
TASK: cryptcow
*/
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;
//#define BIGINTEGER
//#define PRIME
//#define GEOMETRY
template<class T> T f_min(T x,T y){return x<y?x:y;}
template<class T> T f_max(T x,T y){return x>y?x:y;}
template<class T> T f_abs(T x){return x<0?-x:x;}
template<class T> T gcd(T x,T y){while(T t=x%y)x=y,y=t;return y;}
const double eps = 1e-9;
const double PI = acos(-1.);
const int INF = 1000000000;
const int MOD = 1000000007;
const double E = 2.7182818284590452353602874713527;

#define pmul(x1,y1,x2,y2) ((x1)*(x2)+(y1)*(y2))
#define xmul(x1,y1,x2,y2) ((x1)*(y2)-(x2)*(y1))
#define sqr(x) ((x)*(x))

#define FR(i,N) for(int i=0;i<N;i++)
#define FRS(i,S,E) for(int i=S;i<=E;i++)
#define FRD(i,S,E) for(int i=S;i>=E;i--)
#define SZ(x) ((int)(x).size())
#define fill(a,b) memset(a,b,sizeof(a));
#define MP(a,b) make_pair(a,b)
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define PB push_back
#define lowbit(x) ((x)&(-(x)))

bool isdig(char x){return x>='0'&&x<='9';}
bool isup(char x){return x>='A'&&x<='Z';}
bool isdown(char x){return x>='a'&&x<='z';}
bool islet(char x){return isup(x)||isdown(x);}
#ifdef BIGINTEGER
//big integer +
struct Bint{
	int v[2005],l;
	void set(int x){
		l=0;
		while(x)v[l++]=x%10,x/=10;
	}
	void get(){
		char s[1005];
		scanf("%s",s);
		l=strlen(s);
		FR(i,l)v[i]=s[l-1-i]-'0';
	}
	Bint friend operator+(Bint &a,Bint &b){
		Bint r;
		r.l=f_max(a.l,b.l);
		FR(i,r.l){
			r.v[i]=0;
			if(i<a.l)r.v[i]+=a.v[i];
			if(i<b.l)r.v[i]+=b.v[i];
		}
		FR(i,r.l){
			if(r.v[i]>=10){
				if(i+1==r.l)r.v[r.l++]=0;
				r.v[i+1]++;
				r.v[i]-=10;
			}
		}
		return r;
	}
	void disp(){
		FR(i,l)cout<<v[l-1-i];
		cout<<endl;
	}
};
#endif
#ifdef PRIME
//get prime under PRIMEN
#define PRIMEN 10000000
bool unprime[PRIMEN+5];
ll prime[PRIMEN+5],pn;
void get_prime(){
	fill(unprime,0);pn=0;
	unprime[1]=1;
	FRS(i,2,PRIMEN+5){
		if(unprime[i])continue;
		prime[pn++]=i;
		if(i>40000)continue;
		for(int j=i*i;j<PRIMEN+5;j+=i)unprime[j]=1;
	}
}
ll fac[105];
int fn,cnt[105];
void get_fac(ll x){
	fn=0;
	for(int i=0;i<pn&&prime[i]*prime[i]<=x;i++){
		if(x%prime[i])continue;
		cnt[fn]=0;
		fac[fn]=prime[i];
		while(x%prime[i]==0){
			x/=prime[i];
			cnt[fn]++;
		}
		fn++;
	}
	if(x>1){
		fac[fn]=x;
		cnt[fn++]=1;
	}
}
#endif
#ifdef GEOMETRY
//-------GEOMETRY-------
struct Point{
	double x,y;
	Point(){}
	Point(double _x,double _y){x=_x;y=_y;}
};
struct Line{
	Point s,e;
	Line(){}
	Line(Point _s,Point _e){s=_s;e=_e;}
	double dis(){
		return sqrt(sqr(e.x-s.x)+sqr(e.y-s.y));
	}
};
double x_mul(Line a,Line b){
	double x1,y1,x2,y2;
	x1=a.e.x-a.s.x;
	y1=a.e.y-a.s.y;
	x2=b.e.x-b.s.x;
	y2=b.e.y-b.s.y;
	return x1*y2-x2*y1;
}
double p_mul(Line a,Line b){
	double x1,y1,x2,y2;
	x1=a.e.x-a.s.x;
	y1=a.e.y-a.s.y;
	x2=b.e.x-b.s.x;
	y2=b.e.y-b.s.y;
	return x1*x2+y1*y2;
}
void rotate(double &x,double &y,double ang){
	double tx,ty;
	tx=x*cos(ang)-y*sin(ang);
	ty=y*cos(ang)+x*sin(ang);
	x=tx;y=ty;
}
#endif

//--------CODE----------
struct Edge{
	int u,v,next;
	bool mk;
};
Edge edge[200005];
int head[100005],en;
int num[100005],nn,SS[100005],EE[100005];
int N,Q;
void insert(int u,int v){
	edge[en].u=u;edge[en].v=v;
	edge[en].next=head[u];head[u]=en++;
}
void dfs2(int u){
	int i,v;
	num[nn++]=u;SS[u]=nn-1;
	for(i=head[u];i!=-1;i=edge[i].next){
		if(edge[i].mk)continue;
		edge[i^1].mk=1;
		v=edge[i].v;
		dfs2(v);
	}
	EE[u]=nn-1;
}
vector<int>qry[100005];
void get_data(){
	fill(head,-1);en=0;
	cin>>N>>Q;
	int u,v;
	FR(i,N-1){
		cin>>u>>v;u--;v--;
		insert(u,v);
		insert(v,u);
	}
	FR(i,N)qry[i].clear();
	nn=0;
	dfs2(0);
	int a,b;
	FR(i,Q){
		cin>>a>>b;a--;b--;
		qry[a].PB(b);
		qry[b].PB(a);
	}
}
struct Node{
	int s,e,v,cnt;
};
Node nd[400005];
int res[100005];
void bd_t(int l,int s,int e){
	nd[l].s=s;nd[l].e=e;nd[l].v=0;nd[l].cnt=0;
	if(s==e)return;
	int mid=(s+e)>>1;
	bd_t(l<<1,s,mid);
	bd_t(l<<1|1,mid+1,e);
}
void f_insert(int l,int s,int e,int ad){
	if(nd[l].s==s&&nd[l].e==e){
		nd[l].v+=ad;
		if(nd[l].v<0)while(1);
		if(nd[l].v)nd[l].cnt=e-s+1;
		else nd[l].cnt=0;
		return;
	}
	int mid=(nd[l].s+nd[l].e)>>1;
	if(e<=mid)f_insert(l<<1,s,e,ad);
	else if(s>mid)f_insert(l<<1|1,s,e,ad);
	else{
		f_insert(l<<1,s,mid,ad);
		f_insert(l<<1|1,mid+1,e,ad);
	}
	if(nd[l].v)nd[l].cnt=nd[l].e-nd[l].s+1;
	else nd[l].cnt=nd[l<<1].cnt+nd[l<<1|1].cnt;
}
void dfs(int u){
	int i,v;
	if(qry[u].size()){
		for(i=0;i<qry[u].size();i++){
			v=qry[u][i];
			f_insert(1,SS[v],EE[v],1);
		}
		f_insert(1,SS[u],EE[u],1);
	}
	res[u]=nd[1].cnt;
	if(res[u])res[u]--;
	for(i=head[u];i!=-1;i=edge[i].next){
		if(edge[i].mk)continue;
		v=edge[i].v;
		dfs(v);
	}
	if(qry[u].size()){
		f_insert(1,SS[u],EE[u],-1);
		for(i=qry[u].size()-1;i>=0;i--){
			v=qry[u][i];
			f_insert(1,SS[v],EE[v],-1);
		}

	}
}
void run(){
	fill(res,0);
	bd_t(1,0,N-1);
	dfs(0);
	FR(i,N)printf("%d ",res[i]);
	printf("\n");
}
int main(){
//	get_prime();
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	get_data();
	run();
	return 0;
}


/*
ID: nbuacm09
LANG: C++
TASK: cryptcow
*/
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;
//#define BIGINTEGER
//#define PRIME
//#define GEOMETRY
template<class T> T f_min(T x,T y){return x<y?x:y;}
template<class T> T f_max(T x,T y){return x>y?x:y;}
template<class T> T f_abs(T x){return x<0?-x:x;}
template<class T> T gcd(T x,T y){while(T t=x%y)x=y,y=t;return y;}
const double eps = 1e-9;
const double PI = acos(-1.);
const int INF = 1000000000;
const int MOD = 1000000007;
const double E = 2.7182818284590452353602874713527;

#define pmul(x1,y1,x2,y2) ((x1)*(x2)+(y1)*(y2))
#define xmul(x1,y1,x2,y2) ((x1)*(y2)-(x2)*(y1))
#define sqr(x) ((x)*(x))

#define FR(i,N) for(int i=0;i<N;i++)
#define FRS(i,S,E) for(int i=S;i<=E;i++)
#define FRD(i,S,E) for(int i=S;i>=E;i--)
#define SZ(x) ((int)(x).size())
#define fill(a,b) memset(a,b,sizeof(a));
#define MP(a,b) make_pair(a,b)
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define PB push_back
#define lowbit(x) ((x)&(-(x)))

bool isdig(char x){return x>='0'&&x<='9';}
bool isup(char x){return x>='A'&&x<='Z';}
bool isdown(char x){return x>='a'&&x<='z';}
bool islet(char x){return isup(x)||isdown(x);}
#ifdef BIGINTEGER
//big integer +
struct Bint{
	int v[2005],l;
	void set(int x){
		l=0;
		while(x)v[l++]=x%10,x/=10;
	}
	void get(){
		char s[1005];
		scanf("%s",s);
		l=strlen(s);
		FR(i,l)v[i]=s[l-1-i]-'0';
	}
	Bint friend operator+(Bint &a,Bint &b){
		Bint r;
		r.l=f_max(a.l,b.l);
		FR(i,r.l){
			r.v[i]=0;
			if(i<a.l)r.v[i]+=a.v[i];
			if(i<b.l)r.v[i]+=b.v[i];
		}
		FR(i,r.l){
			if(r.v[i]>=10){
				if(i+1==r.l)r.v[r.l++]=0;
				r.v[i+1]++;
				r.v[i]-=10;
			}
		}
		return r;
	}
	void disp(){
		FR(i,l)cout<<v[l-1-i];
		cout<<endl;
	}
};
#endif
#ifdef PRIME
//get prime under PRIMEN
#define PRIMEN 10000000
bool unprime[PRIMEN+5];
ll prime[PRIMEN+5],pn;
void get_prime(){
	fill(unprime,0);pn=0;
	unprime[1]=1;
	FRS(i,2,PRIMEN+5){
		if(unprime[i])continue;
		prime[pn++]=i;
		if(i>40000)continue;
		for(int j=i*i;j<PRIMEN+5;j+=i)unprime[j]=1;
	}
}
ll fac[105];
int fn,cnt[105];
void get_fac(ll x){
	fn=0;
	for(int i=0;i<pn&&prime[i]*prime[i]<=x;i++){
		if(x%prime[i])continue;
		cnt[fn]=0;
		fac[fn]=prime[i];
		while(x%prime[i]==0){
			x/=prime[i];
			cnt[fn]++;
		}
		fn++;
	}
	if(x>1){
		fac[fn]=x;
		cnt[fn++]=1;
	}
}
#endif
#ifdef GEOMETRY
//-------GEOMETRY-------
struct Point{
	double x,y;
	Point(){}
	Point(double _x,double _y){x=_x;y=_y;}
};
struct Line{
	Point s,e;
	Line(){}
	Line(Point _s,Point _e){s=_s;e=_e;}
	double dis(){
		return sqrt(sqr(e.x-s.x)+sqr(e.y-s.y));
	}
};
double x_mul(Line a,Line b){
	double x1,y1,x2,y2;
	x1=a.e.x-a.s.x;
	y1=a.e.y-a.s.y;
	x2=b.e.x-b.s.x;
	y2=b.e.y-b.s.y;
	return x1*y2-x2*y1;
}
double p_mul(Line a,Line b){
	double x1,y1,x2,y2;
	x1=a.e.x-a.s.x;
	y1=a.e.y-a.s.y;
	x2=b.e.x-b.s.x;
	y2=b.e.y-b.s.y;
	return x1*x2+y1*y2;
}
void rotate(double &x,double &y,double ang){
	double tx,ty;
	tx=x*cos(ang)-y*sin(ang);
	ty=y*cos(ang)+x*sin(ang);
	x=tx;y=ty;
}
#endif

//--------CODE----------
struct Edge{
	int u,v,next;
	bool mk;
};
Edge edge[200005];
int head[100005],en;
int num[100005],nn,SS[100005],EE[100005];
int N,Q;
void insert(int u,int v){
	edge[en].u=u;edge[en].v=v;
	edge[en].next=head[u];head[u]=en++;
}
void dfs2(int u){
	int i,v;
	num[nn++]=u;SS[u]=nn-1;
	for(i=head[u];i!=-1;i=edge[i].next){
		if(edge[i].mk)continue;
		edge[i^1].mk=1;
		v=edge[i].v;
		dfs2(v);
	}
	EE[u]=nn-1;
}
vector<int>qry[100005];
void get_data(){
	fill(head,-1);en=0;
	cin>>N>>Q;
	int u,v;
	FR(i,N-1){
		cin>>u>>v;u--;v--;
		insert(u,v);
		insert(v,u);
	}
	FR(i,N)qry[i].clear();
	nn=0;
	dfs2(0);
	int a,b;
	FR(i,Q){
		cin>>a>>b;a--;b--;
		qry[a].PB(b);
		qry[b].PB(a);
	}
}
struct Node{
	int s,e,v,cnt;
};
Node nd[400005];
int res[100005];
void bd_t(int l,int s,int e){
	nd[l].s=s;nd[l].e=e;nd[l].v=0;nd[l].cnt=0;
	if(s==e)return;
	int mid=(s+e)>>1;
	bd_t(l<<1,s,mid);
	bd_t(l<<1|1,mid+1,e);
}
void f_insert(int l,int s,int e,int ad){
	if(nd[l].s==s&&nd[l].e==e){
		nd[l].v+=ad;
	//	if(nd[l].v<0)while(1);
		if(nd[l].v)nd[l].cnt=e-s+1;
		else{
			if(s==e)nd[l].v=0;
			else nd[l].v=nd[l<<1].v+nd[l<<1|1].v;
		}
		return;
	}
	int mid=(nd[l].s+nd[l].e)>>1;
	if(e<=mid)f_insert(l<<1,s,e,ad);
	else if(s>mid)f_insert(l<<1|1,s,e,ad);
	else{
		f_insert(l<<1,s,mid,ad);
		f_insert(l<<1|1,mid+1,e,ad);
	}
	if(nd[l].v)nd[l].cnt=nd[l].e-nd[l].s+1;
	else nd[l].cnt=nd[l<<1].cnt+nd[l<<1|1].cnt;
}
void dfs(int u){
	int i,v;
	if(qry[u].size()){
		for(i=0;i<qry[u].size();i++){
			v=qry[u][i];
			f_insert(1,SS[v],EE[v],1);
		}
		f_insert(1,SS[u],EE[u],1);
	}
	res[u]=nd[1].cnt;
	if(res[u])res[u]--;
	for(i=head[u];i!=-1;i=edge[i].next){
		if(edge[i].mk)continue;
		v=edge[i].v;
		dfs(v);
	}
	if(qry[u].size()){
		f_insert(1,SS[u],EE[u],-1);
		for(i=qry[u].size()-1;i>=0;i--){
			v=qry[u][i];
			f_insert(1,SS[v],EE[v],-1);
		}

	}
}
void run(){
	fill(res,0);
	bd_t(1,0,N-1);
	dfs(0);
	FR(i,N)printf("%d ",res[i]);
	printf("\n");
}
int main(){
//	get_prime();
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	get_data();
	run();
	return 0;
}


/*
ID: nbuacm09
LANG: C++
TASK: cryptcow
*/
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;
//#define BIGINTEGER
//#define PRIME
//#define GEOMETRY
template<class T> T f_min(T x,T y){return x<y?x:y;}
template<class T> T f_max(T x,T y){return x>y?x:y;}
template<class T> T f_abs(T x){return x<0?-x:x;}
template<class T> T gcd(T x,T y){while(T t=x%y)x=y,y=t;return y;}
const double eps = 1e-9;
const double PI = acos(-1.);
const int INF = 1000000000;
const int MOD = 1000000007;
const double E = 2.7182818284590452353602874713527;

#define pmul(x1,y1,x2,y2) ((x1)*(x2)+(y1)*(y2))
#define xmul(x1,y1,x2,y2) ((x1)*(y2)-(x2)*(y1))
#define sqr(x) ((x)*(x))

#define FR(i,N) for(int i=0;i<N;i++)
#define FRS(i,S,E) for(int i=S;i<=E;i++)
#define FRD(i,S,E) for(int i=S;i>=E;i--)
#define SZ(x) ((int)(x).size())
#define fill(a,b) memset(a,b,sizeof(a));
#define MP(a,b) make_pair(a,b)
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define PB push_back
#define lowbit(x) ((x)&(-(x)))

bool isdig(char x){return x>='0'&&x<='9';}
bool isup(char x){return x>='A'&&x<='Z';}
bool isdown(char x){return x>='a'&&x<='z';}
bool islet(char x){return isup(x)||isdown(x);}
#ifdef BIGINTEGER
//big integer +
struct Bint{
	int v[2005],l;
	void set(int x){
		l=0;
		while(x)v[l++]=x%10,x/=10;
	}
	void get(){
		char s[1005];
		scanf("%s",s);
		l=strlen(s);
		FR(i,l)v[i]=s[l-1-i]-'0';
	}
	Bint friend operator+(Bint &a,Bint &b){
		Bint r;
		r.l=f_max(a.l,b.l);
		FR(i,r.l){
			r.v[i]=0;
			if(i<a.l)r.v[i]+=a.v[i];
			if(i<b.l)r.v[i]+=b.v[i];
		}
		FR(i,r.l){
			if(r.v[i]>=10){
				if(i+1==r.l)r.v[r.l++]=0;
				r.v[i+1]++;
				r.v[i]-=10;
			}
		}
		return r;
	}
	void disp(){
		FR(i,l)cout<<v[l-1-i];
		cout<<endl;
	}
};
#endif
#ifdef PRIME
//get prime under PRIMEN
#define PRIMEN 10000000
bool unprime[PRIMEN+5];
ll prime[PRIMEN+5],pn;
void get_prime(){
	fill(unprime,0);pn=0;
	unprime[1]=1;
	FRS(i,2,PRIMEN+5){
		if(unprime[i])continue;
		prime[pn++]=i;
		if(i>40000)continue;
		for(int j=i*i;j<PRIMEN+5;j+=i)unprime[j]=1;
	}
}
ll fac[105];
int fn,cnt[105];
void get_fac(ll x){
	fn=0;
	for(int i=0;i<pn&&prime[i]*prime[i]<=x;i++){
		if(x%prime[i])continue;
		cnt[fn]=0;
		fac[fn]=prime[i];
		while(x%prime[i]==0){
			x/=prime[i];
			cnt[fn]++;
		}
		fn++;
	}
	if(x>1){
		fac[fn]=x;
		cnt[fn++]=1;
	}
}
#endif
#ifdef GEOMETRY
//-------GEOMETRY-------
struct Point{
	double x,y;
	Point(){}
	Point(double _x,double _y){x=_x;y=_y;}
};
struct Line{
	Point s,e;
	Line(){}
	Line(Point _s,Point _e){s=_s;e=_e;}
	double dis(){
		return sqrt(sqr(e.x-s.x)+sqr(e.y-s.y));
	}
};
double x_mul(Line a,Line b){
	double x1,y1,x2,y2;
	x1=a.e.x-a.s.x;
	y1=a.e.y-a.s.y;
	x2=b.e.x-b.s.x;
	y2=b.e.y-b.s.y;
	return x1*y2-x2*y1;
}
double p_mul(Line a,Line b){
	double x1,y1,x2,y2;
	x1=a.e.x-a.s.x;
	y1=a.e.y-a.s.y;
	x2=b.e.x-b.s.x;
	y2=b.e.y-b.s.y;
	return x1*x2+y1*y2;
}
void rotate(double &x,double &y,double ang){
	double tx,ty;
	tx=x*cos(ang)-y*sin(ang);
	ty=y*cos(ang)+x*sin(ang);
	x=tx;y=ty;
}
#endif

//--------CODE----------
struct Edge{
	int u,v,next;
	bool mk;
};
Edge edge[200005];
int head[100005],en;
int num[100005],nn,SS[100005],EE[100005];
int N,Q;
void insert(int u,int v){
	edge[en].u=u;edge[en].v=v;
	edge[en].next=head[u];head[u]=en++;
}
void dfs2(int u){
	int i,v;
	num[nn++]=u;SS[u]=nn-1;
	for(i=head[u];i!=-1;i=edge[i].next){
		if(edge[i].mk)continue;
		edge[i^1].mk=1;
		v=edge[i].v;
		dfs2(v);
	}
	EE[u]=nn-1;
}
vector<int>qry[100005];
void get_data(){
	fill(head,-1);en=0;
	cin>>N>>Q;
	int u,v;
	FR(i,N-1){
		cin>>u>>v;u--;v--;
		insert(u,v);
		insert(v,u);
	}
	FR(i,N)qry[i].clear();
	nn=0;
	dfs2(0);
	int a,b;
	FR(i,Q){
		cin>>a>>b;a--;b--;
		qry[a].PB(b);
		qry[b].PB(a);
	}
}
struct Node{
	int s,e,v,cnt;
};
Node nd[400005];
int res[100005];
void bd_t(int l,int s,int e){
	nd[l].s=s;nd[l].e=e;nd[l].v=0;nd[l].cnt=0;
	if(s==e)return;
	int mid=(s+e)>>1;
	bd_t(l<<1,s,mid);
	bd_t(l<<1|1,mid+1,e);
}
void f_insert(int l,int s,int e,int ad){
	if(nd[l].s==s&&nd[l].e==e){
		nd[l].v+=ad;
	//	if(nd[l].v<0)while(1);
		if(nd[l].v)nd[l].cnt=e-s+1;
		else{
			if(s==e)nd[l].cnt=0;
			else nd[l].cnt=nd[l<<1].cnt+nd[l<<1|1].cnt;
		}
		return;
	}
	int mid=(nd[l].s+nd[l].e)>>1;
	if(e<=mid)f_insert(l<<1,s,e,ad);
	else if(s>mid)f_insert(l<<1|1,s,e,ad);
	else{
		f_insert(l<<1,s,mid,ad);
		f_insert(l<<1|1,mid+1,e,ad);
	}
	if(nd[l].v)nd[l].cnt=nd[l].e-nd[l].s+1;
	else nd[l].cnt=nd[l<<1].cnt+nd[l<<1|1].cnt;
}
void dfs(int u){
	int i,v;
	if(qry[u].size()){
		for(i=0;i<qry[u].size();i++){
			v=qry[u][i];
			f_insert(1,SS[v],EE[v],1);
		}
		f_insert(1,SS[u],EE[u],1);
	}
	res[u]=nd[1].cnt;
	if(res[u])res[u]--;
	for(i=head[u];i!=-1;i=edge[i].next){
		if(edge[i].mk)continue;
		v=edge[i].v;
		dfs(v);
	}
	if(qry[u].size()){
		f_insert(1,SS[u],EE[u],-1);
		for(i=qry[u].size()-1;i>=0;i--){
			v=qry[u][i];
			f_insert(1,SS[v],EE[v],-1);
		}

	}
}
void run(){
	fill(res,0);
	bd_t(1,0,N-1);
	dfs(0);
	FR(i,N)printf("%d ",res[i]);
	printf("\n");
}
int main(){
//	get_prime();
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	get_data();
	run();
	return 0;
}


/*
ID: nbuacm09
LANG: C++
TASK: cryptcow
*/
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;
//#define BIGINTEGER
//#define PRIME
//#define GEOMETRY
template<class T> T f_min(T x,T y){return x<y?x:y;}
template<class T> T f_max(T x,T y){return x>y?x:y;}
template<class T> T f_abs(T x){return x<0?-x:x;}
template<class T> T gcd(T x,T y){while(T t=x%y)x=y,y=t;return y;}
const double eps = 1e-9;
const double PI = acos(-1.);
const int INF = 1000000000;
const int MOD = 1000000007;
const double E = 2.7182818284590452353602874713527;

#define pmul(x1,y1,x2,y2) ((x1)*(x2)+(y1)*(y2))
#define xmul(x1,y1,x2,y2) ((x1)*(y2)-(x2)*(y1))
#define sqr(x) ((x)*(x))

#define FR(i,N) for(int i=0;i<N;i++)
#define FRS(i,S,E) for(int i=S;i<=E;i++)
#define FRD(i,S,E) for(int i=S;i>=E;i--)
#define SZ(x) ((int)(x).size())
#define fill(a,b) memset(a,b,sizeof(a));
#define MP(a,b) make_pair(a,b)
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define PB push_back
#define lowbit(x) ((x)&(-(x)))

bool isdig(char x){return x>='0'&&x<='9';}
bool isup(char x){return x>='A'&&x<='Z';}
bool isdown(char x){return x>='a'&&x<='z';}
bool islet(char x){return isup(x)||isdown(x);}
#ifdef BIGINTEGER
//big integer +
struct Bint{
	int v[2005],l;
	void set(int x){
		l=0;
		while(x)v[l++]=x%10,x/=10;
	}
	void get(){
		char s[1005];
		scanf("%s",s);
		l=strlen(s);
		FR(i,l)v[i]=s[l-1-i]-'0';
	}
	Bint friend operator+(Bint &a,Bint &b){
		Bint r;
		r.l=f_max(a.l,b.l);
		FR(i,r.l){
			r.v[i]=0;
			if(i<a.l)r.v[i]+=a.v[i];
			if(i<b.l)r.v[i]+=b.v[i];
		}
		FR(i,r.l){
			if(r.v[i]>=10){
				if(i+1==r.l)r.v[r.l++]=0;
				r.v[i+1]++;
				r.v[i]-=10;
			}
		}
		return r;
	}
	void disp(){
		FR(i,l)cout<<v[l-1-i];
		cout<<endl;
	}
};
#endif
#ifdef PRIME
//get prime under PRIMEN
#define PRIMEN 10000000
bool unprime[PRIMEN+5];
ll prime[PRIMEN+5],pn;
void get_prime(){
	fill(unprime,0);pn=0;
	unprime[1]=1;
	FRS(i,2,PRIMEN+5){
		if(unprime[i])continue;
		prime[pn++]=i;
		if(i>40000)continue;
		for(int j=i*i;j<PRIMEN+5;j+=i)unprime[j]=1;
	}
}
ll fac[105];
int fn,cnt[105];
void get_fac(ll x){
	fn=0;
	for(int i=0;i<pn&&prime[i]*prime[i]<=x;i++){
		if(x%prime[i])continue;
		cnt[fn]=0;
		fac[fn]=prime[i];
		while(x%prime[i]==0){
			x/=prime[i];
			cnt[fn]++;
		}
		fn++;
	}
	if(x>1){
		fac[fn]=x;
		cnt[fn++]=1;
	}
}
#endif
#ifdef GEOMETRY
//-------GEOMETRY-------
struct Point{
	double x,y;
	Point(){}
	Point(double _x,double _y){x=_x;y=_y;}
};
struct Line{
	Point s,e;
	Line(){}
	Line(Point _s,Point _e){s=_s;e=_e;}
	double dis(){
		return sqrt(sqr(e.x-s.x)+sqr(e.y-s.y));
	}
};
double x_mul(Line a,Line b){
	double x1,y1,x2,y2;
	x1=a.e.x-a.s.x;
	y1=a.e.y-a.s.y;
	x2=b.e.x-b.s.x;
	y2=b.e.y-b.s.y;
	return x1*y2-x2*y1;
}
double p_mul(Line a,Line b){
	double x1,y1,x2,y2;
	x1=a.e.x-a.s.x;
	y1=a.e.y-a.s.y;
	x2=b.e.x-b.s.x;
	y2=b.e.y-b.s.y;
	return x1*x2+y1*y2;
}
void rotate(double &x,double &y,double ang){
	double tx,ty;
	tx=x*cos(ang)-y*sin(ang);
	ty=y*cos(ang)+x*sin(ang);
	x=tx;y=ty;
}
#endif

//--------CODE----------
struct Edge{
	int u,v,next;
	bool mk;
};
Edge edge[200005];
int head[100005],en;
int num[100005],nn,SS[100005],EE[100005];
int N,Q;
void insert(int u,int v){
	edge[en].u=u;edge[en].v=v;
	edge[en].next=head[u];head[u]=en++;
}
void dfs2(int u){
	int i,v;
	num[nn++]=u;SS[u]=nn-1;
	for(i=head[u];i!=-1;i=edge[i].next){
		if(edge[i].mk)continue;
		edge[i^1].mk=1;
		v=edge[i].v;
		dfs2(v);
	}
	EE[u]=nn-1;
}
vector<int>qry[100005];
void get_data(){
	fill(head,-1);en=0;
	cin>>N>>Q;
	int u,v;
	FR(i,N-1){
		cin>>u>>v;u--;v--;
		insert(u,v);
		insert(v,u);
	}
	FR(i,N)qry[i].clear();
	nn=0;
	dfs2(0);
	int a,b;
	FR(i,Q){
		cin>>a>>b;a--;b--;
		qry[a].PB(b);
		qry[b].PB(a);
	}
}
struct Node{
	int s,e,v,cnt;
};
Node nd[400005];
int res[100005];
void bd_t(int l,int s,int e){
	nd[l].s=s;nd[l].e=e;nd[l].v=0;nd[l].cnt=0;
	if(s==e)return;
	int mid=(s+e)>>1;
	bd_t(l<<1,s,mid);
	bd_t(l<<1|1,mid+1,e);
}
void f_insert(int l,int s,int e,int ad){
	if(nd[l].s==s&&nd[l].e==e){
		nd[l].v+=ad;
		if(nd[l].v)nd[l].cnt=e-s+1;
		else nd[l].cnt=0;
		return;
	}
	int mid=(nd[l].s+nd[l].e)>>1;
	if(e<=mid)f_insert(l<<1,s,e,ad);
	else if(s>mid)f_insert(l<<1|1,s,e,ad);
	else{
		f_insert(l<<1,s,mid,ad);
		f_insert(l<<1|1,mid+1,e,ad);
	}
	if(nd[l].v)nd[l].cnt=nd[l].e-nd[l].s+1;
	else nd[l].cnt=nd[l<<1].cnt+nd[l<<1|1].cnt;
}
void dfs(int u){
	int i,v;
	if(qry[u].size()){
		for(i=0;i<qry[u].size();i++){
			v=qry[u][i];
			f_insert(1,SS[v],EE[v],1);
		}
		f_insert(1,SS[u],EE[u],1);
	}
	res[u]=nd[1].cnt;
	if(res[u])res[u]--;
	for(i=head[u];i!=-1;i=edge[i].next){
		if(edge[i].mk)continue;
		v=edge[i].v;
		dfs(v);
	}
	if(qry[u].size()){
		f_insert(1,SS[u],EE[u],-1);
		for(i=qry[u].size()-1;i>=0;i--){
			v=qry[u][i];
			f_insert(1,SS[v],EE[v],-1);
		}

	}
}
void run(){
	fill(res,0);
	bd_t(1,0,N-1);
	dfs(0);
	FR(i,N)printf("%d ",res[i]);
	printf("\n");
}
int main(){
//	get_prime();
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	get_data();
	run();
	return 0;
}


/*
ID: nbuacm09
LANG: C++
TASK: cryptcow
*/
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;
//#define BIGINTEGER
//#define PRIME
//#define GEOMETRY
template<class T> T f_min(T x,T y){return x<y?x:y;}
template<class T> T f_max(T x,T y){return x>y?x:y;}
template<class T> T f_abs(T x){return x<0?-x:x;}
template<class T> T gcd(T x,T y){while(T t=x%y)x=y,y=t;return y;}
const double eps = 1e-9;
const double PI = acos(-1.);
const int INF = 1000000000;
const int MOD = 1000000007;
const double E = 2.7182818284590452353602874713527;

#define pmul(x1,y1,x2,y2) ((x1)*(x2)+(y1)*(y2))
#define xmul(x1,y1,x2,y2) ((x1)*(y2)-(x2)*(y1))
#define sqr(x) ((x)*(x))

#define FR(i,N) for(int i=0;i<N;i++)
#define FRS(i,S,E) for(int i=S;i<=E;i++)
#define FRD(i,S,E) for(int i=S;i>=E;i--)
#define SZ(x) ((int)(x).size())
#define fill(a,b) memset(a,b,sizeof(a));
#define MP(a,b) make_pair(a,b)
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define PB push_back
#define lowbit(x) ((x)&(-(x)))

bool isdig(char x){return x>='0'&&x<='9';}
bool isup(char x){return x>='A'&&x<='Z';}
bool isdown(char x){return x>='a'&&x<='z';}
bool islet(char x){return isup(x)||isdown(x);}
#ifdef BIGINTEGER
//big integer +
struct Bint{
	int v[2005],l;
	void set(int x){
		l=0;
		while(x)v[l++]=x%10,x/=10;
	}
	void get(){
		char s[1005];
		scanf("%s",s);
		l=strlen(s);
		FR(i,l)v[i]=s[l-1-i]-'0';
	}
	Bint friend operator+(Bint &a,Bint &b){
		Bint r;
		r.l=f_max(a.l,b.l);
		FR(i,r.l){
			r.v[i]=0;
			if(i<a.l)r.v[i]+=a.v[i];
			if(i<b.l)r.v[i]+=b.v[i];
		}
		FR(i,r.l){
			if(r.v[i]>=10){
				if(i+1==r.l)r.v[r.l++]=0;
				r.v[i+1]++;
				r.v[i]-=10;
			}
		}
		return r;
	}
	void disp(){
		FR(i,l)cout<<v[l-1-i];
		cout<<endl;
	}
};
#endif
#ifdef PRIME
//get prime under PRIMEN
#define PRIMEN 10000000
bool unprime[PRIMEN+5];
ll prime[PRIMEN+5],pn;
void get_prime(){
	fill(unprime,0);pn=0;
	unprime[1]=1;
	FRS(i,2,PRIMEN+5){
		if(unprime[i])continue;
		prime[pn++]=i;
		if(i>40000)continue;
		for(int j=i*i;j<PRIMEN+5;j+=i)unprime[j]=1;
	}
}
ll fac[105];
int fn,cnt[105];
void get_fac(ll x){
	fn=0;
	for(int i=0;i<pn&&prime[i]*prime[i]<=x;i++){
		if(x%prime[i])continue;
		cnt[fn]=0;
		fac[fn]=prime[i];
		while(x%prime[i]==0){
			x/=prime[i];
			cnt[fn]++;
		}
		fn++;
	}
	if(x>1){
		fac[fn]=x;
		cnt[fn++]=1;
	}
}
#endif
#ifdef GEOMETRY
//-------GEOMETRY-------
struct Point{
	double x,y;
	Point(){}
	Point(double _x,double _y){x=_x;y=_y;}
};
struct Line{
	Point s,e;
	Line(){}
	Line(Point _s,Point _e){s=_s;e=_e;}
	double dis(){
		return sqrt(sqr(e.x-s.x)+sqr(e.y-s.y));
	}
};
double x_mul(Line a,Line b){
	double x1,y1,x2,y2;
	x1=a.e.x-a.s.x;
	y1=a.e.y-a.s.y;
	x2=b.e.x-b.s.x;
	y2=b.e.y-b.s.y;
	return x1*y2-x2*y1;
}
double p_mul(Line a,Line b){
	double x1,y1,x2,y2;
	x1=a.e.x-a.s.x;
	y1=a.e.y-a.s.y;
	x2=b.e.x-b.s.x;
	y2=b.e.y-b.s.y;
	return x1*x2+y1*y2;
}
void rotate(double &x,double &y,double ang){
	double tx,ty;
	tx=x*cos(ang)-y*sin(ang);
	ty=y*cos(ang)+x*sin(ang);
	x=tx;y=ty;
}
#endif

//--------CODE----------
struct Edge{
	int u,v,next;
	bool mk;
};
Edge edge[200005];
int head[100005],en;
int num[100005],nn,SS[100005],EE[100005];
int N,Q;
void insert(int u,int v){
	edge[en].u=u;edge[en].v=v;
	edge[en].next=head[u];head[u]=en++;
}
void dfs2(int u){
	int i,v;
	num[nn++]=u;SS[u]=nn-1;
	for(i=head[u];i!=-1;i=edge[i].next){
		if(edge[i].mk)continue;
		edge[i^1].mk=1;
		v=edge[i].v;
		dfs2(v);
	}
	EE[u]=nn-1;
}
vector<int>qry[100005];
void get_data(){
	fill(head,-1);en=0;
	cin>>N>>Q;
	int u,v;
	FR(i,N-1){
		cin>>u>>v;u--;v--;
		insert(u,v);
		insert(v,u);
	}
	FR(i,N)qry[i].clear();
	nn=0;
	dfs2(0);
	int a,b;
	FR(i,Q){
		cin>>a>>b;a--;b--;
		qry[a].PB(b);
		qry[b].PB(a);
	}
}
struct Node{
	int s,e,v,cnt;
};
Node nd[400005];
int res[100005];
void bd_t(int l,int s,int e){
	nd[l].s=s;nd[l].e=e;nd[l].v=0;nd[l].cnt=0;
	if(s==e)return;
	int mid=(s+e)>>1;
	bd_t(l<<1,s,mid);
	bd_t(l<<1|1,mid+1,e);
}
void f_insert(int l,int s,int e,int ad){
	if(nd[l].s==s&&nd[l].e==e){
		nd[l].v+=ad;
		if(nd[l].v)nd[l].cnt=e-s+1;
		else nd[l].cnt=0;
		return;
	}
	int mid=(nd[l].s+nd[l].e)>>1;
	if(e<=mid)f_insert(l<<1,s,e,ad);
	else if(s>mid)f_insert(l<<1|1,s,e,ad);
	else{
		f_insert(l<<1,s,mid,ad);
		f_insert(l<<1|1,mid+1,e,ad);
	}
	if(nd[l].v)nd[l].cnt=nd[l].e-nd[l].s+1;
	else nd[l].cnt=nd[l<<1].cnt+nd[l<<1|1].cnt;
}
void dfs(int u){
	int i,v;
	if(qry[u].size()){
		for(i=0;i<qry[u].size();i++){
			v=qry[u][i];
			f_insert(1,SS[v],EE[v],1);
		}
		f_insert(1,SS[u],EE[u],1);
	}
	res[u]=nd[1].cnt;
	if(res[u])res[u]--;
	for(i=head[u];i!=-1;i=edge[i].next){
		if(edge[i].mk)continue;
		v=edge[i].v;
		dfs(v);
	}
	if(qry[u].size()){
		f_insert(1,SS[u],EE[u],-1);
		for(i=0;i<qry[u].size();i++){
			v=qry[u][i];
			f_insert(1,SS[v],EE[v],-1);
		}

	}
}
void run(){
	fill(res,0);
	bd_t(1,0,N-1);
	dfs(0);
	FR(i,N)printf("%d ",res[i]);
	printf("\n");
}
int main(){
//	get_prime();
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	get_data();
	run();
	return 0;
}


#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <set>

#define SIZE(A) ((int)A.size())
#define LENGTH(A) ((int)A.length())
#define MP(A,B) make_pair(A,B)
#define PB(A) push_back(A)

typedef long long ll;
typedef double ld;

using namespace std;

const int MAXN = 200000;
const int K = 400;

int n, m;
int d[MAXN];
vector <int> ed[MAXN], sp[MAXN];

int add[MAXN/K];
int pro[MAXN/K];
int v[MAXN];
int pmod[MAXN], pdiv[MAXN];

int curt;
int l[MAXN], r[MAXN];

void prec(int u, int pred)
{
    l[u] = r[u] = curt++;
    for (int i = 0; i < SIZE(ed[u]); i++)
    {
        int v = ed[u][i];
        if (v == pred) continue;

        prec(v, u);
        r[u] = curt-1;
    }
}

void mod(int l, int r, int x)
{
    for (; l<=r && pmod[l]!=0; l++)
    {
        v[l] += x;
        if (v[l]==0)
            pro[pdiv[l]]++;
        else
        if (v[l]==1&&x==1)
            pro[pdiv[l]]--;
    }
    for (; pdiv[l]<pdiv[r]; l+=K)
        add[pdiv[l]] += x;
    for (; l<=r; l++)
    {
        v[l]+=x;
        if (v[l]==0)
            pro[pdiv[l]]++;
        else
        if (v[l]==1&&x==1)
            pro[pdiv[l]]--;
    }
}

int sum(int i)
{
    int res = n;
    for (int it = 0; it <= pdiv[n-1]; it++)
        if (!add[it])
            res -= pro[it];
    if (add[pdiv[i]] || v[i])
        res--;
    return res;
}

void dfs(int u, int pred)
{
    if (SIZE(sp[u]))
    {
        mod(l[u], r[u], 1);
        for (int i = 0; i < SIZE(sp[u]); i++)
            mod(l[sp[u][i]], r[sp[u][i]], 1);
    }

    d[u] = sum(l[u]);

    for (int i = 0; i < SIZE(ed[u]); i++)
    {
        int v = ed[u][i];
        if (v == pred) continue;

        dfs(v, u);
    }

    if (SIZE(sp[u]))
    {
        mod(l[u], r[u], -1);
        for (int i = 0; i < SIZE(sp[u]); i++)
            mod(l[sp[u][i]], r[sp[u][i]], -1);
    }
}

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

    scanf("%d%d", &n, &m);
    for (int i = 1; i < n; i++)
    {
        int u=0, v=0;
        scanf("%d%d", &u, &v);
        ed[u].PB(v);
        ed[v].PB(u);
    }

    prec(1, 0);

    for (int i = 0; i < 2*n; i++)
        pmod[i] = i%K, pdiv[i] = i/K;
    for (int i = 0; i <= (n-1)/K; i++)
        pro[i] = min(K, n-i*K);

    for (int i = 0; i < m; i++)
    {
        int u=0, v=0;
        scanf("%d%d", &u, &v);
        sp[u].PB(v);
        sp[v].PB(u);
    }

    dfs(1, 0);

    for (int i = 1; i <= n; i++)
        printf("%d%c", d[i], " \n"[i==n]);

    return 0;
}


#include<stdio.h>
#include<vector>
using namespace std;
int n,m;
vector<int> e[111111];
int l[111111],r[111111];
vector<int> in[111111],ou[111111];
int A[111111],B[111111];
int o[111111],tim;
int out[111111];
void dfs(int x,int y){
	o[++tim]=x;
	l[x]=tim;
	for(vector<int>::iterator it=e[x].begin(); it!=e[x].end(); it++)
		if(y!=*it)
			dfs(*it,x);
	r[x]=tim;
}

struct segTree{
	int sum,num;
} a[111111*4];

void add(int i,int l,int r,int s,int e,int x){
	if(l==s && r==e)
		a[i].num+=x;
	else{
		int m=(l+r)/2;
		if(e<=m)add(i*2,l,m,s,e,x);else
		if(s>m)add(i*2+1,m+1,r,s,e,x);else{
			add(i*2,l,m,s,m,x);
			add(i*2+1,m+1,r,m+1,e,x);
		}
	}

	if(a[i].num){
		a[i].sum=r-l+1;
		return;
	}
	if(l==r)
		a[i].sum=0;
	else
		a[i].sum=a[i*2].sum+a[i*2+1].sum;
}

int main(){
	scanf("%d%d",&n,&m);
	for(int i=1; i<n; i++){
		int x,y;
		scanf("%d%d",&x,&y);
		e[x].push_back(y);
		e[y].push_back(x);
	}
	dfs(1,1);
	for(int i=1; i<=m; i++){
		scanf("%d%d",&A[i],&B[i]);
		int l1=l[A[i]],r1=r[A[i]],l2=l[B[i]],r2=r[B[i]];
		in[l1].push_back(i);
		in[l2].push_back(i);
		ou[r1].push_back(i);
		ou[r2].push_back(i);
	}
	for(int t=1; t<=n; t++){
		for(vector<int>::iterator it=in[t].begin(); it!=in[t].end(); it++){
			int i=*it;
			int l1=l[A[i]],r1=r[A[i]],l2=l[B[i]],r2=r[B[i]];
			add(1,1,n,l1,r1,1);
			add(1,1,n,l2,r2,1);
		}
		out[o[t]]=a[1].sum?a[1].sum-1:0;
		for(vector<int>::iterator it=ou[t].begin(); it!=ou[t].end(); it++){
			int i=*it;
			int l1=l[A[i]],r1=r[A[i]],l2=l[B[i]],r2=r[B[i]];
			add(1,1,n,l1,r1,-1);
			add(1,1,n,l2,r2,-1);
		}
	}
	for(int i=1; i<=n; i++)
		printf("%d%c",out[i],i<n?' ':'\n');
	return 0;
}


#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <list>
#include <iomanip>
#include <stack>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cassert>

#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
#define forn(i,n) for(int i = 0; i < int(n); ++i)

using namespace std;

typedef long long li;
typedef long double ld;

typedef pair<int,int> pt;
#define ft first
#define sc second

const int N = 100005;

int n, m;
vector <int> g[N], q[N];

bool read() {
    if (!(cin >> n >> m))
        return false;
    forn(i, n-1) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    forn(i, m) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        q[a].pb(b);
        q[b].pb(a);
    }
    return true;
}

int l[N], r[N], T;

void dfs(int v) {
    l[v] = r[v] = T++;
    forn(i, g[v].size()) {
        int to = g[v][i];
        if (l[to] == -1) {
            dfs(to);
            r[v] = r[to];
        }
    }
}

pt st[N * 4];
int upd[N * 4];

pt merge(pt a, pt b) {
    if (a.ft == b.ft)
        return mp(a.ft, a.sc + b.sc);
    else
        return min(a, b);
}

void push(int v, int l, int r) {
    if (upd[v] != 0) {
        st[v].ft += upd[v];
        if (l != r) {
            upd[v*2+1] += upd[v];
            upd[v*2+2] += upd[v];
        }
        upd[v] = 0;
    }
}

void update(int v, int l, int r, int L, int R, int val) {
    push(v, l, r);
    if (L == l && R == r) {
        upd[v] += val;
        return;
    }

    int m = (l + r) >> 1;
    if (R <= m)
        update(v*2 + 1, l, m, L, R, val);

    if (L > m)
        update(v*2 + 2, m+1, r, L, R, val);

    if (L <= m && R > m)
        update(v*2 + 1, l, m, L, m, val),
        update(v*2 + 2, m+1, r, m+1, R, val);

    push(v*2 + 1, l, m);
    push(v*2 + 2, m+1, r);

    st[v] = merge(st[v*2 + 1], st[v*2 + 2]);
}

void build(int v, int l, int r) {
    if (l == r) {
        st[v] = mp(0, 1);
        return;
    }

    int m = (l + r) >> 1;
    build(v*2 + 1, l, m);
    build(v*2 + 2, m+1, r);

    st[v] = merge(st[v*2 + 1], st[v*2 + 2]);
}

pt get(int v, int l, int r, int L, int R) {
    push(v, l, r);
    if (l == L && r == R)
        return st[v];

    int m = (l + r) >> 1;

    if (R <= m)
        return get(v*2 + 1, l, m, L, R);

    if (L > m)
        return get(v*2 + 2, m+1, r, L, R);

    if (L <= m && R > m)
        return merge(
                get(v*2 + 1, l, m, L, m),
                get(v*2 + 2, m+1, r, m+1, R)
            );
}

int ans[N];

void dfs2(int v) {
    forn(i, q[v].size()) {
        int u = q[v][i];
        update(0, 0, T-1, l[v], r[v], +1);
        update(0, 0, T-1, l[u], r[u], +1);
    }

    pt p = get(0, 0, T-1, 0, T-1);
    int c = T;
    if (p.ft == 0)
        c -= p.sc;

    ans[v] = max(c-1, 0);

    forn(i, g[v].size()) {
        int to = g[v][i];
        if (l[v] < l[to])
            dfs2(to);
    }

    forn(i, q[v].size()) {
        int u = q[v][i];
        update(0, 0, T-1, l[v], r[v], -1);
        update(0, 0, T-1, l[u], r[u], -1);
    }
}

void solve() {
    memset(l, -1, sizeof(l));
    dfs(0);
    build(0, 0, T-1);
    dfs2(0);
    forn(i, n)
        cout << ans[i] << " ";
}

int main() {
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif

#ifdef TASK_NAME
    freopen(TASK_NAME ".in", "r", stdin);
    freopen(TASK_NAME ".out", "w", stdout);
#endif

    while (read())
        solve();

    return 0;
}


#include <iostream>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <ctime>
#pragma comment(linker, "/STACK:256000000")

using namespace std;

const int maxN = 101000;

pair<int, int> t[4 * maxN];
int add[4 * maxN];
int sum[4 * maxN];

pair<int, int> merge(pair<int, int> a, pair<int, int> b) {
  if (a.first < b.first) {
    return a;
  }
  if (a.first > b.first) {
    return b;
  }
  return make_pair(a.first, a.second + b.second);
}

void build(int v, int cl, int cr) {
  if (cl == cr) {
    t[v] = make_pair(0, 1);
    return;
  }
  int mid = (cl + cr) / 2;
  build(2 * v, cl, mid);
  build(2 * v + 1, mid + 1, cr);
  t[v] = merge(t[2 * v], t[2 * v + 1]);
}

void push(int v, int cl, int cr) {
  int mid = (cl + cr) / 2;
  add[2 * v] += add[v];
  add[2 * v + 1] += add[v];
  sum[2 * v] += add[v] * (mid - cl + 1);
  sum[2 * v + 1] += add[v] * (cr - mid);
  add[v] = 0;
}

void update(int v, int cl, int cr, int tl, int tr, int value) {
  if (cl == tl && cr == tr) {
    add[v] += value;
    sum[v] += value * (tr - tl + 1);
    t[v].first += value;
    return;
  }
  int mid = (cl + cr) / 2;
  push(v, cl, cr);
  if (tl > mid) {
    update(2 * v + 1, mid + 1, cr, tl, tr, value);
  } else
  if (tr <= mid) {
    update(2 * v, cl, mid, tl, tr, value);
  } else {
    update(2 * v, cl, mid, tl, mid, value);
    update(2 * v + 1, mid + 1, cr, mid + 1, tr, value);
  }
  t[v] = merge(t[2 * v], t[2 * v + 1]);
}

pair<int, int> get(int v, int cl, int cr, int tl, int tr) {
  if (cl == tl && cr == tr) {
    return t[v];
  }
  int mid = (cl + cr) / 2;
  push(v, cl, cr);
  if (tl > mid) return get(2 * v + 1, mid + 1, cr, tl, tr);
  if (tr <= mid) return get(2 * v, cl, mid, tl, tr);
  return merge(get(2 * v, cl, mid, tl, mid), get(2 * v + 1, mid + 1, cr, mid + 1, tr));
}

vector <int> g[maxN];
vector <int> opers[maxN];
vector <int> cols[maxN];
int n, m;

vector <int> order;
int inv[maxN];
int l[maxN], r[maxN];

void dfs(int v, int p = -1) {
  order.push_back(v);
  l[v] = v;
  for (int i = 0; i < g[v].size(); ++i) {
    if (g[v][i] != p) {
      dfs(g[v][i], v);
    }
  }
  r[v] = v;
  for (int i = 0; i < g[v].size(); ++i) {
    if (g[v][i] != p) {
      r[v] = r[g[v][i]];
    }
  }
}

int res[maxN];

void dfs2(int v, int p = -1) {
  for (int i = 0; i < opers[v].size(); ++i) {
    int ccol = opers[v][i];
    for (int j = 0; j < cols[ccol].size(); ++j) {
      int t = cols[ccol][j];
      update(1, 0, n - 1, l[t], r[t], +1);
    }
  }
  pair<int, int> cres = get(1, 0, n - 1, 0, n - 1);
  res[v] = cres.second;

  for (int i = 0; i < g[v].size(); ++i) {
    if (g[v][i] != p) {
      dfs2(g[v][i], v);
    }
  }

  for (int i = 0; i < opers[v].size(); ++i) {
    int ccol = opers[v][i];
    for (int j = 0; j < cols[ccol].size(); ++j) {
      int t = cols[ccol][j];
      update(1, 0, n - 1, l[t], r[t], -1);
    }
  }
}

int main() {
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);

  scanf("%d%d", &n, &m);
  build(1, 0, n - 1);
  for (int i = 1; i < n; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    g[x].push_back(y);
    g[y].push_back(x);
  }

  dfs(1);
  for (int i = 0; i < order.size(); ++i) {
    inv[order[i]] = i;
  }
  for (int i = 1; i <= n; ++i) {
    l[i] = inv[l[i]];
    r[i] = inv[r[i]];
  }

  for (int i = 0; i < m; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    cols[i].push_back(x);
    cols[i].push_back(y);
    opers[x].push_back(i);
    opers[y].push_back(i);
  }

  dfs2(1);
  for (int i = 1; i <= n; ++i) {
    int val = n - res[i];
    if (val > 0) --val;
    printf("%d ", val);
  }
  printf("\n");

  return 0;
}