#include using namespace std; struct Dsu{ vector p; vector r; Dsu() = delete; Dsu(int n){ p.resize(n); for (int i=n; i--;) p[i]=i; r.resize(n); } int root(int a){ return p[a]==a? a: p[a]=root(p[a]); } void merge(int a,int b){ a=root(a); b=root(b); if (r[a]>n>>m; vector h(n); vector> e(n); for (int i=0; i>h[i]; } for (int i=0; i>a>>b; --a,--b; e[a].push_back(b); e[b].push_back(a); } assert(!(cin>>m)); vector> by_height(n); for (int i=0; i0 and by_height[i]==by_height[i-1])) continue; if (by_height[i].first>max(h[0],h[1])) break; Dsu d(n); for (auto jt=by_height.begin()+i; jt!=by_height.end(); ++jt){ for (int k: e[jt->second]){ if (by_height[i].first<=h[k] and h[k]<=jt->first){ d.merge(jt->second, k); } } if (d.root(0)==d.root(1)){ best=min(best,jt->first-by_height[i].first); break; } } } if (best==impossible){ cout<<"impossible"<