#include<bits/stdc++.h>
using namespace std;

const int N = 1e6 + 7;

int fa[N][21];
vector<int> G[N];
bool vis[N];
int dep[N];

void init()
{
    for(int i = 0;i < N;i ++)
        G[i].clear();
    memset(vis,0,sizeof(vis));
}

void dfs(int u,int f,int d)
{
    fa[u][0] = f;
    dep[u] = d;
    for(int i = 1;i <= 20;i ++)
        fa[u][i] = fa[fa[u][i - 1]][i - 1];
    for(auto v : G[u])
    {
        if(v == f)
            continue;
        dfs(v,u,d + 1);
    }
}

int go(int u)
{
    for(int i = 20;i >= 0;i --)
        if(!vis[fa[u][i]])
            u = fa[u][i];
    return u;
}

int main()
{
    int n,k;
    while(cin >> n >> k)
    {
        init();
        for(int i = 1;i < n;i ++)
        {
            int u,v;
            cin >> u >> v;
            G[u].push_back(v);
            G[v].push_back(u);
        }
        dfs(n,n,0);
        k --;
        vis[n] = 1;
        for(int i = n - 1;i >= 1;i --)
        {
            int pre = go(i);
            if(dep[i] - dep[pre] + 1 > k)
                continue;
            k -= (dep[i] - dep[pre] + 1);
            int r = i;
            while(!vis[r])
            {
                vis[r] = 1;
                r = fa[r][0];
            }
        }
        vector<int> anc;
        for(int i = 1;i <= n;i ++)
        {
            if(!vis[i])
                anc.push_back(i);
        }
        for(int i = 0;i < anc.size();i ++)
        {
            if(i)
                cout << " ";
            cout << anc[i];
        }
        cout << endl;
    }
}


#include<bits/stdc++.h>
using namespace std;

const int N = 1e6 + 7;

int fa[N][21];
vector<int> G[N];
bool vis[N];
int dep[N];

void init()
{
    for(int i = 0;i < N;i ++)
        G[i].clear();
    memset(vis,0,sizeof(vis));
}

void dfs(int u,int f,int d)
{
    fa[u][0] = f;
    dep[u] = d;
    for(int i = 1;i <= 20;i ++)
        fa[u][i] = fa[fa[u][i - 1]][i - 1];
    for(auto v : G[u])
    {
        if(v == f)
            continue;
        dfs(v,u,d + 1);
    }
}

int go(int u)
{
    for(int i = 20;i >= 0;i --)
        if(!vis[fa[u][i]])
            u = fa[u][i];
    return u;
}

int main()
{
    int n,k;
    while(cin >> n >> k)
    {
        init();
        for(int i = 1;i < n;i ++)
        {
            int u,v;
            cin >> u >> v;
            G[u].push_back(v);
            G[v].push_back(u);
        }
        dfs(n,n,0);
        k = n - k;
        vis[n] = 1;
        k --;
        for(int i = n - 1;i >= 1;i --)
        {
            int pre = go(i);
            if(dep[i] - dep[pre] + 1 > k)
                continue;
            k -= (dep[i] - dep[pre] + 1);
            int r = i;
            while(!vis[r])
            {
                vis[r] = 1;
                r = fa[r][0];
            }
        }
        vector<int> anc;
        for(int i = 1;i <= n;i ++)
        {
            if(!vis[i])
                anc.push_back(i);
        }
        for(int i = 0;i < anc.size();i ++)
        {
            if(i)
                cout << " ";
            cout << anc[i];
        }
        cout << endl;
    }
}


#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;
const int maxn=1e6+10;
int n,k;
vector<int> G[maxn];
int f[maxn][25];
bool vis[maxn];
void dfs(int u,int fa) {
    f[u][0]=fa;
    for (int i=0;i<=20;i++) f[u][i+1]=f[f[u][i]][i];
    int sz=G[u].size();
    for (int i=0;i<sz;i++) {
        int v=G[u][i];
        if (v==fa) continue;
        dfs(v,u);
    }
}
int main() {
    while (~scanf("%d%d",&n,&k)) {
        for (int i=1;i<=n;i++) G[i].clear();
        memset(vis,0,sizeof(vis));
        int u,v;
        for (int i=0;i<n-1;i++) {
            scanf("%d%d",&u,&v);
            G[u].push_back(v); G[v].push_back(u);
        }
        memset(f,0,sizeof(f));
        dfs(n,n);
        vis[n]=1;
        k=n-k-1;
        for (int i=n-1;i>=1;i--) {
            if (vis[i]) continue;
            int tmp=i;
            int sum=0;
            for (int j=21;j>=0;j--) {
                if (!vis[f[tmp][j]]) {
                    tmp=f[tmp][j];
                    sum+=(1<<j);
                }
            }
            sum++;
            if (sum<=k) {
                k-=sum;
                tmp=i;
                while (!vis[tmp]) {
                    vis[tmp]=1;
                    tmp=f[tmp][0];
                }
            }
        }
        for (int i=1;i<=n;i++) if (!vis[i]) printf("%d ", i);
        printf("\n");
    }
    return 0;
}


#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;
const int maxn=1e6+10;
int n,k,tot;
vector<int> G[maxn];
int dep[maxn],f[maxn],in[maxn],out[maxn];
int a[maxn];
bool vis[maxn];
inline void add(int x,int num) {
    for (;x<=n;x+=x&(-x)) a[x]+=num;
}
inline int getsum(int x) {
    int r=0;
    for (;x;x-=x&(-x)) r+=a[x];
    return r;
}
inline void addseg(int l,int r,int num) {
    add(l,num); add(r+1,-num);
}

void dfs(int u,int fa) {
    in[u]=++tot; f[u]=fa; dep[u]=dep[fa]+1;
    int sz=G[u].size();
    for (int i=0;i<sz;i++) {
        int v=G[u][i];
        if (v==fa) continue;
        dfs(v,u);
    }
    out[u]=tot;
}
int main() {
    while (~scanf("%d%d",&n,&k)) {
        tot=0;
        for (int i=1;i<=n;i++) G[i].clear();
        memset(vis,0,sizeof(vis));
        memset(dep,0,sizeof(dep));
        memset(a,0,sizeof(a));
        int u,v;
        for (int i=0;i<n-1;i++) {
            scanf("%d%d",&u,&v);
            G[u].push_back(v); G[v].push_back(u);
        }
        dfs(n,n);
        vis[n]=1;
        addseg(in[n],out[n],1);
        k=n-k-1;
        for (int i=n-1;i>=1;i--) {
            if (vis[i]) continue;
            int tmp=dep[i]-getsum(in[i]);
            if (tmp>k) continue;
            for (int j=i;!vis[j];j=f[j]) {
                addseg(in[j],out[j],1);
                vis[j]=1;
                k--;
            }
        }
        for (int i=1;i<=n;i++) if (!vis[i]) printf("%d ", i);
        printf("\n");
    }
    return 0;
}


#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
using namespace std;
const int inf=2e9+1e8;
const int maxn=1e6+10;
int n,k,tot,root;
int head[maxn],size[maxn],mxson[maxn],f[maxn],ans[maxn];
struct Node
{
    int num;
    bool operator <(const Node&n) const {
        return num>n.num;
    }
    Node() {}
    Node(int num):num(num) {}
};
struct Edge
{
    int v,nx;
}e[maxn<<1];
inline void add(int u,int v) {
    e[tot].v=v; e[tot].nx=head[u]; head[u]=tot++;
    e[tot].v=u; e[tot].nx=head[v]; head[v]=tot++;
}
void dfs_root(int u,int fa) {
    size[u]=1;
    for (int i=head[u];i!=-1;i=e[i].nx) {
        int v=e[i].v;
        if (v==fa) continue;
        dfs_root(v,u);
        size[u]+=size[v];
        mxson[u]=max(mxson[u],size[v]);
    }
    mxson[u]=max(mxson[u],n-size[u]);
    if (mxson[u]<mxson[0]) {
        mxson[0]=mxson[u];
        root=u;
    }
}
priority_queue<Node> q;
void dfs(int u,int fa) {
    size[u]=1;
    f[u]=fa;
    for (int i=head[u];i!=-1;i=e[i].nx) {
        int v=e[i].v;
        if (v==fa) continue;
        dfs(v,u);
        size[u]+=size[v];
    }
    if (size[u]==1) q.emplace(u);
}
int main() {
    while (~scanf("%d%d",&n,&k)) {
        tot=0;
        memset(head,-1,sizeof(head));
        int u,v;
        for (int i=0;i<n-1;i++) {
            scanf("%d%d",&u,&v);
            add(u,v);
        }
        memset(size,0,sizeof(size));
        memset(mxson,0,sizeof(mxson));
        mxson[0]=inf;
        dfs_root(1,0);

        memset(size,0,sizeof(size));
        while (!q.empty()) q.pop();
        dfs(root,0);
        // printf("root: %d\n", root);
        int cnt=0;
        while (!q.empty() && k--) {
            Node t=q.top(); q.pop();
            ans[++cnt]=t.num;
            if ((--size[f[t.num]])==1) q.emplace(f[t.num]);
        }
        sort(ans+1,ans+cnt);
        for (int i=1;i<=cnt;i++)
            printf("%d ", ans[i]);
        printf("\n");
    }
    return 0;
}


#include <cstdio>
#include <cstring>
#include <queue>
#include <set>
#include <algorithm>
using namespace std;
const int maxn=1e6+10;
int n,k,tot,root;
int ans[maxn];
set<int> G[maxn];
bool vis[maxn];

int main() {
    while (~scanf("%d%d",&n,&k)) {
        memset(vis,0,sizeof(vis));
        for (int i=1;i<=n;i++) G[i].clear();
        int u,v;
        for (int i=0;i<n-1;i++) {
            scanf("%d%d",&u,&v);
            G[u].emplace(v);
            G[v].emplace(u);
        }

        priority_queue<int,vector<int>,greater<int> > q;
        for (int i=1;i<=n;i++) {
            if (G[i].size()==1) {
                q.emplace(i);
                vis[i]=1;
            }
        }
        int cnt=0;
        while (!q.empty() && k--) {
            int u=q.top(); q.pop();
            ans[++cnt]=u;
            for (set<int>::iterator i=G[u].begin();i!=G[u].end();i++) {
                int v=*i;
                if (vis[v]) continue;
                G[v].erase(u);
                if (G[v].size()==1) {
                    q.emplace(v);
                    vis[v]=1;
                }
            }
        }
        sort(ans+1,ans+1+cnt);
        for (int i=1;i<=cnt;i++) printf("%d ", ans[i]);
        printf("\n");
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
vector<int> adjlist[1000005];
int level[1000005];
int parent[1000005];
bool addedsolution[1000005];
int binarylift[1000005][20];
int k,n;

void dfs(int v,int p,int lvl){
    //cout<<"VISITING "<<v+1<<endl;
    level[v]=lvl;
    for(vector<int>::iterator iter=adjlist[v].begin();iter!=adjlist[v].end();iter++){
        if(p!=*iter){
            parent[*iter]=v;
            //cout<<"PARENT["<<*iter+1<<"] "<<v+1<<endl;
            dfs(*iter,v,lvl+1);
        }
    }
}

void buildtable(){
    for(int i=0;i<n;i++){
        for(int j=0;j<20;j++){
            binarylift[i][j]=-1;
        }
    }
    for(int i=0;i<n-1;i++){
        binarylift[i][0]=parent[i];
    }
    for(int i=1;i<20;i++){
        for(int j=0;j<n;j++){
            if(binarylift[j][i-1]!=-1){
                binarylift[j][i]=binarylift[binarylift[j][i-1]][i-1];
            }
        }
    }
}

bool jump(int node,int j){
    int exp=0;
    while(j>0){
        if(j%2==1){
            node=binarylift[node][exp];
        }
        exp++;
        j/=2;
    }
    //cout<<"Ending jump at "<<node+1<<endl;
    return addedsolution[node];
}

int searchlca(int node){
    //cout<<"Searching lca for "<<node+1<<endl;
    /*int maxs=level[node];
    int mins=0;
    int mids=(maxs+mins)/2;
    while(maxs>mins){
        if(maxs==mins+1){
            if(jump(node,mins)){
                return mins;
            }
            else{
                return maxs;
            }
        }
        if(jump(node,mids)){
            maxs=mids;
        }
        else{
            mins=mids+1;
        }
        mids=(maxs+mins)/2;
    }
    return mids;*/
    int initnode=node;
    int jumping=(int)log2(level[node]);
    while(jumping>=0){
        //cout<<"Current node is "<<node+1<<" jumping is "<<jumping<<" jumping to "<<binarylift[node][jumping]+1<<endl;
        if(binarylift[node][jumping]!=-1&&addedsolution[binarylift[node][jumping]]){
            jumping--;
        }
        else{
            if(binarylift[node][jumping]!=-1){
                node=binarylift[node][jumping];
            }
            jumping--;
        }
    }
    node=binarylift[node][0];
    return level[initnode]-level[node];
}

int main(){
    scanf("%i %i",&n,&k);
    int end1,end2;
    for(int i=0;i<n-1;i++){
        scanf("%i %i",&end1,&end2);
        adjlist[end1-1].push_back(end2-1);
        adjlist[end2-1].push_back(end1-1);
    }
    int included=1;
    addedsolution[n-1]=true;
    dfs(n-1,n-1,0);
    buildtable();
    for(int i=n-2;i>=0;i--){
        int incl=searchlca(i);
        //cout<<"NODE "<<i+1<<" with distance "<<incl<<endl;
        if(included+incl<=n-k&&!addedsolution[i]){
            included+=incl;
            int j=i;
            while(!addedsolution[j]){
                //cout<<"ADDING "<<j+1<<endl;
                addedsolution[j]=true;
                j=parent[j];
            }
        }
    }
    for(int i=0;i<n;i++){
        if(!addedsolution[i]){
            printf("%i ",i+1);
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
vector<int> adjlist[1000005];
int level[1000005];
int parent[1000005];
bool addedsolution[1000005];
int binarylift[1000005][20];
int k,n;

void dfs(int v,int p,int lvl){
    level[v]=lvl;
    for(vector<int>::iterator iter=adjlist[v].begin();iter!=adjlist[v].end();iter++){
        if(p!=*iter){
            parent[*iter]=v;
            dfs(*iter,v,lvl+1);
        }
    }
}

void buildtable(){
    for(int i=0;i<n;i++){
        for(int j=0;j<20;j++){
            binarylift[i][j]=-1;
        }
    }
    for(int i=0;i<n;i++){
        binarylift[i][0]=parent[i];
    }
    for(int i=1;i<20;i++){
        for(int j=0;j<n;j++){
            if(binarylift[j][i-1]!=-1){
                binarylift[j][i]=binarylift[binarylift[j][i-1]][i-1];
            }
        }
    }
}

bool jump(int node,int j){
    int exp=0;
    while(j>0){
        if(j%2==1){
            node=binarylift[node][exp];
        }
        exp++;
        j/=2;
    }
    //cout<<"Ending jump at "<<node+1<<endl;
    return addedsolution[node];
}

int searchlca(int node){
    //cout<<"Searching lca for "<<node+1<<endl;
    int maxs=level[node];
    int mins=0;
    int mids=(maxs+mins)/2;
    while(maxs>mins){
        //cout<<"MAXS "<<maxs<<" MIDS "<<mids<<" MINS "<<mins<<endl;
        //cout<<"Jumping "<<mids<<endl;
        if(maxs==mins+1){
            if(jump(node,mins)){
                return mins;
            }
            else{
                return maxs;
            }
        }
        if(jump(node,mids)){
            maxs=mids;
        }
        else{
            mins=mids+1;
        }
        mids=(maxs+mins)/2;
    }
    return mids;
}

int main(){
    scanf("%i %i",&n,&k);
    int end1,end2;
    for(int i=0;i<n-1;i++){
        scanf("%i %i",&end1,&end2);
        adjlist[end1-1].push_back(end2-1);
        adjlist[end2-1].push_back(end1-1);
    }
    int included=1;
    addedsolution[n-1]=true;
    dfs(n-1,n-1,0);
    buildtable();
    for(int i=n-2;i>=0;i--){
        int incl=searchlca(i);
        //cout<<"Node is "<<i+1<<" distance is "<<incl<<endl;
        if(included+incl<=n-k){
            included+=incl;
            int j=i;
            while(!addedsolution[j]){
                //cout<<"ADDING "<<j+1<<endl;
                addedsolution[j]=true;
                j=parent[j];
            }
        }
    }
    for(int i=0;i<n;i++){
        if(!addedsolution[i]){
            printf("%i ",i+1);
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
vector<int> adjlist[1000005];
int level[1000005];
int parent[1000005];
bool addedsolution[1000005];
int binarylift[1000005][20];
int k,n;

void dfs(int v,int p,int lvl){
    //cout<<"VISITING "<<v+1<<endl;
    level[v]=lvl;
    for(vector<int>::iterator iter=adjlist[v].begin();iter!=adjlist[v].end();iter++){
        if(p!=*iter){
            parent[*iter]=v;
            //cout<<"PARENT["<<*iter+1<<"] "<<v+1<<endl;
            dfs(*iter,v,lvl+1);
        }
    }
}

void buildtable(){
    for(int i=0;i<n;i++){
        for(int j=0;j<20;j++){
            binarylift[i][j]=-1;
        }
    }
    for(int i=0;i<n;i++){
        binarylift[i][0]=parent[i];
    }
    for(int i=1;i<20;i++){
        for(int j=0;j<n;j++){
            if(binarylift[j][i-1]!=-1){
                binarylift[j][i]=binarylift[binarylift[j][i-1]][i-1];
            }
        }
    }
}

bool jump(int node,int j){
    int exp=0;
    while(j>0){
        if(j%2==1){
            node=binarylift[node][exp];
        }
        exp++;
        j/=2;
    }
    //cout<<"Ending jump at "<<node+1<<endl;
    return addedsolution[node];
}

int searchlca(int node){
    //cout<<"Searching lca for "<<node+1<<endl;
    /*int maxs=level[node];
    int mins=0;
    int mids=(maxs+mins)/2;
    while(maxs>mins){
        if(maxs==mins+1){
            if(jump(node,mins)){
                return mins;
            }
            else{
                return maxs;
            }
        }
        if(jump(node,mids)){
            maxs=mids;
        }
        else{
            mins=mids+1;
        }
        mids=(maxs+mins)/2;
    }
    return mids;*/
    int initnode=node;
    int jumping=(int)log2(level[node]);
    while(jumping>=0){
        if(addedsolution[binarylift[node][jumping]]){
            jumping--;
        }
        else{
            node=binarylift[node][jumping];
            jumping--;
        }
    }
    node=binarylift[node][0];
    return level[initnode]-level[node];
}

int main(){
    scanf("%i %i",&n,&k);
    int end1,end2;
    for(int i=0;i<n-1;i++){
        scanf("%i %i",&end1,&end2);
        adjlist[end1-1].push_back(end2-1);
        adjlist[end2-1].push_back(end1-1);
    }
    int included=1;
    addedsolution[n-1]=true;
    dfs(n-1,n-1,0);
    buildtable();
    for(int i=n-2;i>=0;i--){
        int incl=searchlca(i);
        //cout<<"NODE "<<i+1<<" with distance "<<incl<<endl;
        if(included+incl<=n-k&&!addedsolution[i]){
            included+=incl;
            int j=i;
            while(!addedsolution[j]){
                //cout<<"ADDING "<<j+1<<endl;
                addedsolution[j]=true;
                j=parent[j];
            }
        }
    }
    for(int i=0;i<n;i++){
        if(!addedsolution[i]){
            printf("%i ",i+1);
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
vector<int> adjlist[1000005];
int level[1000005];
int parent[1000005];
bool addedsolution[1000005];
int binarylift[1000005][20];
int k,n;

void dfs(int v,int p,int lvl){
    level[v]=lvl;
    for(vector<int>::iterator iter=adjlist[v].begin();iter!=adjlist[v].end();iter++){
        if(p!=*iter){
            parent[*iter]=v;
            dfs(*iter,v,lvl+1);
        }
    }
}

void buildtable(){
    for(int i=0;i<n;i++){
        for(int j=0;j<20;j++){
            binarylift[i][j]=-1;
        }
    }
    for(int i=0;i<n;i++){
        binarylift[i][0]=parent[i];
    }
    for(int i=1;i<20;i++){
        for(int j=0;j<n;j++){
            if(binarylift[j][i-1]!=-1){
                binarylift[j][i]=binarylift[binarylift[j][i-1]][i-1];
            }
        }
    }
}

bool jump(int node,int j){
    int exp=0;
    while(j>0){
        if(j%2==1){
            node=binarylift[node][exp];
        }
        exp++;
        j/=2;
    }
    //cout<<"Ending jump at "<<node+1<<endl;
    return addedsolution[node];
}

int searchlca(int node){
    //cout<<"Searching lca for "<<node+1<<endl;
    /*int maxs=level[node];
    int mins=0;
    int mids=(maxs+mins)/2;
    while(maxs>mins){
        if(maxs==mins+1){
            if(jump(node,mins)){
                return mins;
            }
            else{
                return maxs;
            }
        }
        if(jump(node,mids)){
            maxs=mids;
        }
        else{
            mins=mids+1;
        }
        mids=(maxs+mins)/2;
    }
    return mids;*/
    int initnode=node;
    int jumping=(int)log2(level[node]);
    while(jumping>=0){
        if(addedsolution[binarylift[node][jumping]]){
            jumping--;
        }
        else{
            node=binarylift[node][jumping];
        }
    }
    node=binarylift[node][0];
    return level[initnode]-level[node];
}

int main(){
    scanf("%i %i",&n,&k);
    int end1,end2;
    for(int i=0;i<n-1;i++){
        scanf("%i %i",&end1,&end2);
        adjlist[end1-1].push_back(end2-1);
        adjlist[end2-1].push_back(end1-1);
    }
    int included=1;
    addedsolution[n-1]=true;
    dfs(n-1,n-1,0);
    buildtable();
    for(int i=n-2;i>=0;i--){
        int incl=searchlca(i);
        if(included+incl<=n-k){
            included+=incl;
            int j=i;
            while(!addedsolution[j]){
                //cout<<"ADDING "<<j+1<<endl;
                addedsolution[j]=true;
                j=parent[j];
            }
        }
    }
    for(int i=0;i<n;i++){
        if(!addedsolution[i]){
            printf("%i ",i+1);
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
vector<int> adjlist[1000005];
int level[1000005];
int parent[1000005];
bool addedsolution[1000005];
int binarylift[1000005][20];
int k,n;

void dfs(int v,int p,int lvl){
    level[v]=lvl;
    for(vector<int>::iterator iter=adjlist[v].begin();iter!=adjlist[v].end();iter++){
        if(p!=*iter){
            parent[*iter]=v;
            dfs(*iter,v,lvl+1);
        }
    }
}

void buildtable(){
    for(int i=0;i<n;i++){
        for(int j=0;j<20;j++){
            binarylift[i][j]=-1;
        }
    }
    for(int i=0;i<n;i++){
        binarylift[i][0]=parent[i];
    }
    for(int i=1;i<20;i++){
        for(int j=0;j<n;j++){
            if(binarylift[j][i-1]!=-1){
                binarylift[j][i]=binarylift[binarylift[j][i-1]][i-1];
            }
        }
    }
}

bool jump(int node,int j){
    int exp=0;
    while(j>0){
        if(j%2==1){
            node=binarylift[node][exp];
        }
        exp++;
        j/=2;
    }
    //cout<<"Ending jump at "<<node+1<<endl;
    return addedsolution[node];
}

int searchlca(int node){
    //cout<<"Searching lca for "<<node+1<<endl;
    int maxs=level[node];
    int mins=0;
    int mids=(maxs+mins)/2;
    while(maxs>mins){
        //cout<<"MAXS "<<maxs<<" MIDS "<<mids<<" MINS "<<mins<<endl;
        //cout<<"Jumping "<<mids<<endl;
        if(maxs==mins+1){
            if(jump(node,mins)){
                return mins;
            }
            else{
                return maxs;
            }
        }
        if(jump(node,mids)){
            maxs=mids;
        }
        else{
            mins=mids+1;
        }
        mids=(maxs+mins)/2;
    }
    return mids;
}

int main(){
    cin>>n>>k;
    int end1,end2;
    for(int i=0;i<n-1;i++){
        cin>>end1>>end2;
        adjlist[end1-1].push_back(end2-1);
        adjlist[end2-1].push_back(end1-1);
    }
    int included=1;
    addedsolution[n-1]=true;
    dfs(n-1,n-1,0);
    buildtable();
    for(int i=n-2;i>=0;i--){
        int incl=searchlca(i);
        //cout<<"Node is "<<i+1<<" distance is "<<incl<<endl;
        if(included+incl<=n-k){
            included+=incl;
            int j=i;
            while(!addedsolution[j]){
                //cout<<"ADDING "<<j+1<<endl;
                addedsolution[j]=true;
                j=parent[j];
            }
        }
    }
    for(int i=0;i<n;i++){
        if(!addedsolution[i]){
            cout<<i+1<<" ";
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
vector<int> adjlist[1000005];
int level[1000005];
int parent[1000005];
bool addedsolution[1000005];
int binarylift[1000005][20];
int k,n;

void dfs(int v,int p,int lvl){
    level[v]=lvl;
    for(vector<int>::iterator iter=adjlist[v].begin();iter!=adjlist[v].end();iter++){
        if(p!=*iter){
            parent[*iter]=v;
            dfs(*iter,v,lvl+1);
        }
    }
}

void buildtable(){
    for(int i=0;i<n;i++){
        for(int j=0;j<20;j++){
            binarylift[i][j]=-1;
        }
    }
    for(int i=0;i<n;i++){
        binarylift[i][0]=parent[i];
    }
    for(int i=1;i<20;i++){
        for(int j=0;j<n;j++){
            if(binarylift[j][i-1]!=-1){
                binarylift[j][i]=binarylift[binarylift[j][i-1]][i-1];
            }
        }
    }
}

bool jump(int node,int j){
    int exp=0;
    while(j>0){
        if(j%2==1){
            node=binarylift[node][exp];
        }
        exp++;
        j/=2;
    }
    //cout<<"Ending jump at "<<node+1<<endl;
    return addedsolution[node];
}

int searchlca(int node){
    //cout<<"Searching lca for "<<node+1<<endl;
    /*int maxs=level[node];
    int mins=0;
    int mids=(maxs+mins)/2;
    while(maxs>mins){
        if(maxs==mins+1){
            if(jump(node,mins)){
                return mins;
            }
            else{
                return maxs;
            }
        }
        if(jump(node,mids)){
            maxs=mids;
        }
        else{
            mins=mids+1;
        }
        mids=(maxs+mins)/2;
    }
    return mids;*/
    int initnode=node;
    int jumping=(int)log2(level[node]);
    while(jumping>=0){
        if(addedsolution[binarylift[node][jumping]]){
            jumping--;
        }
        else{
            node=binarylift[node][jumping];
        }
    }
    node=binarylift[node][0];
    return level[initnode]-level[node];
}

int main(){
    scanf("%i %i",&n,&k);
    int end1,end2;
    for(int i=0;i<n-1;i++){
        scanf("%i %i",&end1,&end2);
        adjlist[end1-1].push_back(end2-1);
        adjlist[end2-1].push_back(end1-1);
    }
    int included=1;
    addedsolution[n-1]=true;
    dfs(n-1,n-1,0);
    buildtable();
    for(int i=n-2;i>=0;i--){
        int incl=searchlca(i);
        //cout<<"NODE "<<i+1<<" with distance "<<incl<<endl;
        if(included+incl<=n-k&&!addedsolution[i]){
            included+=incl;
            int j=i;
            while(!addedsolution[j]){
                //cout<<"ADDING "<<j+1<<endl;
                addedsolution[j]=true;
                j=parent[j];
            }
        }
    }
    for(int i=0;i<n;i++){
        if(!addedsolution[i]){
            printf("%i ",i+1);
        }
    }
    return 0;
}


# include <bits/stdc++.h>

# define y1 asdjksjkdkjs

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair < int, int > pii;
typedef unsigned long long ull;

const int N = int(2e6) + 5;
const int inf = (int)1e9 + 9;

struct segtree{
  int t[N * 4];
  segtree(){
    fill(t, t + N * 4, 0);
  }
  void setrange(int v, int tl, int tr, int l, int r, int x){
    if(l > r){
      return;
    }
    if(tl == l && tr == r){
      return;
    }

      t[v] = max(t[v], x);
    int tm = (tl + tr) >> 1;
    setrange(v * 2, tl, tm, l, min(r, tm), x);
    setrange(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r, x);
  }
  int get(int v, int tl, int tr, int l, int r){
    if(l > r){
      return 0;
    }
    if(tl == l && tr == r){
      return t[v];
    }
    int tm = (tl + tr) >> 1;
    return max({t[v], get(v * 2, tl, tm, l, min(r, tm)), get(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r)});
  }
}st;

int n, k;
int h[N], l[N], r[N], up[N], T, used[N];
vector < int > g[N];

void dfs(int v, int p){
  l[v] = ++T;
  up[v] = p;
  for(int i : g[v]){
    if(i != p){
      h[i] = h[v] + 1;
      dfs(i, v);
    }
  }
  r[v] = ++T;
}

int main(){
  scanf("%d %d", &n, &k);
  k = n - k;
  for(int i = 1; i < n; ++i){
    int a, b;
    scanf("%d %d", &a, &b);
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs(n, 0);
  used[n] = 1;
  vector < int > ans;
  int now = k - 1;
  int cnt = 1;
  for(int i = n - 1; i >= 1; --i){
    if(used[i]){
      continue;
    }
    int e = st.get(1, 1, T, l[i], l[i]);
    if(now >= h[i] - e){
      now -= h[i] - e;
      int tmp = i;
      while(true){
        if(used[tmp] || !tmp){
          break;
        }

        ++cnt;
        used[tmp] = 1;
        tmp = up[tmp];
      }
      st.setrange(1, 1, T, l[i], r[i], h[i]);
    }
  }
  for(int i = 1; i <= n; ++i){
    if(!used[i]){
      ans.push_back(i);
    }
  }
  for(int i : ans){
    printf("%d ", i);
  }
  return 0;
}


# include <bits/stdc++.h>

# define y1 asdjksjkdkjs

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair < int, int > pii;
typedef unsigned long long ull;

const int N = int(2e6) + 5;
const int inf = (int)1e9 + 9;

struct segtree{
  int t[N * 4];
  segtree(){
    fill(t, t + N * 4, 0);
  }
  void setrange(int v, int tl, int tr, int l, int r, int x){
    if(l > r){
      return;
    }
    if(tl == l && tr == r){
      t[v] = max(t[v], x);
      return;
    }
    int tm = (tl + tr) >> 1;
    setrange(v * 2, tl, tm, l, min(r, tm), x);
    setrange(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r, x);
  }
  int get(int v, int tl, int tr, int l, int r){
    if(l > r){
      return 0;
    }
    if(tl == l && tr == r){
      return t[v];
    }
    int tm = (tl + tr) >> 1;
    return max({t[v], get(v * 2, tl, tm, l, min(r, tm)), get(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r)});
  }
}st;

int n, k;
int h[N], l[N], r[N], up[N], T, used[N];
vector < int > g[N];

void dfs(int v, int p){
  l[v] = ++T;
  up[v] = p;
  for(int i : g[v]){
    if(i != p){
      h[i] = h[v] + 1;
      dfs(i, v);
    }
  }
  r[v] = ++T;
}

int main(){
  scanf("%d %d", &n, &k);
  k = n - k;
  for(int i = 1; i < n; ++i){
    int a, b;
    scanf("%d %d", &a, &b);
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs(n, 0);
  used[n] = 1;
  vector < int > ans;
  int now = k - 1;
  for(int i = n - 1; i >= 2; --i){
    if(used[i]){
      continue;
    }
    int e = st.get(1, 1, T, l[i], l[i]);
    if(now >= h[i] - e){
      now -= h[i] - e;
      int tmp = i;
      while(true){
        if(used[tmp] || !tmp){
          break;
        }
        used[tmp] = 1;
        tmp = up[tmp];
      }
      st.setrange(1, 1, T, l[i], r[i], h[i]);
    }
  }
  for(int i = 1; i <= n; ++i){
    if(!used[i]){
      ans.push_back(i);
    }
  }
  for(int i : ans){
    printf("%d ", i);
  }
  return 0;
}


# include <bits/stdc++.h>

# define y1 asdjksjkdkjs

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair < int, int > pii;
typedef unsigned long long ull;

const int N = int(2e6) + 5;
const int inf = (int)1e9 + 9;

struct segtree{
  int t[N * 4];
  segtree(){
    fill(t, t + N * 4, 0);
  }
  void setrange(int v, int tl, int tr, int l, int r, int x){
    if(l > r){
      return;
    }
    if(tl == l && tr == r){
      t[v] = max(t[v], x);
      return;
    }
    int tm = (tl + tr) >> 1;
    setrange(v * 2, tl, tm, l, min(r, tm), x);
    setrange(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r, x);
  }
  int get(int v, int tl, int tr, int l, int r){
    if(l > r){
      return 0;
    }
    if(tl == l && tr == r){
      return t[v];
    }
    int tm = (tl + tr) >> 1;
    return max({t[v], get(v * 2, tl, tm, l, min(r, tm)), get(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r)});
  }
}st;

int n, k;
int h[N], l[N], r[N], up[N], T, used[N];
vector < int > g[N];

void dfs(int v, int p){
  l[v] = ++T;
  up[v] = p;
  for(int i : g[v]){
    if(i != p){
      h[i] = h[v] + 1;
      dfs(i, v);
    }
  }
  r[v] = ++T;
}

int main(){
  scanf("%d %d", &n, &k);
  k = n - k;
  for(int i = 1; i < n; ++i){
    int a, b;
    scanf("%d %d", &a, &b);
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs(n, 0);
  used[n] = 1;
  vector < int > ans;
  int now = k - 1;
  int cnt = 1;
  for(int i = n - 1; i >= 1; --i){
    if(used[i]){
      continue;
    }
    int e = st.get(1, 1, T, l[i], l[i]);
    if(now >= h[i] - e){
      now -= h[i] - e;
      int tmp = i;
      while(true){
        if(used[tmp] || !tmp){
          break;
        }

        ++cnt;
        used[tmp] = 1;
        tmp = up[tmp];
      }
      st.setrange(1, 1, T, l[i], r[i], h[i]);
    }
  }
  assert(cnt == k);
  for(int i = 1; i <= n; ++i){
    if(!used[i]){
      ans.push_back(i);
    }
  }
  for(int i : ans){
    printf("%d ", i);
  }
  return 0;
}


# include <bits/stdc++.h>

# define y1 asdjksjkdkjs

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair < int, int > pii;
typedef unsigned long long ull;

const int N = int(2e6) + 5;
const int inf = (int)1e9 + 9;

struct segtree{
  int t[N * 4];
  segtree(){
    fill(t, t + N * 4, 0);
  }
  void setrange(int v, int tl, int tr, int l, int r, int x){
    if(l > r){
      return;
    }
    if(tl == l && tr == r){
      t[v] = max(t[v], x);
      return;
    }
    int tm = (tl + tr) >> 1;
    t[v * 2] = max(t[v * 2], t[v]);
    t[v * 2 + 1] = max(t[v * 2 + 1], t[v]);
    setrange(v * 2, tl, tm, l, min(r, tm), x);
    setrange(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r, x);
  }
  int get(int v, int tl, int tr, int l, int ){
    if(l > r){
      return 0;
    }
    if(tl == l && tr == r){
      return t[v];
    }
    int tm = (tl + tr) >> 1;
    return max(get(v * 2, tl, tm, l, min(r, tm)), get(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r));
  }
}st;

int n, k;
int h[N], l[N], r[N], up[N], T, used[N];
vector < int > g[N];

void dfs(int v, int p){
  l[v] = ++T;
  up[v] = p;
  for(int i : g[v]){
    if(i != p){
      h[i] = h[v] + 1;
      dfs(i, v);
    }
  }
  r[v] = ++T;
}

int main(){
  scanf("%d %d", &n, &k);
  k = n - k;
  for(int i = 1; i < n; ++i){
    int a, b;
    scanf("%d %d", &a, &b);
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs(n, 0);
  used[n] = 1;
  vector < int > ans;
  int now = k - 1;
  int cnt = 1;
  for(int i = n - 1; i >= 1; --i){
    if(used[i]){
      continue;
    }
    int e = st.get(1, 1, T, l[i], l[i]);
    if(now >= h[i] - e){
      now -= h[i] - e;
      int tmp = i;
      while(true){
        if(used[tmp] || !tmp){
          break;
        }

        ++cnt;
        used[tmp] = 1;
        tmp = up[tmp];
      }
      st.setrange(1, 1, T, l[i], r[i], h[i]);
    }
  }
  for(int i = 1; i <= n; ++i){
    if(!used[i]){
      ans.push_back(i);
    }
  }
  for(int i : ans){
    printf("%d ", i);
  }
  return 0;
}


# include <bits/stdc++.h>

# define y1 asdjksjkdkjs

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair < int, int > pii;
typedef unsigned long long ull;

const int N = int(2e6) + 5;
const int inf = (int)1e9 + 9;

struct bit{
  ll t[N];
  void inc(int x, int y){
    for(; x < N; x += x & -x){
      t[x] += y;
    }
  }
  ll get(int x){
    ll ans = 0;
    for(; x > 0; x -= x & -x){
      ans += t[x];
    }
    return ans;
  }
}st;

int n, k;
int h[N], l[N], r[N], up[N], T, used[N];
vector < int > g[N];

void dfs(int v, int p){
  l[v] = ++T;
  up[v] = p;
  for(int i : g[v]){
    if(i != p){
      h[i] = h[v] + 1;
      dfs(i, v);
    }
  }
  r[v] = ++T;
}

int main(){
  scanf("%d %d", &n, &k);
  k = n - k;
  for(int i = 1; i < n; ++i){
    int a, b;
    scanf("%d %d", &a, &b);
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs(n, 0);
  for(int i = 1; i <= n; ++i){
    st.inc(l[i], h[i]);
    st.inc(l[i] + 1, -h[i]);
  }
  used[n] = 1;
  vector < int > ans;
  int now = k - 1;
  int cnt = 1;
  for(int i = n - 1; i >= 1; --i){
    if(used[i]){
      continue;
    }
    int e = st.get(l[i]);
    if(now >= e){
      now -= e;
      int tmp = i;
      while(true){
        if(used[tmp] || !tmp){
          break;
        }
        ++cnt;
        used[tmp] = 1;
        tmp = up[tmp];
      }
      st.inc(l[i], -e);
      st.inc(r[i] + 1, e);
    }
  }
  for(int i = 1; i <= n; ++i){
    if(!used[i]){
      ans.push_back(i);
    }
  }
  assert((int)ans.size() == n - k);
  for(int i : ans){
    printf("%d ", i);
  }
  return 0;
}


# include <bits/stdc++.h>

# define y1 asdjksjkdkjs

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair < int, int > pii;
typedef unsigned long long ull;

const int N = int(2e6) + 5;
const int inf = (int)1e9 + 9;

struct segtree{
  int t[N * 4];
  segtree(){
    fill(t, t + N * 4, 0);
  }
  void setrange(int v, int tl, int tr, int l, int r, int x){
    if(l > r){
      return;
    }
    if(tl == l && tr == r){
      t[v] = max(t[v], x);
      return;
    }
    int tm = (tl + tr) >> 1;
    setrange(v * 2, tl, tm, l, min(r, tm), x);
    setrange(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r, x);
  }
  int get(int v, int tl, int tr, int l, int r){
    if(l > r){
      return 0;
    }
    if(tl == l && tr == r){
      return t[v];
    }
    int tm = (tl + tr) >> 1;
    return max({t[v], get(v * 2, tl, tm, l, min(r, tm)), get(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r)});
  }
}st;

int n, k;
int h[N], l[N], r[N], up[N], T, used[N];
vector < int > g[N];

void dfs(int v, int p){
  l[v] = ++T;
  up[v] = p;
  for(int i : g[v]){
    if(i != p){
      h[i] = h[v] + 1;
      dfs(i, v);
    }
  }
  r[v] = ++T;
}

int main(){
  scanf("%d %d", &n, &k);
  k = n - k;
  for(int i = 1; i < n; ++i){
    int a, b;
    scanf("%d %d", &a, &b);
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs(n, 0);
  used[n] = 1;
  vector < int > ans;
  int now = k - 1;
  for(int i = n - 1; i >= 1; --i){
    if(used[i]){
      continue;
    }
    int e = st.get(1, 1, T, l[i], l[i]);
    if(now >= h[i] - e){
      now -= h[i] - e;
      int tmp = i;
      while(true){
        if(used[tmp] || !tmp){
          break;
        }
        used[tmp] = 1;
        tmp = up[tmp];
      }
      st.setrange(1, 1, T, l[i], r[i], h[i]);
    }
  }
  for(int i = 1; i <= n; ++i){
    if(!used[i]){
      ans.push_back(i);
    }
  }
  for(int i : ans){
    printf("%d ", i);
  }
  return 0;
}


# include <bits/stdc++.h>

# define y1 asdjksjkdkjs

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair < int, int > pii;
typedef unsigned long long ull;

const int N = int(2e6) + 5;
const int inf = (int)1e9 + 9;

struct bit{
  ll t[N];
  void inc(int x, int y){
    for(; x < N; x += x & -x){
      t[x] += y;
    }
  }
  ll get(int x){
    ll ans = 0;
    for(; x > 0; x -= x & -x){
      ans += t[x];
    }
    return ans;
  }
}st;

int n, k;
int h[N], l[N], r[N], up[N], T, used[N];
vector < int > g[N];

void dfs(int v, int p){
  l[v] = ++T;
  up[v] = p;
  for(int i : g[v]){
    if(i != p){
      h[i] = h[v] + 1;
      dfs(i, v);
    }
  }
  r[v] = ++T;
}

int main(){
  scanf("%d %d", &n, &k);
  k = n - k;
  for(int i = 1; i < n; ++i){
    int a, b;
    scanf("%d %d", &a, &b);
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs(n, 0);
  for(int i = 1; i <= n; ++i){
    st.inc(l[i], h[i]);

    st.inc(l[i] + 1, -h[i]);
  }

  used[n] = 1;
  vector < int > ans;
  int now = k - 1;
  int cnt = 1;
  for(int i = n - 1; i >= 1; --i){
    if(used[i]){
      continue;
    }
    int e = st.get(l[i]);
    if(now >= e){
      now -= e;
      int tmp = i;
      while(true){
        if(used[tmp] || !tmp){
          break;
        }
        ++cnt;
        used[tmp] = 1;
        tmp = up[tmp];
      }
      st.inc(l[i], -e);
      st.inc(r[i] + 1, e);
    }
  }
  for(int i = 1; i <= n; ++i){
    if(!used[i]){
      ans.push_back(i);
    }
  }
  for(int i : ans){
    printf("%d ", i);
  }
  return 0;
}


# include <bits/stdc++.h>

# define y1 asdjksjkdkjs

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair < int, int > pii;
typedef unsigned long long ull;

const int N = int(2e6) + 5;
const int inf = (int)1e9 + 9;

struct bit{
  ll t[N];
  void inc(int x, int y){
    for(; x < N; x += x & -x){
      t[x] += y;
    }
  }
  ll get(int x){
    ll ans = 0;
    for(; x > 0; x -= x & -x){
      ans += t[x];
    }
    return ans;
  }
}st;

int n, k;
int h[N], l[N], r[N], up[N], T, used[N];
vector < int > g[N];

void dfs(int v, int p){
  l[v] = ++T;
  up[v] = p;
  for(int i : g[v]){
    if(i != p){
      h[i] = h[v] + 1;
      dfs(i, v);
    }
  }
  r[v] = ++T;
}

int main(){
  scanf("%d %d", &n, &k);
  k = n - k;
  for(int i = 1; i < n; ++i){
    int a, b;
    scanf("%d %d", &a, &b);
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs(n, 0);
  for(int i = 1; i <= n; ++i){
    st.inc(l[i], h[i]);
    st.inc(l[i] + 1, -h[i]);
  }
  used[n] = 1;
  vector < int > ans;
  int now = k - 1;
  int cnt = 1;
  for(int i = n - 1; i >= 1; --i){
    if(used[i]){
      continue;
    }
    int e = st.get(l[i]);
    if(now >= e){
      now -= e;
      int tmp = i;
      vector < int > me;
      while(true){
        if(used[tmp] || !tmp){
          break;
        }

        me.push_back(tmp);
        used[tmp] = 1;
        tmp = up[tmp];
      }
      reverse(me.begin(), me.end());
      for(int i : me){
        st.inc(l[i], -1);
        st.inc(r[i] + 1, 1);
      }
    }
  }
  for(int i = 1; i <= n; ++i){
    if(!used[i]){
      ans.push_back(i);
    }
  }
  for(int i : ans){
    printf("%d ", i);
  }
  return 0;
}


# include <bits/stdc++.h>

# define y1 asdjksjkdkjs

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair < int, int > pii;
typedef unsigned long long ull;

const int N = int(2e6) + 5;
const int inf = (int)1e9 + 9;

struct segtree{
  int t[N * 4];
  segtree(){
    fill(t, t + N * 4, 0);
  }
  void setrange(int v, int tl, int tr, int l, int r, int x){
    if(l > r){
      return;
    }
    if(tl == l && tr == r){
      t[v] = max(t[v], x);
      return;
    }
    int tm = (tl + tr) >> 1;
    setrange(v * 2, tl, tm, l, min(r, tm), x);
    setrange(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r, x);
  }
  int get(int v, int tl, int tr, int l, int r){
    if(l > r){
      return 0;
    }
    if(tl == l && tr == r){
      return t[v];
    }
    int tm = (tl + tr) >> 1;
    return max({t[v], get(v * 2, tl, tm, l, min(r, tm)), get(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r)});
  }
}st;

int n, k;
int h[N], l[N], r[N], up[N], T, used[N];
vector < int > g[N];

void dfs(int v, int p){
  l[v] = ++T;
  up[v] = p;
  for(int i : g[v]){
    if(i != p){
      h[i] = h[v] + 1;
      dfs(i, v);
    }
  }
  r[v] = ++T;
}

int main(){
  scanf("%d %d", &n, &k);
  k = n - k;
  for(int i = 1; i < n; ++i){
    int a, b;
    scanf("%d %d", &a, &b);
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs(n, 0);
  used[n] = 1;
  vector < int > ans;
  int now = k - 1;
  for(int i = n - 1; i >= 1; --i){
    if(used[i]){
      continue;
    }
    int e = st.get(1, 1, T, l[i], l[i]);
    if(now >= h[i] - e){
      now -= h[i] - e;
      int tmp = i;
      while(true){
        if(used[tmp] || !tmp){
          break;
        }
        st.setrange(1, 1, T, l[tmp], r[tmp], h[tmp]);
        used[tmp] = 1;
        tmp = up[tmp];
      }
    }
  }
  for(int i = 1; i <= n; ++i){
    if(!used[i]){
      ans.push_back(i);
    }
  }
  for(int i : ans){
    printf("%d ", i);
  }
  return 0;
}


# include <bits/stdc++.h>

# define y1 asdjksjkdkjs

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair < int, int > pii;
typedef unsigned long long ull;

const int N = int(2e6) + 5;
const int inf = (int)1e9 + 9;

struct segtree{
  int t[N * 4];
  segtree(){
    fill(t, t + N * 4, 0);
  }
  void setrange(int v, int tl, int tr, int l, int r, int x){
    if(l > r){
      return;
    }
    if(tl == l && tr == r){
      t[v] = max(t[v], x);
      return;
    }
    int tm = (tl + tr) >> 1;
    setrange(v * 2, tl, tm, l, min(r, tm), x);
    setrange(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r, x);
  }
  int get(int v, int tl, int tr, int pos){
    int tm = (tl + tr) >> 1;
    if(tl == tr){
      return t[v];
    }
    if(pos <= tm){
      return max(get(v * 2, tl, tm, pos), t[v]);
    } else{
      return max(get(v * 2 + 1, tm + 1, tr, pos), t[v]);
    }
  }
}st;

int n, k;
int h[N], l[N], r[N], up[N], T, used[N];
vector < int > g[N];

void dfs(int v, int p){
  l[v] = ++T;
  up[v] = p;
  for(int i : g[v]){
    if(i != p){
      h[i] = h[v] + 1;
      dfs(i, v);
    }
  }
  r[v] = ++T;
}

int main(){
  scanf("%d %d", &n, &k);
  k = n - k;
  for(int i = 1; i < n; ++i){
    int a, b;
    scanf("%d %d", &a, &b);
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs(n, 0);
  used[n] = 1;
  vector < int > ans;
  int now = k - 1;
  int cnt = 1;
  for(int i = n - 1; i >= 1; --i){
    if(used[i]){
      continue;
    }
    int e = st.get(1, 1, T, l[i]);
    if(now >= h[i] - e){
      now -= h[i] - e;
      int tmp = i;
      while(true){
        if(used[tmp] || !tmp){
          break;
        }

        ++cnt;
        used[tmp] = 1;
        tmp = up[tmp];
      }
      st.setrange(1, 1, T, l[i], r[i], h[i]);
    }
  }
  for(int i = 1; i <= n; ++i){
    if(!used[i]){
      ans.push_back(i);
    }
  }
  for(int i : ans){
    printf("%d ", i);
  }
  return 0;
}


//                                      KiSmAt
#include "bits/stdc++.h"
using namespace std;

using ll = long long;

const int LOG = 5;
const ll inf = 1e18;
const int N = 1e6 + 10;

ll res;
ll Par[N];
ll up[N][LOG + 10];
ll a[N], vis[N];

vector<ll> v[N];

void dfs(ll node, ll parent, ll ct){
    vis[node] = 1;
    Par[node] = parent;
    up[node][0] = parent;
    for(int i = 1; 1LL << i <= ct; ++i){
        up[node][i] = up[up[node][i - 1]][i - 1];
    }
    for(auto i: v[node]){
        if(!vis[i]) dfs(i, node, ct + 1);
    }
}

ll foo(ll idx){
    ll res = 0;
    for(int i = LOG; i >= 0; --i){
        if(up[idx][i] && !vis[up[idx][i]]){
            idx = up[idx][LOG];
            res += 1LL << i;
        }
    }
    return res + 1;
}

void solve(){
    ll n, k, x, y;
    cin >> n >> k;
    for(int i = 0; i < n - 1; ++i){
        cin >> x >> y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    ll cur = n - k;
    dfs(n, n, 0);
    Par[n] = 0;
    up[n][0] = 0;
    memset(vis, 0, sizeof vis);
    vis[0] = 1;
    for(int i = n; i > 0; --i){
        ll req = foo(i), idx = i;
        if(req <= cur){
            cur -= req;
            while(!vis[idx]){
                vis[idx] = 1;
                idx = Par[idx];
            }
        }
    }
    for(int i = 1; i <= n; ++i){
        if(!vis[i]) cout << i << " ";
    }
}

int main(int argc, char const *argv[]){
    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    ll t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}
// nEro


//                                      KiSmAt
#include "bits/stdc++.h"
using namespace std;

using ll = long long;

const int LOG = 5;
const ll inf = 1e18;
const int N = 1e6 + 10;

ll res;
ll Par[N];
ll up[N][LOG + 10];
ll a[N], vis[N];

vector<ll> v[N];

void dfs(ll node, ll parent, ll ct){
    vis[node] = 1;
    Par[node] = parent;
    up[node][0] = parent;
    for(int i = 1; 1LL << i <= ct; ++i){
        up[node][i] = up[up[node][i - 1]][i - 1];
    }
    for(auto i: v[node]){
        if(!vis[i]) dfs(i, node, ct + 1);
    }
}

ll foo(ll idx){
    ll res = !vis[idx];
    for(int i = LOG; i >= 0; --i){
        if(up[idx][i] && !vis[up[idx][i]]){
            idx = up[idx][LOG];
            res += 1LL << i;
        }
    }
    return res;
}

void solve(){
    ll n, k, x, y;
    cin >> n >> k;
    for(int i = 0; i < n - 1; ++i){
        cin >> x >> y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    ll cur = n - k;
    dfs(n, n, 0);
    Par[n] = 0;
    up[n][0] = 0;
    memset(vis, 0, sizeof vis);
    vis[0] = 1;
    for(int i = n; i > 0; --i){
        ll req = foo(i), idx = i;
        if(req <= cur){
            cur -= req;
            while(!vis[idx]){
                vis[idx] = 1;
                idx = Par[idx];
            }
        }
    }
    for(int i = 1; i <= n; ++i){
        if(!vis[i]) cout << i << " ";
    }
}

int main(int argc, char const *argv[]){
    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    ll t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}
// nEro


//                                      KiSmAt
#include "bits/stdc++.h"
using namespace std;

using ll = long long;

const ll inf = 1e18;
const int N = 1e6 + 10;

ll res;
ll a[N], vis[N];

vector<ll> v[N], vv[N], vvv;

void dfs(ll node){
    vvv.push_back(node);
    vv[node] = vvv;
    vis[node] = 1;
    for(auto i: v[node]){
        if(!vis[i]) dfs(i);
    }
    vvv.pop_back();
}

ll foo(ll idx){
    ll lo = -1, hi = vv[idx].size();
    while(lo + 1 < hi){
        ll m = lo + hi >> 1;
        if(vis[vv[idx][m]])   lo = m;
        else    hi = m;
    }
    res = lo + 1;
    return vv[idx].size() - 1 - lo;
}

void solve(){
    ll n, k, x, y;
    cin >> n >> k;
    for(int i = 0; i < n - 1; ++i){
        cin >> x >> y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    ll cur = n - k;
    dfs(n);
    memset(vis, 0, sizeof vis);
    for(int i = n; i > 0; --i){
        ll req = foo(i);
        if(req <= cur){
            cur -= req;
            for(int j = res; j < vv[i].size(); ++j){
                vis[vv[i][j]] = 1;
            }
        }
    }
    for(int i = 1; i <= n; ++i){
        if(!vis[i]) cout << i << " ";
    }
}

int main(int argc, char const *argv[]){
    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    ll t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}
// nEro


//                                      KiSmAt
#include "bits/stdc++.h"
using namespace std;

using ll = long long;

const int LOG = 5;
const ll inf = 1e18;
const int N = 1e6 + 10;

ll res;
ll Par[N];
ll up[N][LOG + 10];
ll a[N], vis[N];

vector<ll> v[N];

void dfs(ll node, ll parent, ll ct){
    vis[node] = 1;
    Par[node] = parent;
    up[node][0] = parent;
    for(int i = 1; 1LL << i <= ct; ++i){
        up[node][i] = up[up[node][i - 1]][i - 1];
    }
    for(auto i: v[node]){
        if(!vis[i]) dfs(i, node, ct + 1);
    }
}

ll foo(ll idx){
    ll res = !vis[idx];
    for(int i = LOG; i >= 0; --i){
        if(up[idx][i] && !vis[up[idx][i]]){
            idx = up[idx][LOG];
            res += 1LL << i;
        }
    }
    return res;
}

void solve(){
    ll n, k, x, y;
    cin >> n >> k;
    for(int i = 0; i < n - 1; ++i){
        cin >> x >> y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    ll cur = n - k;
    dfs(n, n, 0);
    Par[n] = 0;
    up[n][0] = 0;
    memset(vis, 0, sizeof vis);
    vis[0] = 1;
    for(int i = n; i > 0; --i){
        ll req = foo(i), idx = i;
        if(req <= cur){
            cur -= req;
            while(!vis[idx]){
                vis[idx] = 1;
                idx = Par[idx];
            }
        }
    }
    for(int i = 1; i <= n; ++i){
        if(!vis[i]) cout << i << " ";
    }
    return ;
}

int main(int argc, char const *argv[]){
    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    ll t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}
// nEro


//                                      KiSmAt
#include "bits/stdc++.h"
using namespace std;

using ll = int;

const int LOG = 20;
const int N = 1e6 + 10;

ll res;
ll Par[N];
ll up[N][LOG + 1];
ll a[N], vis[N];

vector<ll> v[N];

void dfs(ll node, ll parent, ll ct){
    vis[node] = 1;
    Par[node] = parent;
    up[node][0] = parent;
    for(int i = 1; i <= LOG; ++i){
        up[node][i] = up[up[node][i - 1]][i - 1];
    }
    for(auto i: v[node]){
        if(!vis[i]) dfs(i, node, ct + 1);
    }
}

ll foo(ll idx){
    ll res = !vis[idx];
    for(int i = LOG; i >= 0; --i){
        if(up[idx][i] && !vis[up[idx][i]]){
            idx = up[idx][i];
            res += 1LL << i;
        }
    }
    return res;
}

void solve(){
    ll n, k, x, y;
    cin >> n >> k;
    for(int i = 0; i < n - 1; ++i){
        cin >> x >> y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    ll cur = n - k;
    dfs(n, 0, 0);
    memset(vis, 0, sizeof vis);
    vis[0] = 1;
    for(int i = n; i > 0; --i){
        ll req = foo(i), idx = i;
        if(req <= cur){
            cur -= req;
            while(!vis[idx]){
                vis[idx] = 1;
                idx = Par[idx];
            }
        }
    }
    for(int i = 1; i <= n; ++i){
        if(!vis[i]) cout << i << " ";
    }
}

int main(int argc, char const *argv[]){
    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    ll t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}
// nEro


//                                      KiSmAt
#include "bits/stdc++.h"
using namespace std;

using ll = long long;

const int LOG = 20;
const ll inf = 1e18;
const int N = 1e6 + 10;

ll res;
ll Par[N];
ll up[N][LOG + 1];
ll a[N], vis[N];

vector<ll> v[N];

void dfs(ll node, ll parent, ll ct){
    vis[node] = 1;
    Par[node] = parent;
    up[node][0] = parent;
    for(int i = 1; 1LL << i <= ct; ++i){
        up[node][i] = up[up[node][i - 1]][i - 1];
    }
    for(auto i: v[node]){
        if(!vis[i]) dfs(i, node, ct + 1);
    }
}

ll foo(ll idx){
    ll res = !vis[idx];
    for(int i = LOG; i >= 0; --i){
        if(up[idx][i] && !vis[up[idx][i]]){
            idx = up[idx][i];
            res += 1LL << i;
        }
    }
    return res;
}

void solve(){
    ll n, k, x, y;
    cin >> n >> k;
    for(int i = 0; i < n - 1; ++i){
        cin >> x >> y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    ll cur = n - k;
    dfs(n, n, 0);
    Par[n] = 0;
    up[n][0] = 0;
    memset(vis, 0, sizeof vis);
    vis[0] = 1;
    for(int i = n; i > 0; --i){
        ll req = foo(i), idx = i;
        if(req <= cur){
            cur -= req;
            while(!vis[idx]){
                vis[idx] = 1;
                idx = Par[idx];
            }
        }
    }
    for(int i = 1; i <= n; ++i){
        if(!vis[i]) cout << i << " ";
    }
}

int main(int argc, char const *argv[]){
    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    ll t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}
// nEro


//                                      KiSmAt
#include "bits/stdc++.h"
using namespace std;

using ll = int;

const int LOG = 20;
const ll inf = 1e18;
const int N = 1e6 + 10;

ll res;
ll Par[N];
ll up[N][LOG + 1];
ll a[N], vis[N];

vector<ll> v[N];

void dfs(ll node, ll parent, ll ct){
    vis[node] = 1;
    Par[node] = parent;
    up[node][0] = parent;
    for(int i = 1; 1LL << i <= ct; ++i){
        up[node][i] = up[up[node][i - 1]][i - 1];
    }
    for(auto i: v[node]){
        if(!vis[i]) dfs(i, node, ct + 1);
    }
}

ll foo(ll idx){
    ll res = !vis[idx];
    for(int i = LOG; i >= 0; --i){
        if(up[idx][i] && !vis[up[idx][i]]){
            idx = up[idx][i];
            res += 1LL << i;
        }
    }
    return res;
}

void solve(){
    ll n, k, x, y;
    cin >> n >> k;
    for(int i = 0; i < n - 1; ++i){
        cin >> x >> y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    ll cur = n - k;
    dfs(n, n, 0);
    Par[n] = 0;
    up[n][0] = 0;
    memset(vis, 0, sizeof vis);
    vis[0] = 1;
    for(int i = n; i > 0; --i){
        ll req = foo(i), idx = i;
        if(req <= cur){
            cur -= req;
            while(!vis[idx]){
                vis[idx] = 1;
                idx = Par[idx];
            }
        }
    }
    for(int i = 1; i <= n; ++i){
        if(!vis[i]) cout << i << " ";
    }
}

int main(int argc, char const *argv[]){
    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    ll t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}
// nEro


//                                      KiSmAt
#include "bits/stdc++.h"
using namespace std;

using ll = long long;

const int LOG = 20;
const ll inf = 1e18;
const int N = 1e6 + 10;

ll res;
ll Par[N];
ll up[N][LOG + 10];
ll a[N], vis[N];

vector<ll> v[N];

void dfs(ll node, ll parent, ll ct){
    vis[node] = 1;
    Par[node] = parent;
    up[node][0] = parent;
    for(int i = 1; 1LL << i <= ct; ++i){
        up[node][i] = up[up[node][i - 1]][i - 1];
    }
    for(auto i: v[node]){
        if(!vis[i]) dfs(i, node, ct + 1);
    }
}

ll foo(ll idx){
    ll res = !vis[idx];
    for(int i = LOG; i >= 0; --i){
        if(up[idx][i] && !vis[up[idx][i]]){
            idx = up[idx][i];
            res += 1LL << i;
        }
    }
    return res;
}

void solve(){
    ll n, k, x, y;
    cin >> n >> k;
    for(int i = 0; i < n - 1; ++i){
        cin >> x >> y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    ll cur = n - k;
    dfs(n, n, 0);
    Par[n] = 0;
    up[n][0] = 0;
    memset(vis, 0, sizeof vis);
    vis[0] = 1;
    for(int i = n; i > 0; --i){
        ll req = foo(i), idx = i;
        if(req <= cur){
            cur -= req;
            while(!vis[idx]){
                vis[idx] = 1;
                idx = Par[idx];
            }
        }
    }
    for(int i = 1; i <= n; ++i){
        if(!vis[i]) cout << i << " ";
    }
}

int main(int argc, char const *argv[]){
    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    ll t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}
// nEro


#include <bits/stdc++.h>

using namespace std;

#ifdef ONLINE_JUDGE
#define OJ 1
#else
#define OJ 0
#endif

#define dd				double
#define ll 				long long
#define pb 				push_back
#define mp 				make_pair
#define X				first
#define Y				second
#define forn( i, n ) 	for( ll i = 0; i < (ll) (n); i ++ )
#define endl 			'\n'

#define TIMESTAMP fprintf(stderr, "Execution time: %.3lf s.\n", (double)clock()/CLOCKS_PER_SEC)

struct __s { __s() {
		//srand( time( NULL ) );
		//freopen( "input.txt", "r", stdin ); freopen( "output.txt", "w", stdout );
		if( OJ ) { ios_base::Init i; cin.sync_with_stdio( 0 ); cin.tie( 0 ); }
	} ~__s() {
		if( !OJ ) TIMESTAMP;
		ll n; cin >> n;
	}
} __S;

vector< ll > g[1111111];
bool u[1111111];
ll h[1111111];
ll p[22][1111111];

void dfs( ll i ) {
	u[i] = true;
	for( ll j : g[i] ) {
		if( u[j] )
			continue;
		p[0][j] = i;
		h[j] = h[i] + 1;
		dfs( j );
	}
}

bool U[1111111];

ll get( ll i ) {
	ll k = i;
	for( ll j = 21; j >= 0; j -- ) {
		if( p[j][i] == -1 )
			continue;
		if( U[p[j][i]] )
			continue;
		i = p[j][i];
	}
	return h[k] - h[i] + 1;
}

int main( void ) {
	ll n, k;
	cin >> n >> k;
	forn( i, n-1 ) {
		ll a, b;
		cin >> a >> b;
		a --, b --;
		g[a].pb( b );
		g[b].pb( a );
	}
	dfs( n-1 );
	p[0][n-1] = -1;
	for( ll i = 1; i < 22; i ++ ) {
		forn( j, n ) {
			if( p[i-1][j] == -1 ) {
				p[i][j] = -1;
				continue;
			}
			ll k = p[i-1][j];
			p[i][j] = p[i-1][k];
		}
	}
	ll cnt = n-k;
	for( ll i = n-1; i >= 0; i -- ) {
		ll m = get( i );
		if( m > cnt )
			continue;
		cnt -= m;
		ll j = i;
		while( j != -1 && !U[j] ) {
			U[j] = true;
			j = p[0][j];
		}
	}
	forn( i, n ) {
		if( U[i] )
			continue;
		cout << i+1 << " ";
	}
	cout << endl;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#ifdef ONLINE_JUDGE
#define OJ 1
#else
#define OJ 0
#endif

#define dd				double
#define ll 				long long
#define pb 				push_back
#define mp 				make_pair
#define X				first
#define Y				second
#define forn( i, n ) 	for( ll i = 0; i < (ll) (n); i ++ )
#define endl 			'\n'

#define TIMESTAMP fprintf(stderr, "Execution time: %.3lf s.\n", (double)clock()/CLOCKS_PER_SEC)

struct __s { __s() {
		//srand( time( NULL ) );
		//freopen( "input.txt", "r", stdin ); freopen( "output.txt", "w", stdout );
		if( OJ ) { ios_base::Init i; cin.sync_with_stdio( 0 ); cin.tie( 0 ); }
	} ~__s() {
		if( !OJ ) TIMESTAMP;
		ll n; cin >> n;
	}
} __S;

vector< ll > g[1111111];
bool u[1111111];
ll h[1111111];
ll p[22][1111111];

void dfs( ll i ) {
	u[i] = true;
	for( ll j : g[i] ) {
		if( u[j] )
			continue;
		p[0][j] = i;
		h[j] = h[i] + 1;
		dfs( j );
	}
}

bool U[1111111];

ll get( ll i ) {
	ll k = i;
	for( ll j = 21; j >= 0; j -- ) {
		if( p[j][i] == -1 )
			continue;
		if( U[p[j][i]] )
			continue;
		i = p[j][i];
	}
	return h[k] - h[i] + 1;
}

int main( void ) {
	ll n, k;
	cin >> n >> k;
	forn( i, n-1 ) {
		ll a, b;
		cin >> a >> b;
		a --, b --;
		g[a].pb( b );
		g[b].pb( a );
	}
	dfs( n-1 );
	p[0][n-1] = -1;
	for( ll i = 1; i < 22; i ++ ) {
		forn( j, n ) {
			if( p[i-1][j] == -1 ) {
				p[i][j] = -1;
				continue;
			}
			ll k = p[i-1][j];
			p[i][j] = p[i-1][k];
		}
	}
	ll cnt = n-k;
	for( ll i = n-1; i >= 0; i -- ) {
		if( U[i] )
		continue;
		ll m = get( i );
		if( m > cnt )
			continue;
		cnt -= m;
		ll j = i;
		while( j != -1 && !U[j] ) {
			U[j] = true;
			j = p[0][j];
		}
	}
	forn( i, n ) {
		if( U[i] )
			continue;
		cout << i+1 << " ";
	}
	cout << endl;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#ifdef ONLINE_JUDGE
#define OJ 1
#else
#define OJ 0
#endif

#define dd				double
#define ll 				int
#define pb 				push_back
#define mp 				make_pair
#define X				first
#define Y				second
#define forn( i, n ) 	for( ll i = 0; i < (ll) (n); i ++ )
#define endl 			'\n'

#define TIMESTAMP fprintf(stderr, "Execution time: %.3lf s.\n", (double)clock()/CLOCKS_PER_SEC)

struct __s { __s() {
		//srand( time( NULL ) );
		//freopen( "input.txt", "r", stdin ); freopen( "output.txt", "w", stdout );
		if( OJ ) { ios_base::Init i; cin.sync_with_stdio( 0 ); cin.tie( 0 ); }
	} ~__s() {
		if( !OJ ) TIMESTAMP;
		ll n; cin >> n;
	}
} __S;

vector< ll > g[1111111];
bool u[1111111];
ll h[1111111];
ll p[33][1111111];

void dfs( ll i ) {
	u[i] = true;
	for( ll j : g[i] ) {
		if( u[j] )
			continue;
		p[0][j] = i;
		h[j] = h[i] + 1;
		dfs( j );
	}
}

bool U[1111111];

ll get( ll i ) {
	ll k = i;
	for( ll j = 32; j >= 0; j -- ) {
		if( p[j][i] == -1 )
			continue;
		if( U[p[j][i]] )
			continue;
		i = p[j][i];
	}
	return h[k] - h[i] + 1;
}

int main( void ) {
	ll n, k;
	cin >> n >> k;
	forn( i, n-1 ) {
		ll a, b;
		cin >> a >> b;
		a --, b --;
		g[a].pb( b );
		g[b].pb( a );
	}
	dfs( n-1 );
	p[0][n-1] = -1;
	for( ll i = 1; i < 33; i ++ ) {
		forn( j, n ) {
			if( p[i-1][j] == -1 ) {
				p[i][j] = -1;
				continue;
			}
			ll k = p[i-1][j];
			p[i][j] = p[i-1][k];
		}
	}
	ll cnt = n-k;
	for( ll i = n-1; i >= 0; i -- ) {
		ll m = get( i );
		if( m > cnt )
			continue;
		cnt -= m;
		ll j = i;
		while( j != -1 && !U[j] ) {
			U[j] = true;
			j = p[0][j];
		}
	}
	forn( i, n ) {
		if( U[i] )
			continue;
		cout << i+1 << " ";
	}
	cout << endl;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#ifdef ONLINE_JUDGE
#define OJ 1
#else
#define OJ 0
#endif

#define dd				double
#define ll 				int
#define pb 				push_back
#define mp 				make_pair
#define X				first
#define Y				second
#define forn( i, n ) 	for( ll i = 0; i < (ll) (n); i ++ )
#define endl 			'\n'

#define TIMESTAMP fprintf(stderr, "Execution time: %.3lf s.\n", (double)clock()/CLOCKS_PER_SEC)

struct __s { __s() {
		//srand( time( NULL ) );
		//freopen( "input.txt", "r", stdin ); freopen( "output.txt", "w", stdout );
		if( OJ ) { ios_base::Init i; cin.sync_with_stdio( 0 ); cin.tie( 0 ); }
	} ~__s() {
		if( !OJ ) TIMESTAMP;
		ll n; cin >> n;
	}
} __S;

vector< ll > g[1111111];
bool u[1111111];
ll h[1111111];
ll p[22][1111111];

void dfs( ll i ) {
	u[i] = true;
	for( ll j : g[i] ) {
		if( u[j] )
			continue;
		p[0][j] = i;
		h[j] = h[i] + 1;
		dfs( j );
	}
}

bool U[1111111];

ll get( ll i ) {
	ll k = i;
	for( ll j = 21; j >= 0; j -- ) {
		if( p[j][i] == -1 )
			continue;
		if( U[p[j][i]] )
			continue;
		i = p[j][i];
	}
	return h[k] - h[i] + 1;
}

int main( void ) {
	ll n, k;
	cin >> n >> k;
	forn( i, n-1 ) {
		ll a, b;
		cin >> a >> b;
		a --, b --;
		g[a].pb( b );
		g[b].pb( a );
	}
	dfs( n-1 );
	p[0][n-1] = -1;
	for( ll i = 1; i < 22; i ++ ) {
		forn( j, n ) {
			if( p[i-1][j] == -1 ) {
				p[i][j] = -1;
				continue;
			}
			ll k = p[i-1][j];
			p[i][j] = p[i-1][k];
		}
	}
	ll cnt = n-k;
	for( ll i = n-1; i >= 0; i -- ) {
		if( U[i] )
		continue;
		ll m = get( i );
		if( m > cnt )
			continue;
		cnt -= m;
		ll j = i;
		while( j != -1 && !U[j] ) {
			U[j] = true;
			j = p[0][j];
		}
	}
	forn( i, n ) {
		if( U[i] )
			continue;
		cout << i+1 << " ";
	}
	cout << endl;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#ifdef ONLINE_JUDGE
#define OJ 1
#else
#define OJ 0
#endif

#define dd				double
#define ll 				int
#define pb 				push_back
#define mp 				make_pair
#define X				first
#define Y				second
#define forn( i, n ) 	for( ll i = 0; i < (ll) (n); i ++ )
#define endl 			'\n'

#define TIMESTAMP fprintf(stderr, "Execution time: %.3lf s.\n", (double)clock()/CLOCKS_PER_SEC)

struct __s { __s() {
		//srand( time( NULL ) );
		//freopen( "input.txt", "r", stdin ); freopen( "output.txt", "w", stdout );
		if( OJ ) { ios_base::Init i; cin.sync_with_stdio( 0 ); cin.tie( 0 ); }
	} ~__s() {
		if( !OJ ) TIMESTAMP;
		ll n; cin >> n;
	}
} __S;

vector< ll > g[1111111];
bool u[1111111];
ll h[1111111];
ll p[22][1111111];

void dfs( ll i ) {
	u[i] = true;
	for( ll j : g[i] ) {
		if( u[j] )
			continue;
		p[0][j] = i;
		h[j] = h[i] + 1;
		dfs( j );
	}
}

bool U[1111111];

ll get( ll i ) {
	ll k = i;
	for( ll j = 21; j >= 0; j -- ) {
		if( p[j][i] == -1 )
			continue;
		if( U[p[j][i]] )
			continue;
		i = p[j][i];
	}
	return h[k] - h[i] + 1;
}

int main( void ) {
	ll n, k;
	cin >> n >> k;
	forn( i, n-1 ) {
		ll a, b;
		cin >> a >> b;
		a --, b --;
		g[a].pb( b );
		g[b].pb( a );
	}
	dfs( n-1 );
	p[0][n-1] = -1;
	for( ll i = 1; i < 22; i ++ ) {
		forn( j, n ) {
			if( p[i-1][j] == -1 ) {
				p[i][j] = -1;
				continue;
			}
			ll k = p[i-1][j];
			p[i][j] = p[i-1][k];
		}
	}
	ll cnt = n-k-1;
	U[n-1] = true;
	for( ll i = n-2; i >= 0; i -- ) {
		ll m = get( i );
		if( m > cnt )
			continue;
		cnt -= m;
		ll j = i;
		while( !U[j] ) {
			U[j] = true;
			j = p[0][j];
		}
	}
	forn( i, n ) {
		if( U[i] )
			continue;
		cout << i+1 << " ";
	}
	cout << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int maxn = 1e6+19;
int fa[maxn] = {0},clr[maxn] = {0},dep[maxn];
vector<int> e[maxn];
inline void add_edge(int u,int v) {e[u].push_back(v);}

void dfs(int u,int p) {
    for(auto v:e[u]) if(v != p) {
        fa[v] = u;
        dep[v] = dep[u]+1;
        dfs(v,u);
    }
}

int frt(int u) {
    if(clr[u]) return 0;
    else return 1+frt(fa[u]);
}

void paint(int u) {
    if(clr[u]) return ;
    clr[u] = 1;
    paint(fa[u]);
}

int main() {
    int n,k,u,v;
    cin >> n >> k;
    memset(dep,-1,sizeof(dep));
    for(int i = 1 ; i < n ; ++i) {
        cin >> u >> v;
        add_edge(u,v);
        add_edge(v,u);
    }
    dfs(n,0);
    k = n-k-1;
    clr[n] = 1;
    dep[n] = 1;
    for(int i = n-1 ; i ; --i) {
        if(dep[i] > k) continue;
        int res = frt(i);
        if(res <= k) {
            k -= res;
            paint(i);
        }
    }
    for(int i = 1 ; i <= n ; ++i)
        if(!clr[i]) cout << i << ' ';
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int maxn = 1e5+19;
int fa[maxn] = {0},clr[maxn] = {0};
vector<int> e[maxn];
inline void add_edge(int u,int v) {e[u].push_back(v);}

void dfs(int u,int p) {
    for(auto v:e[u]) if(v != p) {
        fa[v] = u;
        dfs(v,u);
    }
}

int frt(int u) {
    if(clr[u]) return 0;
    else return 1+frt(fa[u]);
}

void paint(int u) {
    if(clr[u]) return ;
    clr[u] = 1;
    paint(fa[u]);
}

int main() {
    int n,k,u,v;
    cin >> n >> k;
    for(int i = 1 ; i < n ; ++i) {
        cin >> u >> v;
        add_edge(u,v);
        add_edge(v,u);
    }
    dfs(n,0);
    k = n-k-1;
    clr[n] = 1;
    for(int i = n-1 ; i ; --i) {
        int res = frt(i);
        if(res <= k) {
            k -= res;
            paint(i);
        }
    }
    for(int i = 1 ; i <= n ; ++i)
        if(!clr[i]) cout << i << ' ';
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int maxn = 1e6+19;
int fa[maxn] = {0},clr[maxn] = {0},dep[maxn],g[maxn<<1] = {0},now = 0,lst[maxn] = {0},fst[maxn] = {0},h[maxn<<2] = {0},n;
vector<int> e[maxn];
inline void add_edge(int u,int v) {e[u].push_back(v);}
inline int getid(int l,int r) {return (l+r)|(l<r);}

void dfs(int u,int p) {
    g[++now] = u;
    fst[u] = now;
    for(auto v:e[u]) if(v != p) {
        fa[v] = u;
        dep[v] = dep[u]+1;
        dfs(v,u);
    }
    g[++now] = u;
    lst[u] = now;
}

int qry(int x,int l,int r) {
    int num = getid(l,r),ans = 0,m = l+r>>1;
    ans += h[num];
    if(l == r) return ans;
    if(x <= m) ans += qry(x,l,m);
    else ans += qry(x,m+1,r);
    return ans;
}

void mdf(int ql,int qr,int l,int r) {
    int num = getid(l,r),m = l+r>>1;
    if(ql > r || qr < l) return ;
    if(ql <= l && qr >= r) {++h[num];return ;}
    mdf(ql,qr,l,m);mdf(ql,qr,m+1,r);
}

void paint(int u) {
    if(clr[u]) return ;
    mdf(fst[u],lst[u],1,2*n);
    clr[u] = 1;
    paint(fa[u]);
}

int main() {
    int k,u,v;
    cin >> n >> k;
    memset(dep,0,sizeof(dep));
    for(int i = 1 ; i < n ; ++i) {
        cin >> u >> v;
        add_edge(u,v);
        add_edge(v,u);
    }
    dep[n] = 1;
    dfs(n,0);
    k = n-k;
    for(int i = n ; i && k ; --i) {
        if(clr[i]) continue;
        int res = qry(fst[i],1,2*n);
        if(dep[i]-res <= k) {k -= dep[i]-res;paint(i);}
    }
    for(int i = 1 ; i <= n ; ++i)
        if(!clr[i]) cout << i << ' ';
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int maxn = 1e6+19;
int fa[maxn] = {0},clr[maxn] = {0},dep[maxn],g[maxn<<1] = {0},now = 0,lst[maxn],fst[maxn],h[maxn<<1] = {0},n;
vector<int> e[maxn];
inline void add_edge(int u,int v) {e[u].push_back(v);}
inline int getid(int l,int r) {return (l+r)|(l<r);}

void dfs(int u,int p) {
    g[++now] = u;
    fst[u] = now;
    for(auto v:e[u]) if(v != p) {
        fa[v] = u;
        dep[v] = dep[u]+1;
        dfs(v,u);
    }
    g[++now] = u;
    lst[u] = now;
}

int qry(int x,int l,int r) {
    int num = getid(l,r),ans = 0,m = l+r>>1;
    ans += h[num];
    if(l == r) return ans;
    if(x <= m) ans += qry(x,l,m);
    else ans += qry(x,m+1,r);
    return ans;
}

void mdf(int ql,int qr,int l,int r) {
    int num = getid(l,r),m = l+r>>1;
    if(ql > r || qr < l) return ;
    if(ql <= l && qr >= r) {++h[num];return ;}
    mdf(ql,qr,l,m);mdf(ql,qr,m+1,r);
}

void paint(int u) {
    if(clr[u]) return ;
    mdf(fst[u],lst[u],1,n);
    clr[u] = 1;
    paint(fa[u]);
}

int main() {
    int k,u,v;
    cin >> n >> k;
    memset(dep,0,sizeof(dep));
    for(int i = 1 ; i < n ; ++i) {
        cin >> u >> v;
        add_edge(u,v);
        add_edge(v,u);
    }
    dep[n] = 1;
    dfs(n,0);
    k = n-k;
    for(int i = n ; i && k ; --i) {
        if(clr[i]) continue;
        int res = qry(fst[i],1,n);
        if(dep[i]-res <= k) {k -= dep[i]-res;paint(i);}
    }
    for(int i = 1 ; i <= n ; ++i)
        if(!clr[i]) cout << i << ' ';
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int maxn = 1e6+19;
int fa[maxn] = {0},clr[maxn] = {0},dep[maxn],g[maxn<<1] = {0},now = 0,lst[maxn],fst[maxn],h[maxn<<2] = {0},n;
vector<int> e[maxn];
inline void add_edge(int u,int v) {e[u].push_back(v);}
inline int getid(int l,int r) {return (l+r)|(l<r);}

void dfs(int u,int p) {
    g[++now] = u;
    fst[u] = now;
    for(auto v:e[u]) if(v != p) {
        fa[v] = u;
        dep[v] = dep[u]+1;
        dfs(v,u);
    }
    g[++now] = u;
    lst[u] = now;
}

int qry(int x,int l,int r) {
    int num = getid(l,r),ans = 0,m = l+r>>1;
    ans += h[num];
    if(l == r) return ans;
    if(x <= m) ans += qry(x,l,m);
    else ans += qry(x,m+1,r);
    return ans;
}

void mdf(int ql,int qr,int l,int r) {
    int num = getid(l,r),m = l+r>>1;
    if(ql > r || qr < l) return ;
    if(ql <= l && qr >= r) {++h[num];return ;}
    mdf(ql,qr,l,m);mdf(ql,qr,m+1,r);
}

void paint(int u) {
    if(clr[u]) return ;
    mdf(fst[u],lst[u],1,n);
    clr[u] = 1;
    paint(fa[u]);
}

int main() {
    int k,u,v;
    cin >> n >> k;
    memset(dep,0,sizeof(dep));
    for(int i = 1 ; i < n ; ++i) {
        cin >> u >> v;
        add_edge(u,v);
        add_edge(v,u);
    }
    dep[n] = 1;
    dfs(n,0);
    k = n-k;
    for(int i = n ; i && k ; --i) {
        if(clr[i]) continue;
        int res = qry(fst[i],1,n);
        if(dep[i]-res <= k) {k -= dep[i]-res;paint(i);}
    }
    for(int i = 1 ; i <= n ; ++i)
        if(!clr[i]) cout << i << ' ';
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int maxn = 1e6+19;
int fa[maxn] = {0},clr[maxn] = {0},dep[maxn],g[maxn<<1] = {0},now = 0,lst[maxn],fst[maxn],h[maxn<<1] = {0},n;
vector<int> e[maxn];
inline void add_edge(int u,int v) {e[u].push_back(v);}
inline int getid(int l,int r) {return (l+r)|(l<r);}

void dfs(int u,int p) {
    g[++now] = u;
    fst[u] = now;
    for(auto v:e[u]) if(v != p) {
        fa[v] = u;
        dep[v] = dep[u]+1;
        dfs(v,u);
    }
    g[++now] = u;
    lst[u] = now;
}

int qry(int x,int l,int r) {
    int num = getid(l,r),ans = 0,m = l+r>>1;
    ans += h[num];
    if(l == r) return ans;
    if(x <= m) ans += qry(x,l,m);
    else ans += qry(x,m+1,r);
    return ans;
}

void mdf(int ql,int qr,int l,int r) {
    int num = getid(l,r),m = l+r>>1;
    if(ql > r || qr < l) return ;
    if(ql <= l && qr >= r) {++h[num];return ;}
    mdf(ql,qr,l,m);mdf(ql,qr,m+1,r);
}

void paint(int u) {
    if(clr[u]) return ;
    mdf(fst[u],lst[u],1,n);
    clr[u] = 1;
    paint(fa[u]);
}

int main() {
    int k,u,v;
    cin >> n >> k;
    memset(dep,0,sizeof(dep));
    for(int i = 1 ; i < n ; ++i) {
        cin >> u >> v;
        add_edge(u,v);
        add_edge(v,u);
    }
    dep[n] = 1;
    dfs(n,0);
    k = n-k;
    for(int i = n ; i && k ; --i) {
        int res = qry(fst[i],1,n);
        if(dep[i]-res <= k) {k -= dep[i]-res;paint(i);}
    }
    for(int i = 1 ; i <= n ; ++i)
        if(!clr[i]) cout << i << ' ';
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int maxn = 1e6+19;
int fa[maxn] = {0},clr[maxn] = {0},dep[maxn],g[maxn<<1] = {0},now = 0,lst[maxn] = {0},fst[maxn] = {0},h[maxn<<2] = {0},n;
vector<int> e[maxn];
inline void add_edge(int u,int v) {e[u].push_back(v);}
inline int getid(int l,int r) {return (l+r)|(l<r);}

void dfs(int u,int p) {
    g[++now] = u;
    fst[u] = now;
    for(auto v:e[u]) if(v != p) {
        fa[v] = u;
        dep[v] = dep[u]+1;
        dfs(v,u);
    }
    g[++now] = u;
    lst[u] = now;
}

int qry(int x,int l,int r) {
    int num = getid(l,r),ans = 0,m = l+r>>1;
    ans += h[num];
    if(l == r) return ans;
    if(x <= m) ans += qry(x,l,m);
    else ans += qry(x,m+1,r);
    return ans;
}

void mdf(int ql,int qr,int l,int r) {
    int num = getid(l,r),m = l+r>>1;
    if(ql > r || qr < l) return ;
    if(ql <= l && qr >= r) {++h[num];return ;}
    mdf(ql,qr,l,m);mdf(ql,qr,m+1,r);
}

void paint(int u) {
    if(clr[u]) return ;
    mdf(fst[u],lst[u],1,2*n);
    clr[u] = 1;
    paint(fa[u]);
}

int main() {
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int k,u,v;
    cin >> n >> k;
    memset(dep,0,sizeof(dep));
    for(int i = 1 ; i < n ; ++i) {
        cin >> u >> v;
        add_edge(u,v);
        add_edge(v,u);
    }
    dep[n] = 1;
    dfs(n,0);
    k = n-k;
    for(int i = n ; i && k ; --i) {
        if(clr[i]) continue;
        int res = qry(fst[i],1,2*n);
        if(dep[i]-res <= k) {k -= dep[i]-res;paint(i);}
    }
    for(int i = 1 ; i <= n ; ++i)
        if(!clr[i]) cout << i << ' ';
    return 0;
}


//in the name of allah
#include<bits/stdc++.h>
#define double long double
#define f first
#define s second
typedef long long ll;
const ll MOD = 1e9+7;
const int MAX_N = 1e6+100;
const ll INF = 1e9;
const ll delta = 10957;
using namespace std;

short mark[MAX_N];
int len[MAX_N];
vector<int> g[MAX_N];
int par[MAX_N][21];
int n,k;

void dfs(int v,int p,int l)
{
    len[v] = l;
    par[v][0] = p;
    for(auto u:g[v])
        if (u!=p)
            dfs(u,v,l+1);
}
ll cnt;

bool check(int v)
{
    int l = 0;
    while(v)
    {
        int f = 0;
        while(par[v][f+1] and !mark[par[v][f]])
            f++;
        if (mark[par[v][f]] and !f)
        {
            l++;
            if (l+cnt>n-k)
                return false;
            return true;
        }
        if (mark[par[v][f]])
            f--;
        l+=1<<f;
        if (l+cnt>n-k)
            return false;
        v = par[v][f];
    }
    return false;
}

int main()
{
    ios::sync_with_stdio(false);
    cout.tie();
    cin.tie();
    cin >> n >> k;
    for(int i = 1;i<n;++i)
    {
        int u,v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(n,0,0);
    map<int,vector<int>> mp;
    for(int i = 1;i<=n;++i)
        mp[len[i]].push_back(i);
    for(auto x:mp)
    {
        if (!x.second.size())
            continue;
        for(auto v:x.second)
        {
            for(int i = 1;;++i)
            {
                int p = par[par[v][i-1]][i-1];
                if(!p)
                    break;
                par[v][i] = p;
            }
        }
    }
    mark[n]++;
    int cur = n;
    cnt = 1;
    while((cur--) and cnt<n-k)
    {
        if (mark[cur])
            continue;
        if (check(cur))
        {
            int x = cur;
            while(!mark[x] and x)
            {
                cnt++;
                mark[x] = 1;
                x = par[x][0];
            }
        }
    }
    for(int i = 1;i<=n;++i)
        if (!mark[i])
            cout << i << " ";
    return 0;
}


//in the name of allah
#include<bits/stdc++.h>
#define double long double
#define f first
#define s second
typedef long long ll;
const ll MOD = 1e9+7;
const int MAX_N = 1e6+100;
const ll INF = 1e9;
const ll delta = 10957;
using namespace std;

short mark[MAX_N];
int len[MAX_N];
vector<int> g[MAX_N];
int par[MAX_N][21];
int n,k;

void dfs(int v,int p,int l)
{
    len[v] = l;
    par[v][0] = p;
    for(auto u:g[v])
        if (u!=p)
            dfs(u,v,l+1);
}
ll cnt;

bool check(int v)
{
    int l = 0;
    while(v)
    {
        int f = 0;
        while(par[v][f+1] and !mark[par[v][f]])
            f++;
        if (mark[par[v][f]] and !f)
        {
            l++;
            if (l+cnt>n-k)
                return false;
            return true;
        }
        if (mark[par[v][f]])
            f--;
        l+=1<<f;
        if (l+cnt>n-k)
            return false;
        v = par[v][f];
    }
    return false;
}
// What the fuck?
int main()
{
    ios::sync_with_stdio(false);
    cout.tie();
    cin.tie();
    cin >> n >> k;
    for(int i = 1;i<n;++i)
    {
        int u,v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(n,0,0);
    map<int,vector<int>> mp;
    for(int i = 1;i<=n;++i)
        mp[len[i]].push_back(i);
    for(auto x:mp)
    {
        if (!x.second.size())
            continue;
        for(auto v:x.second)
        {
            for(int i = 1;;++i)
            {
                int p = par[par[v][i-1]][i-1];
                if(!p)
                    break;
                par[v][i] = p;
            }
        }
    }
    mark[n]++;
    int cur = n;
    cnt = 1;
    while((cur--) and cnt<n-k)
    {
        if (mark[cur])
            continue;
        if (check(cur))
        {
            int x = cur;
            while(!mark[x] and x)
            {
                cnt++;
                mark[x] = 1;
                x = par[x][0];
            }
        }
    }
    for(int i = 1;i<=n;++i)
        if (!mark[i])
            cout << i << " ";
    return 0;
}


//in the name of allah
#include<bits/stdc++.h>
#define double long double
#define f first
#define s second
typedef long long ll;
const ll MOD = 1e9+7;
const int MAX_N = 1e6+100;
const ll INF = 1e9;
const ll delta = 10957;
using namespace std;

short mark[MAX_N];
int len[MAX_N];
vector<int> g[MAX_N];
int par[MAX_N][21];
int n,k;

void dfs(int v,int p,int l)
{
    len[v] = l;
    par[v][0] = p;
    for(auto u:g[v])
        if (u!=p)
            dfs(u,v,l+1);
}
ll cnt;

bool check(int v)
{
    int l = 0;
    while(v)
    {
        int f = 0;
        while(par[v][f+1] and !mark[par[v][f]])
            f++;
        if (mark[par[v][f]] and !f)
        {
            l++;
            if (l+cnt>n-k)
                return false;
            return true;
        }
        if (mark[par[v][f]])
            f--;
        l+=1<<f;
        if (l+cnt>n-k)
            return false;
        v = par[v][f];
    }
    return false;
}
//what the fuck?
int main()
{
    ios::sync_with_stdio(false);
    cout.tie();
    cin.tie();
    cin >> n >> k;
    for(int i = 1;i<n;++i)
    {
        int u,v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    if (k==n-1)
    {
        for(int i = 1;i<n;++i)
            cout << i << " ";
        return 0;
    }
    dfs(n,0,0);
    map<int,vector<int>> mp;
    for(int i = 1;i<=n;++i)
        mp[len[i]].push_back(i);
    for(auto x:mp)
    {
        if (!x.second.size())
            continue;
        for(auto v:x.second)
        {
            for(int i = 1;;++i)
            {
                int p = par[par[v][i-1]][i-1];
                if(!p)
                    break;
                par[v][i] = p;
            }
        }
    }
    mark[n]++;
    int cur = n;
    cnt = 1;
    while((cur--) and cnt<n-k)
    {
        if (mark[cur])
            continue;
        if (check(cur))
        {
            int x = cur;
            while(!mark[x] and x)
            {
                cnt++;
                mark[x] = 1;
                x = par[x][0];
            }
        }
    }
    for(int i = 1;i<=n;++i)
        if (!mark[i])
            cout << i << " ";
    return 0;
}


//in the name of allah
#include<bits/stdc++.h>
#define double long double
#define f first
#define s second
typedef long long ll;
const ll MOD = 1e9+7;
const int MAX_N = 1e6+100;
const ll INF = 1e9;
const ll delta = 10957;
using namespace std;

short mark[MAX_N];
int len[MAX_N];
vector<int> g[MAX_N];
int par[MAX_N][21];
int n,k;

void dfs(int v,int p,int l)
{
    len[v] = l;
    par[v][0] = p;
    for(int i = 1;;++i)
    {
        int pf = par[par[v][i-1]][i-1];
        if (!pf)
            break;
        par[v][i] = pf;
    }
    for(auto u:g[v])
        if (u!=p)
            dfs(u,v,l+1);
}
ll cnt;

bool check(int v)
{
    int l = 0;
    while(v)
    {
        int f = 0;
        while(par[v][f+1] and !mark[par[v][f]])
            f++;
        if (mark[par[v][f]] and !f)
        {
            l++;
            if (l+cnt>n-k)
                return false;
            return true;
        }
        if (mark[par[v][f]])
            f--;
        l+=1<<f;
        if (l+cnt>n-k)
            return false;
        v = par[v][f];
    }
    return false;
}

int main()
{
    ios::sync_with_stdio(false);
    cout.tie();
    cin.tie();
    cin >> n >> k;
    for(int i = 1;i<n;++i)
    {
        int u,v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(n,0,0);
    mark[n]++;
    int cur = n;
    cnt = 1;
    while((cur--) and cnt<n-k)
    {
        if (mark[cur])
            continue;
        if (check(cur))
        {
            int x = cur;
            while(!mark[x] and x)
            {
                cnt++;
                mark[x] = 1;
                x = par[x][0];
            }
        }
    }
    for(int i = 1;i<=n;++i)
        if (!mark[i])
            cout << i << " ";
    return 0;
}


//in the name of allah
#include<bits/stdc++.h>
#define double long double
#define f first
#define s second
typedef long long ll;
const ll MOD = 1e9+7;
const int MAX_N = 1e6+100;
const ll INF = 1e9;
const ll delta = 10957;
using namespace std;

short mark[MAX_N];
int len[MAX_N];
vector<int> g[MAX_N];
int par[MAX_N][21];
int n,k;

void dfs(int v,int p,int l)
{
    len[v] = l;
    par[v][0] = p;
    for(auto u:g[v])
        if (u!=p)
            dfs(u,v,l+1);
}
ll cnt;

bool check(int v)
{
    int l = 0;
    while(v)
    {
        int f = 0;
        while(par[v][f+1] and !mark[par[v][f]])
            f++;
        if (mark[par[v][f]] and !f)
        {
            l++;
            if (l+cnt>n-k)
                return false;
            return true;
        }
        if (mark[par[v][f]])
            f--;
        l+=1<<f;
        if (l+cnt>n-k)
            return false;
        v = par[v][f];
    }
    return false;
}

int main()
{
    ios::sync_with_stdio(false);
    cout.tie();
    cin.tie();
    cin >> n >> k;
    for(int i = 1;i<n;++i)
    {
        int u,v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    if (k==n-1)
    {
        for(int i = 1;i<n;++i)
            cout << i << " ";
        return 0;
    }
    dfs(n,0,0);
    map<int,vector<int>> mp;
    for(int i = 1;i<=n;++i)
        mp[len[i]].push_back(i);
    for(auto x:mp)
    {
        if (!x.second.size())
            continue;
        for(auto v:x.second)
        {
            for(int i = 1;;++i)
            {
                int p = par[par[v][i-1]][i-1];
                if(!p)
                    break;
                par[v][i] = p;
            }
        }
    }
    mark[n]++;
    int cur = n;
    cnt = 1;
    while((cur--) and cnt<n-k)
    {
        if (mark[cur])
            continue;
        if (check(cur))
        {
            int x = cur;
            while(!mark[x] and x)
            {
                cnt++;
                mark[x] = 1;
                x = par[x][0];
            }
        }
    }
    for(int i = 1;i<=n;++i)
        if (!mark[i])
            cout << i << " ";
    return 0;
}


//in the name of allah
#include<bits/stdc++.h>
#define double long double
#define maximum(s,e) *max_element(s,e)
#define minimum(s,e) *min_element(s,e)
typedef long long ll;
const ll MOD = 1e9+7;
const int MAX_N =1e6+100;
const ll INF = 1e18;
const ll delta = 10957;
using namespace std;

bool mark[MAX_N];
set<int> g[MAX_N];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie();
    cout.tie();
    int n,k;
    cin >> n >> k;
    for(int i = 1;i<n;++i)
    {
        int a,b;
        cin >> a >> b;
        g[a].insert(b);
        g[b].insert(a);
    }
    set<int> leaves;
    for(int i = 1;i<=n;++i)
    {
        if (g[i].size()==1)
            leaves.insert(i);
    }
    vector<int> ans;
    for(int i = 1;i<=k;++i)
    {
        ans.push_back(*leaves.begin());
        int v = *leaves.begin();
        leaves.erase(leaves.begin());
        int u = *g[v].begin();
        g[u].erase(v);
        if (g[u].size()==1)
            leaves.insert(u);
    }
    sort(ans.begin(),ans.end());
    for(auto x:ans)
        cout << x << " ";
    return 0;
}


#include<bits/stdc++.h>
#define MAXN 1000001
using namespace std;
vector<int> vec[MAXN];
int n,k;
int depth[MAXN];
int a[MAXN][21];
bool vis[MAXN];
void dfs(int now){
    vis[now]=1;
    for(int i=1; i<=20; i++){
        if(1<<i+1>depth[now]) break;
        a[now][i]=a[a[now][i-1]][i-1];
    }
    for(int i=0; i<vec[now].size(); i++){
        int v=vec[now][i];
        if(vis[v]) continue;
        depth[v]=depth[now]+1;
        a[v][0]=now;
        dfs(v);
    }
}
int main(){
    scanf("%d%d",&n,&k);
    for(int i=1; i<=n-1; i++){
        int u,v;
        scanf("%d%d",&u,&v);
        vec[u].push_back(v);
        vec[v].push_back(u);
    }
    depth[n]=1;
    dfs(n);
    int m=n-k-1;
    memset(vis,0,sizeof(vis));
    vis[0]=1;
    vis[n]=1;
    for(int i=n-1; i>=1; i--){
        if(vis[i]) continue;
        else{
            int p=i;
            for(int j=20; j>=0; j--){
                if(vis[a[p][j]]==1) continue;
                else p=a[p][j],j=j+1;
            }
            if(depth[i]-depth[p]>=m) continue;
            else{
                int kk=i;
                while(vis[kk]==0){
                    m-=1;
                    vis[kk]=1;
                    kk=a[kk][0];
                }
            }
        }
    }
    for(int i=1; i<=n; i++){
        if(vis[i]==0) printf("%d ",i);
    }
    return 0;
}


#include<bits/stdc++.h>
#define MAXN 1000005
using namespace std;
vector<int> vec[MAXN];
int n,k;
int depth[MAXN];
int a[MAXN][50];
bool vis[MAXN];
void dfs(int now){
    vis[now]=1;
    for(int i=1; i<=20; i++){
        if(1<<i+1>depth[now]) break;
        a[now][i]=a[a[now][i-1]][i-1];
    }
    for(int i=0; i<vec[now].size(); i++){
        int v=vec[now][i];
        if(vis[v]) continue;
        depth[v]=depth[now]+1;
        a[v][0]=now;
        dfs(v);
    }
}
int main(){
    scanf("%d%d",&n,&k);
    for(int i=1; i<=n-1; i++){
        int u,v;
        scanf("%d%d",&u,&v);
        vec[u].push_back(v);
        vec[v].push_back(u);
    }
    depth[n]=1;
    dfs(n);
    int m=n-k-1;
    memset(vis,0,sizeof(vis));
    vis[0]=1;
    vis[n]=1;
    for(int i=n-1; i>=1; i--){
        if(vis[i]) continue;
        else{
            int p=i;
            for(int j=20; j>=0; j--){
                if(vis[a[p][j]]==1) continue;
                else p=a[p][j];
            }
            if(depth[i]-depth[p]>=m) continue;
            else{
                int kk=i;
                while(vis[kk]==0){
                    m-=1;
                    vis[kk]=1;
                    kk=a[kk][0];
                }
            }
        }
    }
    for(int i=1; i<=n; i++){
        if(vis[i]==0) printf("%d ",i);
    }
    return 0;
}


#include<bits/stdc++.h>
#define MAXN 1000005
using namespace std;
vector<int> vec[MAXN];
int n,k;
int depth[MAXN];
int a[MAXN][50];
bool vis[MAXN];
void dfs(int now){
    vis[now]=1;
    for(int i=1; i<=20; i++){
        if(1<<i+1>depth[now]) break;
        a[now][i]=a[a[now][i-1]][i-1];
    }
    for(int i=0; i<vec[now].size(); i++){
        int v=vec[now][i];
        if(vis[v]) continue;
        depth[v]=depth[now]+1;
        a[v][0]=now;
        dfs(v);
    }
}
int main(){
    scanf("%d%d",&n,&k);
    for(int i=1; i<=n-1; i++){
        int u,v;
        scanf("%d%d",&u,&v);
        vec[u].push_back(v);
        vec[v].push_back(u);
    }
    depth[n]=1;
    dfs(n);
    int m=n-k-1;
    memset(vis,0,sizeof(vis));
    vis[0]=1;
    vis[n]=1;
    for(int i=n-1; i>=1; i--){
        if(vis[i]) continue;
        else{
            int p=i;
            for(int j=20; j>=0; j--){
                if(vis[a[p][j]]==1) continue;
                else p=a[p][j],j=j+1;
            }
            if(depth[i]-depth[p]>=m) continue;
            else{
                int kk=i;
                while(vis[kk]==0){
                    m-=1;
                    vis[kk]=1;
                    kk=a[kk][0];
                }
            }
        }
    }
    for(int i=1; i<=n; i++){
        if(vis[i]==0) printf("%d ",i);
    }
    return 0;
}


#include<bits/stdc++.h>
#define MAXN 1000005
using namespace std;
vector<int> vec[MAXN];
int n,k;
int depth[MAXN];
int a[MAXN][50];
bool vis[MAXN];
void dfs(int now){
	vis[now]=1;
	for(int i=1; i<=20; i++){
		if(1<<i+1>depth[now]) break;
		a[now][i]=a[a[now][i-1]][i-1];
	}
	for(int i=0; i<vec[now].size(); i++){
		int v=vec[now][i];
		if(vis[v]) continue;
		depth[v]=depth[now]+1;
		a[v][0]=now;
		dfs(v);
	}
}
set<int> s;
set<int>::iterator p;
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1; i<=n-1; i++){
		int u,v;
		scanf("%d%d",&u,&v);
		vec[u].push_back(v);
		vec[v].push_back(u);
	}
	depth[n]=1;
	dfs(n);
	s.insert(n);
	int m=n-k-1;
	memset(vis,0,sizeof(vis));
	vis[0]=1;
	for(int i=n-1; i>=1; i--){
		if(vis[i]) continue;
		else{
			int p=i;
			for(int j=20; j>=0; j--){
				if(vis[a[p][j]]==1) continue;
				else p=a[p][j];
			}
			if(depth[i]-depth[p]>m) continue;
			else{
				m-=depth[i]-depth[p]+1;
				int kk=i;
				while(kk!=a[p][0]){
					vis[kk]=1;
					s.insert(kk);
					kk=a[kk][0];
				}
			}
		}
	}
	for(int i=1; i<=n; i++){
		if(s.count(i)) continue;
		else printf("%d ",i);
	}
	return 0;
}


#include<bits/stdc++.h>
#define MAXN 1000005
using namespace std;
vector<int> vec[MAXN];
int n,k;
int depth[MAXN];
int a[MAXN][50];
bool vis[MAXN];
void dfs(int now){
    vis[now]=1;
    for(int i=1; i<=20; i++){
        if(1<<i+1>depth[now]) break;
        a[now][i]=a[a[now][i-1]][i-1];
    }
    for(int i=0; i<vec[now].size(); i++){
        int v=vec[now][i];
        if(vis[v]) continue;
        depth[v]=depth[now]+1;
        a[v][0]=now;
        dfs(v);
    }
}
int main(){
    scanf("%d%d",&n,&k);
    for(int i=1; i<=n-1; i++){
        int u,v;
        scanf("%d%d",&u,&v);
        vec[u].push_back(v);
        vec[v].push_back(u);
    }
    depth[n]=1;
    dfs(n);
    int m=n-k-1;
    memset(vis,0,sizeof(vis));
    vis[0]=1;
    vis[n]=1;
    for(int i=n-1; i>=1; i--){
        if(vis[i]) continue;
        else{
            int p=i;
            for(int j=20; j>=0; j--){
                if(vis[a[p][j]]==1) continue;
                else p=a[p][j];
            }
            if(depth[i]-depth[p]>=m) continue;
            else{
                int kk=i;
                while(vis[kk]==0){
                    m-=1;
                    vis[kk]=1;
                    kk=a[kk][0];
                }
            }
        }
    }
    for(int i=1; i<=n; i++){
        if(vis[i]==0) printf("%d ",i);
    }//
    return 0;
}


#include<bits/stdc++.h>
#define MAXN 1000005
using namespace std;
vector<int> vec[MAXN];
int n,k;
int depth[MAXN];
int a[MAXN][50];
bool vis[MAXN];
void dfs(int now){
	vis[now]=1;
	for(int i=1; i<=20; i++){
		if(1<<i+1>depth[now]) break;
		a[now][i]=a[a[now][i-1]][i-1];
	}
	for(int i=0; i<vec[now].size(); i++){
		int v=vec[now][i];
		if(vis[v]) continue;
		depth[v]=depth[now]+1;
		a[v][0]=now;
		dfs(v);
	}
}
set<int> s;
set<int>::iterator p;
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1; i<=n-1; i++){
		int u,v;
		scanf("%d%d",&u,&v);
		vec[u].push_back(v);
		vec[v].push_back(u);
	}
	depth[n]=1;
	dfs(n);
	s.insert(n);
	int m=n-k-1;
	memset(vis,0,sizeof(vis));
	vis[0]=1;
	vis[n]=1;
	for(int i=n-1; i>=1; i--){
		if(vis[i]) continue;
		else{
			int p=i;
			for(int j=20; j>=0; j--){
				if(vis[a[p][j]]==1) continue;
				else p=a[p][j];
			}
			if(depth[i]-depth[p]>=m) continue;
			else{
				m-=depth[i]-depth[p]+1;
				int kk=i;
				while(kk!=a[p][0]){
					vis[kk]=1;
					s.insert(kk);
					kk=a[kk][0];
				}
			}
		}
	}
	for(int i=1; i<=n; i++){
		if(s.count(i)) continue;
		else printf("%d ",i);
	}
	return 0;
}


#include<bits/stdc++.h>
#define MAXN 1000001
using namespace std;
vector<int> vec[MAXN];
int n,k;
int depth[MAXN];
int a[MAXN][21];
bool vis[MAXN];
void dfs(int now){
    vis[now]=1;
    for(int i=1; i<=20; i++){
        if(1<<i+1>depth[now]) break;
        a[now][i]=a[a[now][i-1]][i-1];
    }
    for(int i=0; i<vec[now].size(); i++){
        int v=vec[now][i];
        if(vis[v]) continue;
        depth[v]=depth[now]+1;
        a[v][0]=now;
        dfs(v);
    }
}
int main(){
    scanf("%d%d",&n,&k);
    for(int i=1; i<=n-1; i++){
        int u,v;
        scanf("%d%d",&u,&v);
        vec[u].push_back(v);
        vec[v].push_back(u);
    }
    depth[n]=1;
    dfs(n);
    int m=n-k-1;
    memset(vis,0,sizeof(vis));
    vis[0]=1;
    vis[n]=1;
    for(int i=n-1; i>=1; i--){
        if(vis[i]) continue;
        else{
            int p=i;
            for(int j=20; j>=0; j--){
                if(vis[a[p][j]]==1) continue;
                else p=a[p][j],j=j+1;
            }
            if(depth[i]-depth[p]>=m) continue;
            else{
                int kk=i;
                while(vis[kk]==0){
                    m-=1;
                    vis[kk]=1;
                    kk=a[kk][0];
                }
            }
        }
    }
    for(int i=1; i<=n; i++){
        if(vis[i]==0) printf("%d ",i);
    }//
    return 0;
}


#include<bits/stdc++.h>
#define MAXN 1000005
using namespace std;
vector<int> vec[MAXN];
int n,k;
int depth[MAXN];
int a[MAXN][50];
bool vis[MAXN];
void dfs(int now){
	vis[now]=1;
	for(int i=1; i<=20; i++){
		if(1<<i+1>depth[now]) break;
		a[now][i]=a[a[now][i-1]][i-1];
	}
	for(int i=0; i<vec[now].size(); i++){
		int v=vec[now][i];
		if(vis[v]) continue;
		depth[v]=depth[now]+1;
		a[v][0]=now;
		dfs(v);
	}
}
set<int> s;
set<int>::iterator p;
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1; i<=n-1; i++){
		int u,v;
		scanf("%d%d",&u,&v);
		vec[u].push_back(v);
		vec[v].push_back(u);
	}
	depth[n]=1;
	dfs(n);
	s.insert(n);
	int m=n-k-1;
	memset(vis,0,sizeof(vis));
	vis[0]=1;
	vis[n]=1;
	for(int i=n-1; i>=1; i--){
		if(vis[i]) continue;
		else{
			int p=i;
			for(int j=20; j>=0; j--){
				if(vis[a[p][j]]==1) continue;
				else p=a[p][j];
			}
			if(depth[i]-depth[p]>=m) continue;
			else{
				int kk=i;
				while(vis[kk]==0){
					m-=1;
					vis[kk]=1;
					s.insert(kk);
					kk=a[kk][0];
				}
			}
		}
	}
	for(int i=1; i<=n; i++){
		if(s.count(i)) continue;
		else printf("%d ",i);
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=1e6+7;
int n,k,fa[N][21],dep[N],cnt=0;
int head[N],edge[2*N],to[2*N];
bool flag[N];
inline void add(int x,int y) {
    edge[++cnt]=head[x];
    head[x]=cnt; to[cnt]=y;
}
void dfs(int u,int pa) {
    fa[u][0]=pa;
    dep[u]=dep[pa]+1;
    for (int i=1;(1<<i)<=dep[u];i++) {
        fa[u][i]=fa[fa[u][i-1]][i-1];
    }
    for (int i=head[u];i!=-1;i=edge[i]) {
        int v=to[i];
        if (v==pa) continue;
        dfs(v,u);
    }
}
void work(int u) {
    int v=u;
    for (int i=20;i>=0;i--) {
        if (!flag[fa[u][i]]) u=fa[u][i];
    }
    if (k<dep[v]-dep[u]+1) return ;
    k-=dep[v]-dep[u]+1;
    flag[u]=true;
    for (;v!=u;v=fa[v][0]) {
        flag[v]=true;
    }
}
int main() {
    scanf("%d%d",&n,&k); k=n-k;
    memset(head,-1,sizeof(head));
    memset(flag,false,sizeof(flag));
    int x,y;
    for (int i=1;i<n;i++) {
        scanf("%d%d",&x,&y);
        add(x,y); add(y,x);
    }
    flag[0]=flag[n]=true;
    dfs(n,0);
    for (int i=n;i>=1;i--) {
        if (k!=0 && !flag[i]) work(i);
    }
    for (int i=1;i<=n;i++) {
        if (!flag[i]) printf("%d ",i);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=1e6+7;
int n,k,fa[N][21],dep[N],cnt=0;
int head[N],edge[2*N],to[2*N];
bool flag[N];
inline void add(int x,int y) {
    edge[++cnt]=head[x];
    head[x]=cnt; to[cnt]=y;
}
void dfs(int u,int pa) {
    fa[u][0]=pa;
    dep[u]=dep[pa]+1;
    for (int i=1;(1<<i)<=dep[u];i++) {
        fa[u][i]=fa[fa[u][i-1]][i-1];
    }
    for (int i=head[u];i!=-1;i=edge[i]) {
        int v=to[i];
        if (v==pa) continue;
        dfs(v,u);
    }
}
void work(int u) {
    int v=u;
    for (int i=20;i>=0;i--) {
        if (!flag[fa[u][i]]) u=fa[u][i];
    }
    if (k<dep[v]-dep[u]+1) return ;
    k-=dep[v]-dep[u]+1;
    flag[u]=true;
    for (;v!=u;v=fa[v][0]) {
        flag[v]=true;
    }
}
int main() {
    scanf("%d%d",&n,&k); k=n-k-1;
    memset(head,-1,sizeof(head));
    memset(flag,false,sizeof(flag));
    int x,y;
    for (int i=1;i<n;i++) {
        scanf("%d%d",&x,&y);
        add(x,y); add(y,x);
    }
    flag[0]=flag[n]=true;
    dfs(n,0);
    for (int i=n;i>=1;i--) {
        if (k!=0 && !flag[i]) work(i);
    }
    for (int i=1;i<=n;i++) {
        if (!flag[i]) printf("%d ",i);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=1e6+7;
int n,k,fa[N][21],dep[N],cnt=0;
int head[N],edge[2*N],to[2*N];
bool flag[N];
inline void add(int x,int y) {
    edge[++cnt]=head[x];
    head[x]=cnt; to[cnt]=y;
}
void dfs(int u,int pa) {
    fa[u][0]=pa;
    dep[u]=dep[pa]+1;
    for (int i=1;(1<<i)<=dep[u];i++) {
        fa[u][i]=fa[fa[u][i-1]][i-1];
    }
    for (int i=head[u];i!=-1;i=edge[i]) {
        int v=to[i];
        if (v==pa) continue;
        dfs(v,u);
    }
}
void work(int u) {
    int v=u;
    for (int i=20;i>=0;i--) {
        if (!flag[fa[u][i]]) u=fa[u][i];
    }
    if (k<dep[v]-dep[u]+1) return ;
    k-=dep[v]-dep[u]+1;
    flag[u]=true;
    for (;v!=u;v=fa[v][0]) {
        flag[v]=true;
    }
}
int main() {
    scanf("%d%d",&n,&k); k=n-k;
    memset(head,-1,sizeof(head));
    memset(flag,false,sizeof(flag));
    int x,y;
    for (int i=1;i<n;i++) {
        scanf("%d%d",&x,&y);
        add(x,y); add(y,x);
    }
    flag[0]=flag[n]=true;
    dfs(n,0);
    for (int i=n;i>=1;i--) {
        if (k!=0) work(i);
    }
    for (int i=1;i<=n;i++) {
        if (!flag[i]) printf("%d ",i);
    }
    return 0;
}


#include<map>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cstring>
using namespace std;
const int N=1e6+7;
int n,k,fa[N][21],dep[N],cnt=0;
int head[N],edge[2*N],to[2*N];
bool flag[N];
inline void add(int x,int y) {
    edge[++cnt]=head[x];
    head[x]=cnt; to[cnt]=y;
}
void dfs(int u,int pa) {
    fa[u][0]=pa;
    dep[u]=dep[pa]+1;
    for (int i=1;(1<<i)<=dep[u];i++) {
        fa[u][i]=fa[fa[u][i-1]][i-1];
    }
    for (int i=head[u];i!=-1;i=edge[i]) {
        int v=to[i];
        if (v==pa) continue;
        dfs(v,u);
    }
}
void work(int u) {
    int v=u;
    for (int i=20;i>=0;i--) {
        if (!flag[fa[u][i]]) u=fa[u][i];
    }
    if (k<dep[v]-dep[u]+1) return ;
    k-=dep[v]-dep[u]+1;
    flag[u]=true;
    for (;v!=u;v=fa[v][0]) {
        flag[v]=true;
    }
}
int main() {
    scanf("%d%d",&n,&k); k=n-k-1;
    memset(head,-1,sizeof(head));
    memset(flag,false,sizeof(flag));
    int x,y;
    for (int i=1;i<n;i++) {
        scanf("%d%d",&x,&y);
        add(x,y); add(y,x);
    }
    flag[0]=flag[n]=true;
    dfs(n,0);
    for (int i=n;i>=1;i--) {
        if (k!=0 && !flag[i]) work(i);
    }
    for (int i=1;i<=n;i++) {
        if (!flag[i]) printf("%d ",i);
    }
    return 0;
}