#include using namespace std; using ll=long long; int main(){ int n,k; cin>>n>>k; vector> g(n); for (int i = 0; i < n-1; ++i) { int a,b; cin>>a>>b; g[a].emplace_back(b); g[b].emplace_back(a); } if(k>n){ cout<<-1<