#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=5e5+5,M=5e6+5,Inf=1e9;
int n,m,s,k;
int u,v,w;
struct edge {
int fr,to,vl;
bool xd;
} cur[M];
vector<edge> st[2];
int cnt;
int fa[M];
int find(int pos) {
if(pos==fa[pos]) return pos;
else return fa[pos]=find(fa[pos]);
}
bool cmp(edge x,edge y) {
if(x.vl==y.vl) return 1;
else return x.vl<y.vl;
}
ll ksk() {
for(int i=1;i<=n;i++) fa[i]=i;
int x=0,y=0,tot=0;
while(x<st[0].size()&&y<st[1].size()) {
if(cmp(st[0][x],st[1][y])) cur[++tot]=st[0][x],x++;
else cur[++tot]=st[1][y],y++;
}
while(x<st[0].size()) cur[++tot]=st[0][x],x++;
while(y<st[1].size()) cur[++tot]=st[1][y],y++;
tot=cnt=0;
ll ans=0;
for(int i=1;i<=m;i++) {
if(find(cur[i].fr)==find(cur[i].to)) continue;
fa[fa[cur[i].to]]=cur[i].fr,ans+=cur[i].vl,tot++;
if(cur[i].xd) cnt++;
if(tot==n-1) return ans;
}
}
int main() {
cin>>n>>m>>s>>k;
for(int i=1;i<=m;i++) {
cin>>u>>v>>w;
if(u==s||v==s) st[0].push_back({u,v,w,true});
else st[1].push_back({u,v,w,false});
}
sort(st[0].begin(),st[0].end(),cmp);
sort(st[1].begin(),st[1].end(),cmp);
int l=-Inf,r=Inf;
for(int i=0;i<st[0].size();i++) st[0][i].vl+=l;
ksk();
if(cnt<k) {cout<<"Impossible";return 0;}
for(int i=0;i<st[0].size();i++) st[0][i].vl-=l;
for(int i=0;i<st[0].size();i++) st[0][i].vl+=r;
ksk();
if(cnt>k) {cout<<"Impossible";return 0;}
for(int i=0;i<st[0].size();i++) st[0][i].vl-=r;
while(l<r) {
int mid=(l+r+1)/2;
for(int i=0;i<st[0].size();i++) st[0][i].vl+=mid;
ksk();
for(int i=0;i<st[0].size();i++) st[0][i].vl-=mid;
if(cnt>=k) l=mid;
else r=mid-1;
}
for(int i=0;i<st[0].size();i++) st[0][i].vl+=r;
cout<<ksk()-1ll*k*r;
}