//#define _GLIBCXX_DEBUG
//#include <atcoder/all>
#include <bits/stdc++.h>
#include <chrono>
#include <random>



using namespace std;
//using namespace atcoder;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
//const ll MOD=1000000007;
const ll MOD=998244353;
//using mint = modint998244353;
//using mint = modint1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);
int dx[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};
int dy[9] = {0, 1, 0, -1, 1, -1, -1, 1, 0};

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


//https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a

ll mod_pow(long long x, long long n) {
    long long ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * x % MOD;  // n の最下位bitが 1 ならば x^(2^i) をかける
        x = x * x % MOD;
        n >>= 1;  // n を1bit 左にずらす
    }
    return ret;
}


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // cout << fixed << setprecision(15);

  ll N,K; cin>>N>>K;
  vector<ll> A(N); rep(i,N) cin>>A[i];
  
  vector<vector<ll>> pascal(1,{1});
  for(int i=1;i<=K;i++){
    vector<ll> vec={};
    rep(j,i+1){
      if(j==0||j==i) {vec.push_back(1); continue;}
      vec.push_back((pascal[i-1][j-1]+pascal[i-1][j])%MOD);
    }
    pascal.push_back(vec);
  }
  /*
  for(auto v:pascal){
    rep(i,v.size()){
      if(i!=0) cout<<' ';
      cout<<v[i];
    }
    cout<<'\n';
  }
  */
  vector<ll> run(K+1,0);
  rep(i,N){
    ll a=1;
    rep(_,K+1){
      run[_]=(run[_]+a)%MOD;
      a=a*A[i]%MOD;
    }
  }
  for(int X=1;X<=K;X++){
    auto l=pascal[X];
    ll ans=0;
    rep(i,X+1){
      ll sans=0;
      ll AA=run[X-i];
      ll B=run[i];
      ll C=run[X];
      sans=l[i]*(AA*B%MOD-C)%MOD;
      if(X%2==0&&i==X/2) sans=sans*mod_pow(2,MOD-2)%MOD;
      if(i>X/2) break;
      if(sans<0) sans+=MOD;
      ans=(ans+sans)%MOD;
    }
    cout<<ans<<'\n';
  }
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T,class U>
inline bool chmax(T &a,U b){
    if(a<b){
        a=b;
        return true;
    }
    return false;
}
template<class T,class U>
inline bool chmin(T &a,U b){
    if(a>b){
        a=b;
        return true;
    }
    return false;
}
constexpr int INF=1000000000;
constexpr ll llINF=3000000000000000000;
constexpr int mod=998244353;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
/*
vector<vector<ll>>C,sC;
void init_comb(int n,int m){
    C.resize(n+1,vector<ll>(m+1,0));
    sC.resize(n+1,vector<ll>(m+1,0));
    C[0][0]=1;
    for(int i=1;i<=n;i++){
        C[i][0]=1;
        for(int j=1;j<=m;j++){
            C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
        }
    }
    rep(i,n+1){
        rep(j,m){
            sC[i][j+1]=(sC[i][j]+C[i][j])%mod;
        }
    }
}*/
ll gcd(ll a,ll b){
    while(a%b){
        a%=b;
        swap(a,b);
    }
    return b;
}
ll lcm(ll a,ll b){
    return a/gcd(a,b)*b;
}
bool isprime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
vector<int>primes;
void init_prime(int n){
	primes.push_back(2);
    for(int i=3;i<=n;i+=2){
        bool f=true;
        for(int j:primes){
            if(j*j>i)break;
            if(i%j==0){
                f=false;
                break;
            }
        }
        if(f)primes.push_back(i);
    }
}
ll modpow(ll a,ll b){
    ll res=1;
    while(b){
        if(b&1){
            res*=a;
            res%=mod;
        }
        a*=a;
        a%=mod;
        b>>=1;
    }
    return res;
}
vector<ll>inv,fact,factinv;
void init_fact(int n){
    inv.resize(n+1);
    fact.resize(n+1);
    factinv.resize(n+1);
    inv[0]=0;
    inv[1]=1;
    fact[0]=1;
    factinv[0]=1;
    for(ll i=1;i<=n;i++){
        if(i>=2)inv[i]=mod-((mod/i)*inv[mod%i]%mod);
        fact[i]=(fact[i-1]*i)%mod;
        factinv[i]=factinv[i-1]*inv[i]%mod;
    }
}
ll _inv(ll a,ll m=mod){
    //gcd(a,m) must be 1
    ll b=m,u=1,v=0;
    while(b){
        ll t=a/b;
        a-=t*b;swap(a,b);
        u-=t*v;swap(u,v);
    }
    u%=m;
    if(u<0)u+=m;
    return u;
}
ll comb(int a,int b){
    if(a<b)return 0;
    if(a<0)return 0;
    return fact[a]*factinv[a-b]%mod*factinv[b]%mod;
}
ll multicomb(int a,int b){
    return comb(a+b-1,b);
}
int n,k,dp[200010],res,dmax;
vector<int>g[200010];
void dfs(int x,int p){
    dp[x]=0;
    for(int i:g[x]){
        if(i!=p){
            dfs(i,x);
            if(dp[i]+1>dmax)res++;
            else if(dp[i]+1+dp[x]<=dmax)chmax(dp[x],dp[i]+1);
            else{
                res++;
                chmin(dp[x],dp[i]+1);
            }
        }
    }
}
bool check(int x){
    res=0,dmax=x*2;
    dfs(0,-1);
    return res<k;
}
void solve(){
    cin>>n>>k;
    rep(i,n-1){
        int a,b;
        cin>>a>>b;
        a--,b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int ok=n,ng=0;
    while(ok-ng>1){
        int m=(ok+ng)>>1;
        if(check(m))ok=m;
        else ng=m;
    }
    cout<<ok<<endl;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    //int t;cin>>t;while(t--)
    solve();
    return 0;
}