#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #include #include #include using namespace std; struct UnionFind { private: int n; vector par,siz; public: UnionFind(int n) :n(n),par(n,-1),siz(n,1) {} int root(int u) { assert(0 <= u && u < n); return (par[u] < 0 ? u:par[u] = root(par[u])); } bool same(int u,int v) { assert(0 <= u && u < n && 0 <= v && v < n); return root(u) == root(v); } bool unite(int u,int v) { assert(0 <= u && u < n && 0 <= v && v < n); u = root(u),v = root(v); if(u == v) return false; if(siz[u] < siz[v]) swap(u,v); siz[u] += siz[v]; par[v] = u; return true; } int size(int u) { assert(0 <= u && u < n); return siz[root(u)]; } vector> components() { vector> ret(n); for(int u = 0;u < n;u++) ret[root(u)].push_back(u); ret.erase(remove_if(ret.begin(),ret.end(),[](vector v) { return v.empty();}),ret.end()); return ret; } }; void Main() { int N,M; cin >> N >> M; int s,t,k; cin >> s >> t >> k; s--; t--; vector> G(N); UnionFind uf(N); for(int i = 0;i < M;i++) { int u,v; cin >> u >> v; u--; v--; G[u].push_back(v); G[v].push_back(u); uf.unite(u,v); } if(uf.same(s,t)) { vector C(N,-1); auto dfs = [&](auto dfs,int u,int c) -> void { C[u] = c; for(int v : G[u]) { if(C[v] == -1) { dfs(dfs,v,1 - c); } } }; dfs(dfs,s,0); if(C[s] == C[t] && k % 2 == 1) { cout << "No\n"; return; } if(C[s] != C[t] && k % 2 == 0) { cout << "No\n"; return; } vector dp(N,-1); dp[s] = 0; queue Q; Q.push(s); while(!Q.empty()) { int u = Q.front(); Q.pop(); for(int v : G[u]) { if(dp[v] == -1) { dp[v] = dp[u] + 1; Q.push(v); } } } if(dp[t] <= k) { cout << "Yes\n"; } else { cout << "Unknown\n"; } } else { cout << "Unknown\n"; } } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int tt = 1; /* cin >> tt; */ while(tt--) Main(); }