#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#include <stack>
using namespace std;
#define ll long long
#define ull unsigned long long
#define up(i, a, b) for (int i = (a); i <= (b); i++)
#define down(i, a, b) for (int i = (a); i >= (b); i--)
#define mem(x, y) memset(x, (y), sizeof x)
#define ff first
#define ss second
#define mp(x, y) make_pair(x, y)
#define pb(x) push_back(x)
#define sc(a) scanf("%d", &a)
#define scl(a) scanf("%lld", &a)
#define scs(a) scanf("%s", a)
#define pr(a, b) printf("%d%c", a, b)
#define prl(a, b) printf("%lld%c", a, b)
#define PQ priority_queue
#define ld long double
#define all(v) v.begin(), v.end()
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)

typedef pair<ll, int> pii;
typedef map<int, int> mii;
typedef vector<int> V;

const int N=3e5+10;
pair<pii,int> a[N];
vector<pair<pii,int>>v[810];
set<int>s[810];
mii mp;
int mapp[N],f[N],vis[N];
ll w[810][810];
ll ans[330010];
void floyd(int n) {
	up(i,1,n)up(o,1,n)up(p,1,n)if(w[i][o]>w[i][p]+w[p][o])w[i][o]=w[i][p]+w[p][o];
}
int find(int x) {
	return f[x]==x?x:f[x]=find(f[x]);
}
void add(int x,int y) {
	int fx=find(x),fy=find(y);
	if(fx!=fy)f[fx]=fy;
}
int main() {
	int n,m,k;
	sc(n),sc(m),sc(k);
	up(i,1,m)sc(a[i].ff.ff),sc(a[i].ff.ss),sc(a[i].ss),mp[a[i].ss]++;
	sort(a+1,a+1+m,[](pair<pii,int> a,pair<pii,int> b) {
		return a.ss<b.ss;
	});
	if(m<k) {
		mp.clear();
		up(i,1,m)mp[a[i].ff.ff]++,mp[a[i].ff.ss]++;
		int c=0;
		for(auto i:mp)mp[i.ff]=++c;
		up(i,1,c)up(o,1,c)w[i][o]=1e17;
		up(i,1,m)w[mp[a[i].ff.ss]][mp[a[i].ff.ff]]=w[mp[a[i].ff.ff]][mp[a[i].ff.ss]]=a[i].ss;
		floyd(c);
		up(i,1,c)up(o,i+1,c)if(w[i][o]<1e17)ans[++ans[0]]=w[i][o];
		sort(ans+1,ans+1+ans[0]);
		prl(ans[k],'\n');
		return 0;
	}
	int end;
	up(i,1,k)
	if(a[i].ss==a[k].ss) {
		end=i-1;
		break;
	}

	up(i,1,n)f[i]=i;
	up(i,1,end)add(a[i].ff.ff,a[i].ff.ss),vis[a[i].ff.ff]++,vis[a[i].ff.ss]++;
	up(i,1,end)add(a[i].ff.ff,a[i].ff.ss);
	int c=0;
	up(i,1,n)if(f[i]==i&&vis[i])mapp[i]=++c;
//	up(i,1,n)pr(f[i],' ');printf("\n");
	up(i,1,end) {
		int ind=mapp[f[a[i].ff.ff]];
		s[ind].insert(a[i].ff.ff),s[ind].insert(a[i].ff.ss);
		v[ind].pb(mp(mp(a[i].ff.ff,a[i].ff.ss),a[i].ss));
	}
	up(p,1,c) {
		int si=s[p].size();
		up(i,1,si)up(o,1,si)w[i][o]=1e17;
		int j=0;
		for(auto i:s[p])mapp[i]=++j;
		for(auto i:v[p])w[mapp[i.ff.ff]][mapp[i.ff.ss]]=w[mapp[i.ff.ss]][mapp[i.ff.ff]]=i.ss;
		floyd(si);
		up(i,1,si)up(o,i+1,si)if(w[i][o]<1e17)ans[++ans[0]]=w[i][o];
	}
	sort(ans+1,ans+1+ans[0]);
	int index=upper_bound(ans+1,ans+1+ans[0],a[k].ss)-ans-2;
	if(index>=k)prl(ans[k],'\n');
	else pr(a[k].ss,'\n');
}


#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#include <stack>
using namespace std;
#define ll long long
#define ull unsigned long long
#define up(i, a, b) for (int i = (a); i <= (b); i++)
#define down(i, a, b) for (int i = (a); i >= (b); i--)
#define mem(x, y) memset(x, (y), sizeof x)
#define ff first
#define ss second
#define mp(x, y) make_pair(x, y)
#define pb(x) push_back(x)
#define sc(a) scanf("%d", &a)
#define scl(a) scanf("%lld", &a)
#define scs(a) scanf("%s", a)
#define pr(a, b) printf("%d%c", a, b)
#define prl(a, b) printf("%lld%c", a, b)
#define PQ priority_queue
#define ld long double
#define all(v) v.begin(), v.end()
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)

typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> V;

const int N=3e5+10;
pair<pii,int> a[N];
vector<pair<pii,int>>v[810];
set<int>s[810];
mii mp;
int mapp[N],f[N],vis[N];
ll w[810][810];
ll ans[330010];
void floyd(int n) {
	up(p,1,n)up(i,1,n)up(o,1,n)if(w[i][o]>w[i][p]+w[p][o])w[i][o]=w[i][p]+w[p][o];
}
int find(int x) {
	return f[x]==x?x:f[x]=find(f[x]);
}
void add(int x,int y) {
	int fx=find(x),fy=find(y);
	if(fx!=fy)f[fx]=fy;
}
int main() {
	int n,m,k;
	sc(n),sc(m),sc(k);
	up(i,1,m)sc(a[i].ff.ff),sc(a[i].ff.ss),sc(a[i].ss),mp[a[i].ss]++;
	sort(a+1,a+1+m,[](pair<pii,int> a,pair<pii,int> b) {
		return a.ss<b.ss;
	});
	if(m<k) {
		up(i,1,n)up(o,1,n)w[i][o]=1e17;
		up(i,1,m)w[a[i].ff.ss][a[i].ff.ff]=w[a[i].ff.ff][a[i].ff.ss]=a[i].ss;
		floyd(n);
		up(i,1,n)up(o,i+1,n)if(w[i][o]<1e17)ans[++ans[0]]=w[i][o];
		sort(ans+1,ans+1+ans[0]);
		prl(ans[k],'\n');
		return 0;
	}
	int end;
	up(i,1,k)
	if(a[i].ss==a[k].ss) {
		end=i-1;
		break;
	}

	up(i,1,n)f[i]=i;
	up(i,1,end)add(a[i].ff.ff,a[i].ff.ss),vis[a[i].ff.ff]++,vis[a[i].ff.ss]++;
	int c=0;
	up(i,1,n)if(find(i)==i&&vis[i])mapp[i]=++c;
//	up(i,1,n)pr(f[i],' ');printf("\n");
	up(i,1,end) {
		int ind=mapp[find(a[i].ff.ff)];
		s[ind].insert(a[i].ff.ff),s[ind].insert(a[i].ff.ss);
		v[ind].pb(mp(mp(a[i].ff.ff,a[i].ff.ss),a[i].ss));
	}
	up(p,1,c) {
		int si=s[p].size();
		up(i,1,si)up(o,1,si)w[i][o]=1e17;
		int j=0;
		for(auto i:s[p])mapp[i]=++j;
		for(auto i:v[p])w[mapp[i.ff.ff]][mapp[i.ff.ss]]=w[mapp[i.ff.ss]][mapp[i.ff.ff]]=i.ss;
		floyd(si);
		up(i,1,si)up(o,i+1,si)if(w[i][o]<1e17)ans[++ans[0]]=w[i][o];
	}
	sort(ans+1,ans+1+ans[0]);
	int index=upper_bound(ans+1,ans+1+ans[0],a[k].ss)-ans-1;
	if(index>=k)prl(ans[k],'\n');
	else pr(a[k].ss,'\n');
}


#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#include <stack>
using namespace std;
#define ll long long
#define ull unsigned long long
#define up(i, a, b) for (int i = (a); i <= (b); i++)
#define down(i, a, b) for (int i = (a); i >= (b); i--)
#define mem(x, y) memset(x, (y), sizeof x)
#define ff first
#define ss second
#define mp(x, y) make_pair(x, y)
#define pb(x) push_back(x)
#define sc(a) scanf("%d", &a)
#define scl(a) scanf("%lld", &a)
#define scs(a) scanf("%s", a)
#define pr(a, b) printf("%d%c", a, b)
#define prl(a, b) printf("%lld%c", a, b)
#define PQ priority_queue
#define ld long double
#define all(v) v.begin(), v.end()
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)

typedef pair<ll, int> pii;
typedef map<int, int> mii;
typedef vector<int> V;

const int N=3e5+10;
pair<pii,int> a[N];
vector<pair<pii,int>>v[810];
set<int>s[810];
mii mp;
int mapp[N],f[N],vis[N];
ll w[810][810];
ll ans[330010];
void floyd(int n) {
	up(i,1,n)up(o,1,n)up(p,1,n)if(w[i][o]>w[i][p]+w[p][o])w[i][o]=w[i][p]+w[p][o];
}
int find(int x) {
	return f[x]==x?x:f[x]=find(f[x]);
}
void add(int x,int y) {
	int fx=find(x),fy=find(y);
	if(fx!=fy)f[fx]=fy;
}
int main() {
	int n,m,k;
	sc(n),sc(m),sc(k);
	up(i,1,m)sc(a[i].ff.ff),sc(a[i].ff.ss),sc(a[i].ss),mp[a[i].ss]++;
	sort(a+1,a+1+m,[](pair<pii,int> a,pair<pii,int> b) {
		return a.ss<b.ss;
	});
	if(m<k) {
		up(i,1,n)up(o,1,n)w[i][o]=1e17;
		up(i,1,m)w[a[i].ff.ss][a[i].ff.ff]=w[a[i].ff.ff][a[i].ff.ss]=a[i].ss;
		floyd(n);
		up(i,1,n)up(o,i+1,n)if(w[i][o]<1e17)ans[++ans[0]]=w[i][o];
		sort(ans+1,ans+1+ans[0]);
		prl(ans[k],'\n');
		return 0;
	}
	int end;
	up(i,1,k)
	if(a[i].ss==a[k].ss) {
		end=i-1;
		break;
	}

	up(i,1,n)f[i]=i;
	up(i,1,end)add(a[i].ff.ff,a[i].ff.ss),vis[a[i].ff.ff]++,vis[a[i].ff.ss]++;
	up(i,1,end)add(a[i].ff.ff,a[i].ff.ss);
	int c=0;
	up(i,1,n)if(f[i]==i&&vis[i])mapp[i]=++c;
//	up(i,1,n)pr(f[i],' ');printf("\n");
	up(i,1,end) {
		int ind=mapp[f[a[i].ff.ff]];
		s[ind].insert(a[i].ff.ff),s[ind].insert(a[i].ff.ss);
		v[ind].pb(mp(mp(a[i].ff.ff,a[i].ff.ss),a[i].ss));
	}
	up(p,1,c) {
		int si=s[p].size();
		up(i,1,si)up(o,1,si)w[i][o]=1e17;
		int j=0;
		for(auto i:s[p])mapp[i]=++j;
		for(auto i:v[p])w[mapp[i.ff.ff]][mapp[i.ff.ss]]=w[mapp[i.ff.ss]][mapp[i.ff.ff]]=i.ss;
		floyd(si);
		up(i,1,si)up(o,i+1,si)if(w[i][o]<1e17)ans[++ans[0]]=w[i][o];
	}
	sort(ans+1,ans+1+ans[0]);
	int index=upper_bound(ans+1,ans+1+ans[0],a[k].ss)-ans-2;
	if(index>=k)prl(ans[k],'\n');
	else pr(a[k].ss,'\n');
}


#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#include <stack>
using namespace std;
#define ll long long
#define ull unsigned long long
#define up(i, a, b) for (int i = (a); i <= (b); i++)
#define down(i, a, b) for (int i = (a); i >= (b); i--)
#define mem(x, y) memset(x, (y), sizeof x)
#define ff first
#define ss second
#define mp(x, y) make_pair(x, y)
#define pb(x) push_back(x)
#define sc(a) scanf("%d", &a)
#define scl(a) scanf("%lld", &a)
#define scs(a) scanf("%s", a)
#define pr(a, b) printf("%d%c", a, b)
#define prl(a, b) printf("%lld%c", a, b)
#define PQ priority_queue
#define ld long double
#define all(v) v.begin(), v.end()
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)

typedef pair<ll, int> pii;
typedef map<int, int> mii;
typedef vector<int> V;

const int N=3e5+10;
pair<pii,int> a[N];
vector<pair<pii,int>>v[810];
set<int>s[810];
mii mp;
int mapp[N],f[N],vis[N];
ll w[810][810];
ll ans[330010];
void floyd(int n) {
	up(i,1,n)up(o,1,n)up(p,1,n)if(w[i][o]>w[i][p]+w[p][o])w[i][o]=w[i][p]+w[p][o];
}
int find(int x) {
	return f[x]==x?x:f[x]=find(f[x]);
}
void add(int x,int y) {
	int fx=find(x),fy=find(y);
	if(fx!=fy)f[fx]=fy;
}
int main() {
	int n,m,k;
	sc(n),sc(m),sc(k);
	up(i,1,m)sc(a[i].ff.ff),sc(a[i].ff.ss),sc(a[i].ss),mp[a[i].ss]++;
	sort(a+1,a+1+m,[](pair<pii,int> a,pair<pii,int> b) {
		return a.ss<b.ss;
	});
	if(m<k){
		mp.clear();
		up(i,1,m)mp[a[i].ff.ff]++,mp[a[i].ff.ss]++;
		int c=0;
		for(auto i:mp)mp[i.ff]=++c;
		up(i,1,c)up(o,1,c)w[i][o]=1e17;
		up(i,1,m)w[mp[a[i].ff.ss]][mp[a[i].ff.ff]]=w[mp[a[i].ff.ff]][mp[a[i].ff.ss]]=a[i].ss;
		floyd(c);
		up(i,1,c)up(o,i+1,c)if(w[i][o]<1e17)ans[++ans[0]]=w[i][o];
		sort(ans+1,ans+1+ans[0]);
		prl(ans[k],'\n');
		return 0;
	}
	int end;
	up(i,1,k)
	if(a[i].ss==a[k].ss) {
		end=i-1;
		break;
	}

	up(i,1,n)f[i]=i;
	up(i,1,end)add(a[i].ff.ff,a[i].ff.ss),vis[a[i].ff.ff]++,vis[a[i].ff.ss]++;
	up(i,1,end)add(a[i].ff.ff,a[i].ff.ss);
	int c=0;
	up(i,1,n)if(f[i]==i&&vis[i])mapp[i]=++c;
//	up(i,1,n)pr(f[i],' ');printf("\n");
	up(i,1,end) {
		int ind=mapp[f[a[i].ff.ff]];
		s[ind].insert(a[i].ff.ff),s[ind].insert(a[i].ff.ss);
		v[ind].pb(mp(mp(a[i].ff.ff,a[i].ff.ss),a[i].ss));
	}
	up(p,1,c) {
		int si=s[p].size();
		up(i,1,si)up(o,1,si)w[i][o]=1e17;
		int j=0;
		for(auto i:s[p])mapp[i]=++j;
		for(auto i:v[p])w[mapp[i.ff.ff]][mapp[i.ff.ss]]=w[mapp[i.ff.ss]][mapp[i.ff.ss]]=i.ss;
		floyd(si);
		up(i,1,si)up(o,i+1,si)if(w[i][o]<1e17)ans[++ans[0]]=w[i][o];
	}
	sort(ans+1,ans+1+ans[0]);
	int index=upper_bound(ans+1,ans+1+ans[0],a[k].ss)-ans-2;
	if(index>=k)prl(ans[k],'\n');
	else pr(a[k].ss,'\n');
}


#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#include <stack>
using namespace std;
#define ll long long
#define ull unsigned long long
#define up(i, a, b) for (int i = (a); i <= (b); i++)
#define down(i, a, b) for (int i = (a); i >= (b); i--)
#define mem(x, y) memset(x, (y), sizeof x)
#define ff first
#define ss second
#define mp(x, y) make_pair(x, y)
#define pb(x) push_back(x)
#define sc(a) scanf("%d", &a)
#define scl(a) scanf("%lld", &a)
#define scs(a) scanf("%s", a)
#define pr(a, b) printf("%d%c", a, b)
#define prl(a, b) printf("%lld%c", a, b)
#define PQ priority_queue
#define ld long double
#define all(v) v.begin(), v.end()
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)

typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> V;

const int N=3e5+10;
pair<pii,int> a[N];
vector<pair<pii,int>>v[810];
set<int>s[810];
mii mp;
int mapp[N],f[N],vis[N];
ll w[810][810];
ll ans[330010];
void floyd(int n) {
	up(p,1,n)up(i,1,n)up(o,1,n)if(w[i][o]>w[i][p]+w[p][o])w[i][o]=w[i][p]+w[p][o];
}
int find(int x) {
	return f[x]==x?x:f[x]=find(f[x]);
}
void add(int x,int y) {
	int fx=find(x),fy=find(y);
	if(fx!=fy)f[fx]=fy;
}
int main() {
	int n,m,k;
	sc(n),sc(m),sc(k);
	up(i,1,m)sc(a[i].ff.ff),sc(a[i].ff.ss),sc(a[i].ss),mp[a[i].ss]++;
	sort(a+1,a+1+m,[](pair<pii,int> a,pair<pii,int> b) {
		return a.ss<b.ss;
	});
	if(m<k) {
		up(i,1,n)up(o,1,n)w[i][o]=1e17;
		up(i,1,m)w[a[i].ff.ss][a[i].ff.ff]=w[a[i].ff.ff][a[i].ff.ss]=a[i].ss;
		floyd(n);
		up(i,1,n)up(o,i+1,n)if(w[i][o]<1e17)ans[++ans[0]]=w[i][o];
		pr(ans[0],'\n');
		sort(ans+1,ans+1+ans[0]);
		prl(ans[k],'\n');
		return 0;
	}
	int end;
	up(i,1,k)
	if(a[i].ss==a[k].ss) {
		end=i-1;
		break;
	}

	up(i,1,n)f[i]=i;
	up(i,1,end)add(a[i].ff.ff,a[i].ff.ss),vis[a[i].ff.ff]++,vis[a[i].ff.ss]++;
	int c=0;
	up(i,1,n)if(find(i)==i&&vis[i])mapp[i]=++c;
//	up(i,1,n)pr(f[i],' ');printf("\n");
	up(i,1,end) {
		int ind=mapp[find(a[i].ff.ff)];
		s[ind].insert(a[i].ff.ff),s[ind].insert(a[i].ff.ss);
		v[ind].pb(mp(mp(a[i].ff.ff,a[i].ff.ss),a[i].ss));
	}
	up(p,1,c) {
		int si=s[p].size();
		up(i,1,si)up(o,1,si)w[i][o]=1e17;
		int j=0;
		for(auto i:s[p])mapp[i]=++j;
		for(auto i:v[p])w[mapp[i.ff.ff]][mapp[i.ff.ss]]=w[mapp[i.ff.ss]][mapp[i.ff.ff]]=i.ss;
		floyd(si);
		up(i,1,si)up(o,i+1,si)if(w[i][o]<1e17)ans[++ans[0]]=w[i][o];
	}
	sort(ans+1,ans+1+ans[0]);
	int index=upper_bound(ans+1,ans+1+ans[0],a[k].ss)-ans-2;
	if(index>=k)prl(ans[k],'\n');
	else pr(a[k].ss,'\n');
}


#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#include <stack>
using namespace std;
#define ll long long
#define ull unsigned long long
#define up(i, a, b) for (int i = (a); i <= (b); i++)
#define down(i, a, b) for (int i = (a); i >= (b); i--)
#define mem(x, y) memset(x, (y), sizeof x)
#define ff first
#define ss second
#define mp(x, y) make_pair(x, y)
#define pb(x) push_back(x)
#define sc(a) scanf("%d", &a)
#define scl(a) scanf("%lld", &a)
#define scs(a) scanf("%s", a)
#define pr(a, b) printf("%d%c", a, b)
#define prl(a, b) printf("%lld%c", a, b)
#define PQ priority_queue
#define ld long double
#define all(v) v.begin(), v.end()
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)

typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> V;

const int N=3e5+10;
pair<pii,int> a[N];
vector<pair<pii,int>>v[810];
set<int>s[810];
mii mp;
int mapp[N],f[N],vis[N];
ll w[810][810];
ll ans[330010];
void floyd(int n) {
	up(i,1,n)up(o,1,n)up(p,1,n)if(w[i][o]>w[i][p]+w[p][o])w[i][o]=w[i][p]+w[p][o];
}
int find(int x) {
	return f[x]==x?x:f[x]=find(f[x]);
}
void add(int x,int y) {
	int fx=find(x),fy=find(y);
	if(fx!=fy)f[fx]=fy;
}
int main() {
	int n,m,k;
	sc(n),sc(m),sc(k);
	up(i,1,m)sc(a[i].ff.ff),sc(a[i].ff.ss),sc(a[i].ss),mp[a[i].ss]++;
	sort(a+1,a+1+m,[](pair<pii,int> a,pair<pii,int> b) {
		return a.ss<b.ss;
	});
	if(m<k) {
		up(i,1,n)up(o,1,n)w[i][o]=1e17;
		up(i,1,m)w[a[i].ff.ss][a[i].ff.ff]=w[a[i].ff.ff][a[i].ff.ss]=a[i].ss;
		floyd(n);
		up(i,1,n)up(o,i+1,n)if(w[i][o]<1e17)ans[++ans[0]]=w[i][o];
		sort(ans+1,ans+1+ans[0]);
		prl(ans[k],'\n');
		return 0;
	}
	int end;
	up(i,1,k)
	if(a[i].ss==a[k].ss) {
		end=i-1;
		break;
	}

	up(i,1,n)f[i]=i;
	up(i,1,end)add(a[i].ff.ff,a[i].ff.ss),vis[a[i].ff.ff]++,vis[a[i].ff.ss]++;
	int c=0;
	up(i,1,n)if(find(i)==i&&vis[i])mapp[i]=++c;
//	up(i,1,n)pr(f[i],' ');printf("\n");
	up(i,1,end) {
		int ind=mapp[find(a[i].ff.ff)];
		s[ind].insert(a[i].ff.ff),s[ind].insert(a[i].ff.ss);
		v[ind].pb(mp(mp(a[i].ff.ff,a[i].ff.ss),a[i].ss));
	}
	up(p,1,c) {
		int si=s[p].size();
		up(i,1,si)up(o,1,si)w[i][o]=1e17;
		int j=0;
		for(auto i:s[p])mapp[i]=++j;
		for(auto i:v[p])w[mapp[i.ff.ff]][mapp[i.ff.ss]]=w[mapp[i.ff.ss]][mapp[i.ff.ff]]=i.ss;
		floyd(si);
		up(i,1,si)up(o,i+1,si)if(w[i][o]<1e17)ans[++ans[0]]=w[i][o];
	}
	sort(ans+1,ans+1+ans[0]);
	int index=upper_bound(ans+1,ans+1+ans[0],a[k].ss)-ans-2;
	if(index>=k)prl(ans[k],'\n');
	else pr(a[k].ss,'\n');
}


#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<queue>
#include<string.h>
#define pii pair<int,int>
#define mp make_pair
using namespace std;
const int maxx = 2e5+6;
const int INF = 0x3f3f3f3f;
struct node{
  int x,y,w;
}a[maxx];
int order[maxx];
struct Edge{
  int v,w,n;
}edge[maxx];
bool cmp(node a,node b){
   return a.w<b.w;
}
int tot;
int head[maxx],dis[maxx];
bool vis[maxx];
void add(int x,int y,int z){
   edge[++tot]=(Edge){y,z,head[x]};
   head[x]=tot;
}
void dij(int s){
   priority_queue<pii>q;
   for (int i=1;i<=2e5+4;i++){
       dis[i]=INF;
   }
   memset(vis,0,sizeof(vis));
   q.push(mp(0,s));
   dis[s]=0;
   int x,y;
   while(q.size()){
         x=q.top().second;
         q.pop();
      for (int i=head[x];i;i=edge[i].n){
         y=edge[i].v;
         if (vis[y])continue;
         vis[y]=1;
         if (dis[y]>dis[x]+edge[i].w){
             dis[y]=dis[x]+edge[i].w;
             q.push(mp(-dis[y],y));
         }
      }
   }
}
int main(){
  int n,m,k;
  while(~scanf("%d%d%d",&n,&m,&k)){
      tot=0;
      memset(head,0,sizeof(head));
      memset(vis,0,sizeof(vis));
      for (int i=1;i<=m;i++){
        scanf("%d%d%d",&a[i].x,&a[i].y,&a[i].w);
      }
      sort(a+1,a+1+m,cmp);
      int cnt=0;
      for (int i=1;i<=min(k,m);i++){
          add(a[i].x,a[i].y,a[i].w);
          add(a[i].y,a[i].x,a[i].w);
          if (!vis[a[i].x])vis[a[i].x]=1,order[++cnt]=a[i].x;
          if (!vis[a[i].y])vis[a[i].y]=1,order[++cnt]=a[i].y;
      }
      priority_queue<int>ans;
      while(ans.size())ans.pop();
      for (int i=1;i<=cnt;i++){
          dij(order[i]);
          for (int j=i+1;j<=cnt;j++){
             ans.push(-dis[order[j]]);
          }
      }
      for (int i=1;i<k;i++){
        ans.pop();
      }
      printf("%d\n",-ans.top());
  }
  return 0;
}


#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<queue>
#include<string.h>
#define pii pair<int,int>
#define mp make_pair
using namespace std;
const int maxx = 2e5+6;
const int INF = 0x3f3f3f3f;
struct node{
  int x,y,w;
}a[maxx];
int order[maxx];
struct Edge{
  int v,w,n;
}edge[maxx];
bool cmp(node a,node b){
   return a.w<b.w;
}
int tot;
int head[maxx],dis[maxx];
bool vis[maxx];
void add(int x,int y,int z){
   edge[++tot]=(Edge){y,z,head[x]};
   head[x]=tot;
}
void dij(int s){
   priority_queue<pii>q;
   for (int i=1;i<=2e5;i++){
       dis[i]=INF;
   }
   memset(vis,0,sizeof(vis));
   q.push(mp(0,s));
   dis[s]=0;
   int x,y;
   while(q.size()){
         x=q.top().second;
         q.pop();
      for (int i=head[x];i;i=edge[i].n){
         y=edge[i].v;
         if (vis[y])continue;
         vis[y]=1;
         if (dis[y]>dis[x]+edge[i].w){
             dis[y]=dis[x]+edge[i].w;
             q.push(mp(-dis[y],y));
         }
      }
   }
}
int main(){
  int n,m,k;
  while(~scanf("%d%d%d",&n,&m,&k)){
      tot=0;
      memset(head,0,sizeof(head));
      memset(vis,0,sizeof(vis));
      for (int i=1;i<=m;i++){
        scanf("%d%d%d",&a[i].x,&a[i].y,&a[i].w);
      }
      sort(a+1,a+1+m,cmp);
      int cnt=1;
      for (int i=1;i<=min(k,m);i++){
          add(a[i].x,a[i].y,a[i].w);
          add(a[i].y,a[i].x,a[i].w);
          if (!vis[a[i].x])vis[a[i].x]=1,order[++cnt]=a[i].x;
          if (!vis[a[i].y])vis[a[i].y]=1,order[++cnt]=a[i].y;
      }
      for (int i=1;i<=cnt;i++){
        printf("%d-",order[i]);
      }
      cout<<endl;
      priority_queue<int>ans;
      while(ans.size())ans.pop();
      for (int i=1;i<=cnt;i++){
          dij(order[i]);
          for (int j=i+1;j<=cnt;j++){
             ans.push(-dis[order[j]]);
          }
      }
      for (int i=1;i<k;i++){
        ans.pop();
      }
      printf("%d\n",-ans.top());
  }
  return 0;
}


#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<queue>
#include<string.h>
#define pii pair<int,int>
#define mp make_pair
using namespace std;
const int maxx = 2e5+6;
const int INF = 0x3f3f3f3f;
struct node{
  int x,y,w;
}a[maxx];
int order[maxx];
struct Edge{
  int v,w,n;
}edge[maxx];
bool cmp(node a,node b){
   return a.w<b.w;
}
int tot;
int head[maxx],dis[maxx];
bool vis[maxx];
void add(int x,int y,int z){
   edge[++tot]=(Edge){y,z,head[x]};
   head[x]=tot;
}
void dij(int s){
   priority_queue<pii>q;
   for (int i=1;i<=2e5+4;i++){
       dis[i]=INF;
   }
   memset(vis,0,sizeof(vis));
   q.push(mp(0,s));
   dis[s]=0;
   int x,y;
   while(q.size()){
         x=q.top().second;
         q.pop();
         if (vis[x])continue;
         vis[x]=1;
      for (int i=head[x];i;i=edge[i].n){
         y=edge[i].v;
         if (dis[y]>dis[x]+edge[i].w){
             dis[y]=dis[x]+edge[i].w;
             q.push(mp(-dis[y],y));
         }
      }
   }
}
int main(){
  int n,m,k;
  while(~scanf("%d%d%d",&n,&m,&k)){
      tot=1;
      memset(head,0,sizeof(head));
      memset(vis,0,sizeof(vis));
      memset(edge,0,sizeof(edge));
      for (int i=1;i<=m;i++){
        scanf("%d%d%d",&a[i].x,&a[i].y,&a[i].w);
      }
      sort(a+1,a+1+m,cmp);
      int cnt=0;
      for (int i=1;i<=min(k,m);i++){
          add(a[i].x,a[i].y,a[i].w);
          add(a[i].y,a[i].x,a[i].w);
          if (!vis[a[i].x])vis[a[i].x]=1,order[++cnt]=a[i].x;
          if (!vis[a[i].y])vis[a[i].y]=1,order[++cnt]=a[i].y;
      }
      priority_queue<int>ans;
      while(ans.size())ans.pop();
      for (int i=1;i<=cnt;i++){
          dij(order[i]);
          for (int j=i+1;j<=cnt;j++){
             ans.push(-dis[order[j]]);
          }
      }
      for (int i=1;i<k;i++){
        ans.pop();
      }
      printf("%d\n",-ans.top());
  }
  return 0;
}


#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<queue>
#include<string.h>
#define pii pair<int,int>
#define mp make_pair
using namespace std;
const int maxx = 2e5+6;
const int INF = 0x3f3f3f3f;
struct node{
  int x,y,w;
}a[maxx];
int order[maxx];
struct Edge{
  int v,w,n;
}edge[maxx];
bool cmp(node a,node b){
   return a.w<b.w;
}
int tot;
int head[maxx],dis[maxx];
bool vis[maxx];
void add(int x,int y,int z){
   edge[++tot]=(Edge){y,z,head[x]};
   head[x]=tot;
}
void dij(int s){
   priority_queue<pii>q;
   for (int i=1;i<=2e5;i++){
       dis[i]=INF;
   }
   memset(vis,0,sizeof(vis));
   q.push(mp(0,s));
   dis[s]=0;
   int x,y;
   while(q.size()){
         x=q.top().second;
         q.pop();
      for (int i=head[x];i;i=edge[i].n){
         y=edge[i].v;
         if (vis[y])continue;
         vis[y]=1;
         if (dis[y]>dis[x]+edge[i].w){
             dis[y]=dis[x]+edge[i].w;
             q.push(mp(-dis[y],y));
         }
      }
   }
}
int main(){
  int n,m,k;
  while(~scanf("%d%d%d",&n,&m,&k)){
      tot=0;
      memset(head,0,sizeof(head));
      memset(vis,0,sizeof(vis));
      for (int i=1;i<=m;i++){
        scanf("%d%d%d",&a[i].x,&a[i].y,&a[i].w);
      }
      sort(a+1,a+1+m,cmp);
      int cnt=1;
      for (int i=1;i<=min(k,m);i++){
          add(a[i].x,a[i].y,a[i].w);
          add(a[i].y,a[i].x,a[i].w);
          if (!vis[a[i].x])vis[a[i].x]=1,order[++cnt]=a[i].x;
          if (!vis[a[i].y])vis[a[i].y]=1,order[++cnt]=a[i].y;
      }
      priority_queue<int>ans;
      while(ans.size())ans.pop();
      for (int i=1;i<=cnt;i++){
          dij(order[i]);
          for (int j=i+1;j<=cnt;j++){
             ans.push(-dis[order[j]]);
          }
      }
      for (int i=1;i<k;i++){
        ans.pop();
      }
      printf("%d\n",-ans.top());
  }
  return 0;
}


#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<queue>
#include<string.h>
#define pii pair<int,int>
#define pli pair<long long,int>
#define mp make_pair
#define LL long long
using namespace std;
const int maxx = 2e5+6;
const LL INF = 1e18;
struct node{
  int x,y,w;
}a[maxx];
int order[maxx];
struct Edge{
  int v,w,n;
}edge[maxx];
bool cmp(node a,node b){
   return a.w<b.w;
}
int tot;
int head[maxx];
LL dis[maxx];
bool vis[maxx];
void add(int x,int y,int z){
   edge[++tot]=(Edge){y,z,head[x]};
   head[x]=tot;
}
void dij(int s){
   priority_queue<pli>q;
   for (int i=1;i<=2e5+4;i++){
       dis[i]=INF;
   }
   memset(vis,0,sizeof(vis));
   q.push(mp(0,s));
   dis[s]=0;
   int x,y;
   while(q.size()){
         x=q.top().second;
         q.pop();
         if (vis[x])continue;
         vis[x]=1;
      for (int i=head[x];i;i=edge[i].n){
         y=edge[i].v;
         if (dis[y]>dis[x]+edge[i].w){
             dis[y]=dis[x]+edge[i].w;
             q.push(mp(-dis[y],y));
         }
      }
   }
}
int main(){
  int n,m,k;
  while(~scanf("%d%d%d",&n,&m,&k)){
      tot=1;
      memset(head,0,sizeof(head));
      memset(vis,0,sizeof(vis));
      memset(edge,0,sizeof(edge));
      for (int i=1;i<=m;i++){
        scanf("%d%d%d",&a[i].x,&a[i].y,&a[i].w);
      }
      sort(a+1,a+1+m,cmp);
      int cnt=0;
      for (int i=1;i<=min(k,m);i++){
          add(a[i].x,a[i].y,a[i].w);
          add(a[i].y,a[i].x,a[i].w);
          if (!vis[a[i].x])vis[a[i].x]=1,order[++cnt]=a[i].x;
          if (!vis[a[i].y])vis[a[i].y]=1,order[++cnt]=a[i].y;
      }
      priority_queue<LL>ans;
      while(ans.size())ans.pop();
      for (int i=1;i<=cnt;i++){
          dij(order[i]);
          for (int j=i+1;j<=cnt;j++){
             ans.push(-dis[order[j]]);
          }
      }
      for (int i=1;i<k;i++){
        ans.pop();
      }
      printf("%lld\n",-ans.top());
  }
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pi 3.14159265358979323846264
#define pii pair <int, int>
#define pipii pair <int, pair <int, int> >
#define piipi pair <pair <int, int>, int>
#define pb push_back
#define mp make_pair
#define vi vector <int>
#define vl vector <long long>
#define vpii vector <pair <int, int> >
#define ll long long
#define fi first
#define se second
#define FOR(i, x, y) for (int i=x; i<=y; i++)
#define FORD(i, x, y) for (int i=y; i>=x; i--)
#define debug printf("OK\n")
int n, m, k;
ll dist[805][805];
int ma[200005];
vector <pipii> edges;
int main() {
    FOR(i, 1, 800) {
        FOR(j, 1, 800) {
            if (i != j) dist[i][j] = 1e15;
        }
    }
    cin >> n >> m >> k;
    FOR(i, 0, m-1) {
        int x, y, w;
        cin >> x >> y >> w;
        edges.pb({w, {x, y}});
    }
    sort (edges.begin(), edges.end());
    vector <int> ids;
    FOR(i, 0, min(m-1, k-1)) {
        ids.pb(edges[i].se.fi);
        ids.pb(edges[i].se.se);
    }
    sort (ids.begin(), ids.end());
    int mn = 1;
    FOR(i, 0, ids.size()-1) {
        if (ids[i] == ids[i-1]) continue;
        ma[ids[i]] = mn;
        mn++;
    }
    FOR(i, 0, min(m-1, k-1)) {
        edges[i].se.fi = ma[edges[i].se.fi];
        edges[i].se.se = ma[edges[i].se.se];
        int u = edges[i].se.fi, v = edges[i].se.se, l = edges[i].fi;
        dist[u][v] = l;
        dist[v][u] = l;
    }
    mn--;
    FOR(k, 1, mn) {
        FOR(i, 1, mn) {
            FOR(j, 1, mn) {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
    vector <ll> v;
    FOR(i, 1, mn) {
        FOR(j, i+1, mn) {
            if (dist[i][j] > 0) v.pb(dist[i][j]);
        }
    }
    sort (v.begin(), v.end());
    //FOR(i, 0, v.size()-1) cout << i << " " << v[i] << endl;
    printf("%lld\n", v[k-1]);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pi 3.14159265358979323846264
#define pii pair <int, int>
#define pipii pair <int, pair <int, int> >
#define piipi pair <pair <int, int>, int>
#define pb push_back
#define mp make_pair
#define vi vector <int>
#define vl vector <long long>
#define vpii vector <pair <int, int> >
#define ll long long
#define fi first
#define se second
#define FOR(i, x, y) for (int i=x; i<=y; i++)
#define FORD(i, x, y) for (int i=y; i>=x; i--)
#define debug printf("OK\n")
int n, m, k;
ll dist[805][805];
vector <pipii> edges;
int main() {
    FOR(i, 1, 800) {
        FOR(j, 1, 800) {
            if (i != j) dist[i][j] = 1e15;
        }
    }
    cin >> n >> m >> k;
    FOR(i, 0, m-1) {
        int x, y, w;
        cin >> x >> y >> w;
        edges.pb({w, {x, y}});
    }
    sort (edges.begin(), edges.end());
    int mn = 0;
    FOR(i, 0, min(m-1, k-1)) {
        int u = edges[i].se.fi, v = edges[i].se.se, l = edges[i].fi;
        //printf("%d %d %d\n", u, v, l);
        dist[u][v] = l;
        dist[v][u] = l;
        mn = max(mn, max(u, v));
    }
    FOR(k, 1, mn) {
        FOR(i, 1, mn) {
            FOR(j, 1, mn) {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
    vector <ll> v;
    FOR(i, 1, mn) {
        FOR(j, i+1, mn) {
            if (dist[i][j] > 0) v.pb(dist[i][j]);
        }
    }
    sort (v.begin(), v.end());
    //FOR(i, 0, v.size()-1) cout << i << " " << v[i] << endl;
    printf("%lld\n", v[k-1]);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pi 3.14159265358979323846264
#define pii pair <int, int>
#define pipii pair <int, pair <int, int> >
#define piipi pair <pair <int, int>, int>
#define pb push_back
#define mp make_pair
#define vi vector <int>
#define vl vector <long long>
#define vpii vector <pair <int, int> >
#define ll long long
#define fi first
#define se second
#define FOR(i, x, y) for (int i=x; i<=y; i++)
#define FORD(i, x, y) for (int i=y; i>=x; i--)
#define debug printf("OK\n")
int n, m, k;
ll dist[805][805];
vector <pipii> edges;
int main() {
    FOR(i, 1, 800) {
        FOR(j, 1, 800) {
            if (i != j) dist[i][j] = 1e15;
        }
    }
    cin >> n >> m >> k;
    FOR(i, 0, m-1) {
        int x, y, w;
        cin >> x >> y >> w;
        edges.pb({w, {x, y}});
    }
    sort (edges.begin(), edges.end());
    int mn = 0;
    FOR(i, 0, min(m-1, k-1)) {
        int u = edges[i].se.fi, v = edges[i].se.se, l = edges[i].fi;
        //printf("%d %d %d\n", u, v, l);
        dist[u][v] = l;
        dist[v][u] = l;
        mn = max(mn, max(u, v));
    }
    FOR(k, 1, mn) {
        FOR(i, 1, mn) {
            FOR(j, 1, mn) {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
    vector <ll> v;
    FOR(i, 1, mn) {
        FOR(j, i+1, mn) {
            if (dist[i][j] > 0) v.pb(dist[i][j]);
        }
    }
    sort (v.begin(), v.end());
    //FOR(i, 0, v.size()-1) cout << i << " " << v[i] << endl;
    if (v.size() < k) {
        printf(":(\n");
        return 0;
    }
    printf("%lld\n", v[k-1]);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pi 3.14159265358979323846264
#define pii pair <int, int>
#define pipii pair <int, pair <int, int> >
#define piipi pair <pair <int, int>, int>
#define pb push_back
#define mp make_pair
#define vi vector <int>
#define vl vector <long long>
#define vpii vector <pair <int, int> >
#define ll long long
#define fi first
#define se second
#define FOR(i, x, y) for (int i=x; i<=y; i++)
#define FORD(i, x, y) for (int i=y; i>=x; i--)
#define debug printf("OK\n")
int n, m, k;
ll dist[805][805];
vector <pipii> edges;
int main() {
    FOR(i, 1, 800) {
        FOR(j, 1, 800) {
            if (i != j) dist[i][j] = INT_MAX;
        }
    }
    cin >> n >> m >> k;
    FOR(i, 0, m-1) {
        int x, y, w;
        cin >> x >> y >> w;
        edges.pb({w, {x, y}});
    }
    sort (edges.begin(), edges.end());
    int mn = 0;
    FOR(i, 0, min(m-1, k-1)) {
        int u = edges[i].se.fi, v = edges[i].se.se, l = edges[i].fi;
        //printf("%d %d %d\n", u, v, l);
        dist[u][v] = l;
        dist[v][u] = l;
        mn = max(mn, max(u, v));
    }
    FOR(k, 1, mn) {
        FOR(i, 1, mn) {
            FOR(j, 1, mn) {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
    vector <int> v;
    FOR(i, 1, mn) {
        FOR(j, i+1, mn) {
            if (dist[i][j] > 0) v.pb(dist[i][j]);
        }
    }
    sort (v.begin(), v.end());
    printf("%d\n", v[k-1]);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pi 3.14159265358979323846264
#define pii pair <int, int>
#define pipii pair <int, pair <int, int> >
#define piipi pair <pair <int, int>, int>
#define pb push_back
#define mp make_pair
#define vi vector <int>
#define vl vector <long long>
#define vpii vector <pair <int, int> >
#define ll long long
#define fi first
#define se second
#define FOR(i, x, y) for (int i=x; i<=y; i++)
#define FORD(i, x, y) for (int i=y; i>=x; i--)
#define debug printf("OK\n")
int n, m, k;
ll dist[805][805];
int ma[200005];
vector <pipii> edges;
int main() {
    FOR(i, 1, 800) {
        FOR(j, 1, 800) {
            if (i != j) dist[i][j] = 1e15;
        }
    }
    cin >> n >> m >> k;
    FOR(i, 0, m-1) {
        int x, y, w;
        cin >> x >> y >> w;
        edges.pb({w, {x, y}});
    }
    sort (edges.begin(), edges.end());
    vector <int> ids;
    FOR(i, 0, min(m-1, k-1)) {
        ids.pb(edges[i].se.fi);
        ids.pb(edges[i].se.se);
    }
    sort (ids.begin(), ids.end());
    int mn = 1;
    FOR(i, 0, ids.size()-1) {
        if (ids[i] == ids[i-1]) continue;
        ma[ids[i]] = mn;
        mn++;
    }
    FOR(i, 0, min(m-1, k-1)) {
        edges[i].se.fi = ma[edges[i].se.fi];
        edges[i].se.se = ma[edges[i].se.se];
        int u = edges[i].se.fi, v = edges[i].se.se, l = edges[i].fi;
        dist[u][v] = l;
        dist[v][u] = l;
    }
    FOR(k, 1, mn) {
        FOR(i, 1, mn) {
            FOR(j, 1, mn) {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
    vector <ll> v;
    FOR(i, 1, mn) {
        FOR(j, i+1, mn) {
            if (dist[i][j] > 0) v.pb(dist[i][j]);
        }
    }
    sort (v.begin(), v.end());
    //FOR(i, 0, v.size()-1) cout << i << " " << v[i] << endl;
    printf("%lld\n", v[k-1]);
    return 0;
}


#include<bits/stdc++.h>

#define ll long long
#define INF 2147483647

int inp(){
    char c = getchar();
    while(c < '0' || c > '9')
        c = getchar();
    int sum = 0;
    while(c >= '0' && c <= '9'){
        sum = sum * 10 + c - '0';
        c = getchar();
    }
    return sum;
}

int head[200010], nxt[400010], end[400010], value[400010], k, id[200010];
ll is[200010];

ll dis[200010];

struct Node{
    int x;
    ll d;
    bool is;

    bool operator < (const Node &b) const {
        return d > b.d;
    }
};

bool cmp(int a, int b){

}

std::priority_queue<Node> q;
std::multiset<ll, std::greater<ll> > s;
std::vector<int> vec;

int cou = 0;
void link(int a, int b, int v){
    nxt[++cou] = head[a];
    head[a] = cou;
    end[cou] = b;
    value[cou] = v;
}

void dij(int st){
    q.push((Node){st, 0, true});
    dis[st] = 0;
    for(int x = head[st]; x != -1; x = nxt[x])
        is[end[x]] = value[x];
    while(!q.empty() && q.top().d <= *s.begin()){
        Node un = q.top();
        q.pop();
        if(un.d > dis[un.x])
            continue;
        int u = un.x;
        if(!un.is){
            // printf("%d -> %d %lld ", st, u, dis[u]);
            s.insert(dis[u]);
            if(is[u] && is[u] <= *s.begin()){
                s.erase(s.find(is[u]));
                // printf("covered %lld", is[u]);
            } else
                s.erase(s.begin());
            // printf("\n");
            // printf("now {", *s.begin());
            // for(std::multiset<ll>::iterator it = s.begin(); it != s.end(); it++)
            //     printf("%lld " , *it);
            // printf("}\n");
        }
        for(int x = head[u]; x != -1; x = nxt[x]){
            // printf("%d ---> %d -> %d {%lld, %lld + %d} %d\n", st, u, end[x], dis[end[x]], dis[u], value[x], x);
            if(dis[end[x]] > dis[u] + value[x] && dis[u] + value[x] <= *s.begin()){
                vec.push_back(end[x]);
                dis[end[x]] = dis[u] + value[x];
                if(dis[end[x]] < *s.begin())
                    q.push((Node){end[x], dis[end[x]], (u == st)});
            }
        }
    }
    while(!q.empty()){
        // printf("pop {%d, %lld}\n", q.top().x, q.top().d);
        q.pop();
    }
    // printf("---------\n");
    for(int i = 0; i < vec.size(); i++)
        dis[vec[i]] = 1e18;
    for(int x = head[st]; x != -1; x = nxt[x])
        is[end[x]] = 0;
    dis[st] = 1e18;
    vec.clear();
}

int main(){
    srand((unsigned)time(NULL));
    memset(head, -1, sizeof(head));
    int n = inp();
    int m = inp();
    k = inp() << 1;
    for(int i = 1; i <= n; i++)
        id[i] = i;
    std::random_shuffle(id + 1, id + n + 1);
    for(int i = 1; i <= m; i++){
        int u = inp();
        int v = inp();
        int w = inp();
        link(u, v, w);
        link(v, u, w);
        s.insert(w);
        s.insert(w);
    }
    for(int i = (m << 1); i < k; i++)
        s.insert(1e18);
    for(int i = (m << 1); i > k; i--){
        // printf("erase %d\n", s.begin());
        s.erase(s.begin());
    }
    // printf("----------\n");
    for(int i = 1; i <= n; i++)
        dis[i] = 1e18;
    for(int i = 1; i <= n; i++)
        dij(id[i]);
    printf("%lld\n", *s.begin());
}


#include<bits/stdc++.h>

#define ll long long
#define INF 2147483647

int inp(){
    char c = getchar();
    while(c < '0' || c > '9')
        c = getchar();
    int sum = 0;
    while(c >= '0' && c <= '9'){
        sum = sum * 10 + c - '0';
        c = getchar();
    }
    return sum;
}

int head[200010], nxt[400010], end[400010], value[400010], k, id[200010];

ll dis[200010];

struct Node{
    int x;
    ll d;

    bool operator < (const Node &b) const {
        return d > b.d;
    }
};

std::priority_queue<Node> q;
std::priority_queue<ll> s;
std::vector<int> vec;

int cou = 0;
void link(int a, int b, int v){
    nxt[++cou] = head[a];
    head[a] = cou;
    end[cou] = b;
    value[cou] = v;
}

void dij(int st){
    q.push((Node){st, 0});
    dis[st] = 0;
    while(!q.empty() && q.top().d <= s.top()){
        Node un = q.top();
        q.pop();
        if(un.d > dis[un.x])
            continue;
        int u = un.x;
        if(u != st){
            // printf("%d -> %d %lld\n", st, u, dis[u]);
            s.push(dis[u]);
            s.pop();
        }
        for(int x = head[u]; x != -1; x = nxt[x]){
                // printf("%d ---> %d -> %d {%lld, %lld + %d} %d\n", st, u, end[x], dis[end[x]], dis[u], value[x], x);
            if(dis[end[x]] > dis[u] + value[x] && dis[u] + value[x] <= s.top()){
                vec.push_back(end[x]);
                dis[end[x]] = dis[u] + value[x];
                q.push((Node){end[x], dis[end[x]]});
            }
        }
    }
    while(!q.empty()){
        // printf("pop {%d, %lld}\n", q.top().x, q.top().d);
        q.pop();
    }
    // printf("---------\n");
    for(int i = 0; i < vec.size(); i++)
        dis[vec[i]] = 1e18;
    dis[st] = 1e18;
    vec.clear();
}

int main(){
    memset(head, -1, sizeof(head));
    int n = inp();
    int m = inp();
    k = inp() << 1;
    for(int i = 1; i <= n; i++)
        id[i] = i;
    std::random_shuffle(id + 1, id + n + 1);
    for(int i = 1; i <= m; i++){
        int u = inp();
        int v = inp();
        int w = inp();
        link(u, v, w);
        link(v, u, w);
    }
    for(int i = 1; i <= k; i++)
        s.push((ll)(1e18));
    for(int i = 1; i <= n; i++)
        dis[i] = 1e18;
    for(int i = 1; i <= n; i++)
        dij(id[i]);
    printf("%lld\n", s.top());
}


#include<bits/stdc++.h>

#define ll long long
#define INF 2147483647

int inp(){
    char c = getchar();
    while(c < '0' || c > '9')
        c = getchar();
    int sum = 0;
    while(c >= '0' && c <= '9'){
        sum = sum * 10 + c - '0';
        c = getchar();
    }
    return sum;
}

int head[200010], nxt[400010], end[400010], value[400010], k, id[200010];
bool is[200010];

ll dis[200010];

struct Node{
    int x;
    ll d;
    bool is;

    bool operator < (const Node &b) const {
        return d > b.d;
    }
};

std::priority_queue<Node> q;
std::priority_queue<ll> s;
std::vector<int> vec;

int cou = 0;
void link(int a, int b, int v){
    nxt[++cou] = head[a];
    head[a] = cou;
    end[cou] = b;
    value[cou] = v;
}

void dij(int st){
    q.push((Node){st, 0});
    dis[st] = 0;
    while(!q.empty() && q.top().d <= s.top()){
        Node un = q.top();
        q.pop();
        if(un.d > dis[un.x])
            continue;
        int u = un.x;
        if(u != st && !un.is){
            // printf("%d -> %d %lld\n", st, u, dis[u]);
            s.push(dis[u]);
            s.pop();
        }
        for(int x = head[u]; x != -1; x = nxt[x]){
                // printf("%d ---> %d -> %d {%lld, %lld + %d} %d\n", st, u, end[x], dis[end[x]], dis[u], value[x], x);
            if(dis[end[x]] > dis[u] + value[x] && dis[u] + value[x] <= s.top()){
                vec.push_back(end[x]);
                dis[end[x]] = dis[u] + value[x];
                q.push((Node){end[x], dis[end[x]], (u == st)});
            }
        }
    }
    while(!q.empty()){
        // printf("pop {%d, %lld}\n", q.top().x, q.top().d);
        q.pop();
    }
    // printf("---------\n");
    for(int i = 0; i < vec.size(); i++)
        dis[vec[i]] = 1e18;
    dis[st] = 1e18;
    vec.clear();
}

int main(){
    memset(head, -1, sizeof(head));
    int n = inp();
    int m = inp();
    k = inp() << 1;
    for(int i = 1; i <= n; i++)
        id[i] = i;
    std::random_shuffle(id + 1, id + n + 1);
    for(int i = 1; i <= m; i++){
        int u = inp();
        int v = inp();
        int w = inp();
        link(u, v, w);
        link(v, u, w);
        s.push(w);
        s.push(w);
    }
    for(int i = (m << 1); i < k; i++)
        s.push(1e18);
    for(int i = (m << 1); i > k; i--)
        s.pop();

    for(int i = 1; i <= n; i++)
        dis[i] = 1e18;
    for(int i = 1; i <= n; i++)
        dij(id[i]);
    printf("%lld\n", s.top());
}


#include<bits/stdc++.h>

#define ll long long
#define INF 2147483647

int inp(){
    char c = getchar();
    while(c < '0' || c > '9')
        c = getchar();
    int sum = 0;
    while(c >= '0' && c <= '9'){
        sum = sum * 10 + c - '0';
        c = getchar();
    }
    return sum;
}

int head[200010], nxt[400010], end[400010], value[400010], k, id[200010];
ll is[200010];

ll dis[200010];

struct Node{
    int x;
    ll d;
    bool is;

    bool operator < (const Node &b) const {
        return d > b.d;
    }
};

std::priority_queue<Node> q;
std::multiset<ll, std::greater<ll> > s;
std::vector<int> vec;

int cou = 0;
void link(int a, int b, int v){
    nxt[++cou] = head[a];
    head[a] = cou;
    end[cou] = b;
    value[cou] = v;
}

void dij(int st){
    q.push((Node){st, 0, true});
    dis[st] = 0;
    for(int x = head[st]; x != -1; x = nxt[x])
        is[end[x]] = value[x];
    while(!q.empty() && q.top().d <= *s.begin()){
        Node un = q.top();
        q.pop();
        if(un.d > dis[un.x])
            continue;
        int u = un.x;
        if(!un.is){
            // printf("%d -> %d %lld ", st, u, dis[u]);
            s.insert(dis[u]);
            if(is[u] && is[u] <= *s.begin()){
                s.erase(s.find(is[u]));
                // printf("covered %lld", is[u]);
            } else
                s.erase(s.begin());
            printf("\n");
            printf("now {", *s.begin());
            for(std::multiset<ll>::iterator it = s.begin(); it != s.end(); it++)
                printf("%lld " , *it);
            printf("}\n");
        }
        for(int x = head[u]; x != -1; x = nxt[x]){
            // printf("%d ---> %d -> %d {%lld, %lld + %d} %d\n", st, u, end[x], dis[end[x]], dis[u], value[x], x);
            if(dis[end[x]] > dis[u] + value[x] && dis[u] + value[x] <= *s.begin()){
                vec.push_back(end[x]);
                dis[end[x]] = dis[u] + value[x];
                q.push((Node){end[x], dis[end[x]], (u == st)});
            }
        }
    }
    while(!q.empty()){
        // printf("pop {%d, %lld}\n", q.top().x, q.top().d);
        q.pop();
    }
    // printf("---------\n");
    for(int i = 0; i < vec.size(); i++)
        dis[vec[i]] = 1e18;
    for(int x = head[st]; x != -1; x = nxt[x])
        is[end[x]] = 0;
    dis[st] = 1e18;
    vec.clear();
}

int main(){
    srand((unsigned)time(NULL));
    memset(head, -1, sizeof(head));
    int n = inp();
    int m = inp();
    k = inp() << 1;
    for(int i = 1; i <= n; i++)
        id[i] = i;
    std::random_shuffle(id + 1, id + n + 1);
    for(int i = 1; i <= m; i++){
        int u = inp();
        int v = inp();
        int w = inp();
        link(u, v, w);
        link(v, u, w);
        s.insert(w);
        s.insert(w);
    }
    for(int i = (m << 1); i < k; i++)
        s.insert(1e18);
    for(int i = (m << 1); i > k; i--){
        // printf("erase %d\n", s.begin());
        s.erase(s.begin());
    }
    // printf("----------\n");
    for(int i = 1; i <= n; i++)
        dis[i] = 1e18;
    for(int i = 1; i <= n; i++)
        dij(id[i]);
    printf("%lld\n", *s.begin());
}


#include<bits/stdc++.h>

#define ll long long
#define INF 2147483647

int inp(){
    char c = getchar();
    while(c < '0' || c > '9')
        c = getchar();
    int sum = 0;
    while(c >= '0' && c <= '9'){
        sum = sum * 10 + c - '0';
        c = getchar();
    }
    return sum;
}

int head[200010], nxt[400010], end[400010], value[400010], k, id[200010];

ll dis[200010];

struct Node{
    int x;
    ll d;

    bool operator < (const Node &b) const {
        return d > b.d;
    }
};

std::priority_queue<Node> q;
std::priority_queue<ll> s;
std::vector<int> vec;

int cou = 0;
void link(int a, int b, int v){
    nxt[++cou] = head[a];
    head[a] = cou;
    end[cou] = b;
    value[cou] = v;
}

void dij(int st){
    q.push((Node){st, 0});
    dis[st] = 0;
    while(!q.empty() && q.top().d <= s.top()){
        Node un = q.top();
        while(un.d > dis[un.x] && !q.empty()){
            q.pop();
            un = q.top();
        }
        if(q.empty())
            break;
        q.pop();
        int u = un.x;
        if(u != st){
            // printf("%d -> %d %lld\n", st, u, dis[u]);
            s.push(dis[u]);
            vec.push_back(u);
            s.pop();
        }
        for(int x = head[u]; x != -1; x = nxt[x]){
            if(dis[end[x]] > dis[u] + value[x] && dis[u] + value[x] <= s.top()){
                // printf("%d -> %d {%lld, %lld + %lld}\n", u, end[x], dis[end[x]], dis[u], value[x]);
                dis[end[x]] = dis[u] + value[x];
                q.push((Node){end[x], dis[end[x]]});
            }
        }
    }
    // printf("---------\n");
    while(!q.empty())
        q.pop();
    for(int i = 0; i < vec.size(); i++)
        dis[vec[i]] = 1e18;
    vec.clear();
}

int main(){
    memset(head, -1, sizeof(head));
    int n = inp();
    int m = inp();
    k = inp();
    for(int i = 1; i <= n; i++)
        id[i] = i;
    std::random_shuffle(id + 1, id + n + 1);
    for(int i = 1; i <= m; i++){
        int u = inp();
        int v = inp();
        int w = inp();
        link(u, v, w);
        link(v, u, w);
    }
    for(int i = 1; i <= k; i++)
        s.push((ll)(1e18));
    for(int i = 1; i <= n; i++)
        dis[i] = 1e18;
    for(int i = 1; i <= n; i++)
        dij(id[i]);
    printf("%lld\n", s.top());
}


#include<bits/stdc++.h>

#define ll long long
#define INF 2147483647

int inp(){
    char c = getchar();
    while(c < '0' || c > '9')
        c = getchar();
    int sum = 0;
    while(c >= '0' && c <= '9'){
        sum = sum * 10 + c - '0';
        c = getchar();
    }
    return sum;
}

int head[200010], nxt[400010], end[400010], value[400010], k, id[200010];
ll is[200010];

ll dis[200010];

struct Node{
    int x;
    ll d;
    bool is;

    bool operator < (const Node &b) const {
        return d > b.d;
    }
};

bool cmp(int a, int b){

}

std::priority_queue<Node> q;
std::multiset<ll, std::greater<ll> > s;
std::vector<int> vec;

int cou = 0;
void link(int a, int b, int v){
    nxt[++cou] = head[a];
    head[a] = cou;
    end[cou] = b;
    value[cou] = v;
}

void dij(int st){
    q.push((Node){st, 0, true});
    dis[st] = 0;
    for(int x = head[st]; x != -1; x = nxt[x])
        is[end[x]] = value[x];
    while(!q.empty() && q.top().d <= *s.begin()){
        Node un = q.top();
        q.pop();
        if(un.d > dis[un.x])
            continue;
        int u = un.x;
        if(!un.is){
            // printf("%d -> %d %lld ", st, u, dis[u]);
            s.insert(dis[u]);
            if(is[u] && is[u] <= *s.begin()){
                s.erase(s.find(is[u]));
                // printf("covered %lld", is[u]);
            } else
                s.erase(s.begin());
            // printf("\n");
            // printf("now {", *s.begin());
            // for(std::multiset<ll>::iterator it = s.begin(); it != s.end(); it++)
            //     printf("%lld " , *it);
            // printf("}\n");
        }
        for(int x = head[u]; x != -1; x = nxt[x]){
            // printf("%d ---> %d -> %d {%lld, %lld + %d} %d\n", st, u, end[x], dis[end[x]], dis[u], value[x], x);
            if(dis[end[x]] > dis[u] + value[x] && dis[u] + value[x] <= *s.begin()){
                vec.push_back(end[x]);
                dis[end[x]] = dis[u] + value[x];
                if(dis[end[x]] < *s.begin())
                    q.push((Node){end[x], dis[end[x]], (u == st)});
            }
        }
    }
    while(!q.empty()){
        // printf("pop {%d, %lld}\n", q.top().x, q.top().d);
        q.pop();
    }
    // printf("---------\n");
    for(int i = 0; i < vec.size(); i++)
        dis[vec[i]] = 1e18;
    for(int x = head[st]; x != -1; x = nxt[x])
        is[end[x]] = 0;
    dis[st] = 1e18;
    vec.clear();
}

int main(){
    srand((unsigned)time(NULL));
    memset(head, -1, sizeof(head));
    int n = inp();
    int m = inp();
    k = inp() << 1;
    for(int i = 1; i <= n; i++)
        id[i] = i;
    std::random_shuffle(id + 1, id + n + 1);
    for(int i = 1; i <= m; i++){
        int u = inp();
        int v = inp();
        int w = inp();
        link(u, v, w);
        link(v, u, w);
        s.insert(w);
        s.insert(w);
    }
    for(int i = (m << 1); i < k; i++)
        s.insert(1e18);
    for(int i = (m << 1); i > k; i--){
        // printf("erase %d\n", s.begin());
        s.erase(s.begin());
    }
    // printf("----------\n");
    for(int i = 1; i <= n; i++)
        dis[i] = 1e18;
    for(int i = 1; i <= n; i++)
        dij(id[i]);
    printf("%lld\n", *s.begin());
}
// ...


#include<bits/stdc++.h>

#define ll long long
#define INF 2147483647

int inp(){
    char c = getchar();
    while(c < '0' || c > '9')
        c = getchar();
    int sum = 0;
    while(c >= '0' && c <= '9'){
        sum = sum * 10 + c - '0';
        c = getchar();
    }
    return sum;
}

int head[200010], nxt[400010], end[400010], value[400010], k, id[200010];

ll dis[200010];

struct Node{
    int x;
    ll d;

    bool operator < (const Node &b) const {
        return d > b.d;
    }
};

std::priority_queue<Node> q;
std::priority_queue<ll> s;
std::vector<int> vec;

int cou = 0;
void link(int a, int b, int v){
    nxt[++cou] = head[a];
    head[a] = cou;
    end[cou] = b;
    value[cou] = v;
}

void dij(int st){
    q.push((Node){st, 0});
    dis[st] = 0;
    while(!q.empty() && q.top().d < s.top()){
        Node un = q.top();
        while(un.d > dis[un.x] && !q.empty()){
            q.pop();
            un = q.top();
        }
        if(q.empty())
            break;
        q.pop();
        int u = un.x;
        if(u != st){
            // printf("%d -> %d %lld\n", st, u, dis[u]);
            s.push(dis[u]);
            vec.push_back(u);
            s.pop();
        }
        for(int x = head[u]; x != -1; x = nxt[x]){
            if(dis[end[x]] > dis[u] + value[x] && dis[u] + value[x] < s.top()){
                // printf("%d -> %d {%lld, %lld + %lld}\n", u, end[x], dis[end[x]], dis[u], value[x]);
                dis[end[x]] = dis[u] + value[x];
                q.push((Node){end[x], dis[end[x]]});
            }
        }
    }
    // printf("---------\n");
    while(!q.empty())
        q.pop();
    for(int i = 0; i < vec.size(); i++)
        dis[vec[i]] = 1e18;
    vec.clear();
}

int main(){
    memset(head, -1, sizeof(head));
    int n = inp();
    int m = inp();
    k = inp();
    for(int i = 1; i <= n; i++)
        id[i] = i;
    std::random_shuffle(id + 1, id + n + 1);
    for(int i = 1; i <= m; i++){
        int u = inp();
        int v = inp();
        int w = inp();
        link(u, v, w);
        link(v, u, w);
    }
    for(int i = 1; i <= k; i++)
        s.push((ll)(1e18));
    for(int i = 1; i <= n; i++)
        dis[i] = 1e18;
    for(int i = 1; i <= n; i++)
        dij(id[i]);
    printf("%lld\n", s.top());
}


#include<bits/stdc++.h>

#define ll long long
#define INF 2147483647

int inp(){
    char c = getchar();
    while(c < '0' || c > '9')
        c = getchar();
    int sum = 0;
    while(c >= '0' && c <= '9'){
        sum = sum * 10 + c - '0';
        c = getchar();
    }
    return sum;
}

int head[200010], nxt[400010], end[400010], value[400010], k, id[200010];
ll is[200010];

ll dis[200010];

struct Node{
    int x;
    ll d;
    bool is;

    bool operator < (const Node &b) const {
        return d > b.d;
    }
};

std::priority_queue<Node> q;
std::multiset<ll, std::greater<ll> > s;
std::vector<int> vec;

int cou = 0;
void link(int a, int b, int v){
    nxt[++cou] = head[a];
    head[a] = cou;
    end[cou] = b;
    value[cou] = v;
}

void dij(int st){
    q.push((Node){st, 0, true});
    dis[st] = 0;
    for(int x = head[st]; x != -1; x = nxt[x])
        is[end[x]] = value[x];
    while(!q.empty() && q.top().d <= *s.begin()){
        Node un = q.top();
        q.pop();
        if(un.d > dis[un.x])
            continue;
        int u = un.x;
        if(!un.is){
            // printf("%d -> %d %lld ", st, u, dis[u]);
            s.insert(dis[u]);
            if(is[u] && is[u] <= *s.begin()){
                s.erase(s.find(is[u]));
                // printf("covered %lld", is[u]);
            } else
                s.erase(s.begin());
            // printf("\n");
            // printf("now {", *s.begin());
            // for(std::multiset<ll>::iterator it = s.begin(); it != s.end(); it++)
            //     printf("%lld " , *it);
            // printf("}\n");
        }
        for(int x = head[u]; x != -1; x = nxt[x]){
            // printf("%d ---> %d -> %d {%lld, %lld + %d} %d\n", st, u, end[x], dis[end[x]], dis[u], value[x], x);
            if(dis[end[x]] > dis[u] + value[x] && dis[u] + value[x] <= *s.begin()){
                vec.push_back(end[x]);
                dis[end[x]] = dis[u] + value[x];
                q.push((Node){end[x], dis[end[x]], (u == st)});
            }
        }
    }
    while(!q.empty()){
        // printf("pop {%d, %lld}\n", q.top().x, q.top().d);
        q.pop();
    }
    // printf("---------\n");
    for(int i = 0; i < vec.size(); i++)
        dis[vec[i]] = 1e18;
    for(int x = head[st]; x != -1; x = nxt[x])
        is[end[x]] = 0;
    dis[st] = 1e18;
    vec.clear();
}

int main(){
    srand((unsigned)time(NULL));
    memset(head, -1, sizeof(head));
    int n = inp();
    int m = inp();
    k = inp() << 1;
    for(int i = 1; i <= n; i++)
        id[i] = i;
    std::random_shuffle(id + 1, id + n + 1);
    for(int i = 1; i <= m; i++){
        int u = inp();
        int v = inp();
        int w = inp();
        link(u, v, w);
        link(v, u, w);
        s.insert(w);
        s.insert(w);
    }
    for(int i = (m << 1); i < k; i++)
        s.insert(1e18);
    for(int i = (m << 1); i > k; i--){
        // printf("erase %d\n", s.begin());
        s.erase(s.begin());
    }
    // printf("----------\n");
    for(int i = 1; i <= n; i++)
        dis[i] = 1e18;
    for(int i = 1; i <= n; i++)
        dij(id[i]);
    printf("%lld\n", *s.begin());
}


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

const long long INF64 = 1e18;
const int maxn=2e5+10;
const int maxm=405;
struct Edge{
    int w,a,b;
    bool operator < (const Edge & e)const {
        return w<e.w;
    }
}edge[maxn];
int hs[2*maxm],cntv;
int dis[maxm][maxm];
vector<int>ans;
int main()
{
    int n,m,k;
    scanf("%d %d %d",&n,&m,&k);
    for(int i=1;i<=m;i++)
        scanf("%d %d %d",&edge[i].a,&edge[i].b,&edge[i].w);
    sort(edge+1,edge+1+m);
    for(int i=1;i<=min(k,m);i++){
        hs[++cntv]=edge[i].a;
        hs[++cntv]=edge[i].b;
    }
    sort(hs+1,hs+1+cntv);
    cntv=unique(hs+1,hs+1+cntv)-hs-1;
    //cout<<cntv<<endl;
    for(int i=1;i<=cntv;i++)
        for(int j=1;j<=cntv;j++)
            dis[i][j]=1e9;
    for(int i=1;i<=min(k,m);i++){
        int x=lower_bound(hs+1,hs+1+cntv,edge[i].a)-hs;
        int y=lower_bound(hs+1,hs+1+cntv,edge[i].b)-hs;
        dis[x][y]=dis[y][x]=edge[i].w;
    }
    for(int k=1;k<=cntv;k++)
        for(int i=1;i<=cntv;i++)
            for(int j=1;j<=cntv;j++)
                dis[i][j]=min((ll)dis[i][j],(ll)dis[i][k]+dis[k][j]);
    for(int i=1;i<=cntv;i++){
        for(int j=i+1;j<=cntv;j++)
            ans.push_back(dis[i][j]);
    }
    sort(ans.begin(),ans.end());
    printf("%d\n",ans[k-1]);
	return 0;
}


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

const long long INF64 = 1e18;
const int maxn=2e5+10;
const int maxm=405;
struct Edge{
    int w,a,b;
    bool operator < (const Edge & e)const {
        return w<e.w;
    }
}edge[maxn];
int hs[2*maxm],cntv;
ll dis[maxm][maxm];
vector<ll>ans;
int main()
{
    int n,m,k;
    scanf("%d %d %d",&n,&m,&k);
    for(int i=1;i<=m;i++)
        scanf("%d %d %d",&edge[i].a,&edge[i].b,&edge[i].w);
    sort(edge+1,edge+1+m);
    for(int i=1;i<=min(k,m);i++){
        hs[++cntv]=edge[i].a;
        hs[++cntv]=edge[i].b;
    }
    sort(hs+1,hs+1+cntv);
    cntv=unique(hs+1,hs+1+cntv)-hs-1;
    //cout<<cntv<<endl;
    for(int i=1;i<=cntv;i++)
        for(int j=1;j<=cntv;j++)
            dis[i][j]=1e9;
    for(int i=1;i<=min(k,m);i++){
        int x=lower_bound(hs+1,hs+1+cntv,edge[i].a)-hs;
        int y=lower_bound(hs+1,hs+1+cntv,edge[i].b)-hs;
        dis[x][y]=dis[y][x]=edge[i].w;
    }
    for(int k=1;k<=cntv;k++)
        for(int i=1;i<=cntv;i++)
            for(int j=1;j<=cntv;j++)
                dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
    for(int i=1;i<=cntv;i++){
        for(int j=i+1;j<=cntv;j++)
            ans.push_back(dis[i][j]);
    }
    sort(ans.begin(),ans.end());
    printf("%lld\n",ans[k-1]);
	return 0;
}


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

const long long INF64 = 1e18;
const int maxn=2e5+10;
const int maxm=405;
struct Edge{
    int w,a,b;
    bool operator < (const Edge & e)const {
        return w<e.w;
    }
}edge[maxn];
int hs[2*maxm],cntv;
ll dis[maxm][maxm];
vector<ll>ans;
int main()
{
    int n,m,k;
    scanf("%d %d %d",&n,&m,&k);
    for(int i=1;i<=m;i++)
        scanf("%d %d %d",&edge[i].a,&edge[i].b,&edge[i].w);
    sort(edge+1,edge+1+m);
    for(int i=1;i<=min(k,m);i++){
        hs[++cntv]=edge[i].a;
        hs[++cntv]=edge[i].b;
    }
    sort(hs+1,hs+1+cntv);
    cntv=unique(hs+1,hs+1+cntv)-hs-1;
    //cout<<cntv<<endl;
    for(int i=1;i<=cntv;i++)
        for(int j=1;j<=cntv;j++)
            dis[i][j]=1e9;
    for(int i=1;i<=min(k,m);i++){
        int x=lower_bound(hs+1,hs+1+cntv,edge[i].a)-hs;
        int y=lower_bound(hs+1,hs+1+cntv,edge[i].b)-hs;
        dis[x][y]=dis[y][x]=edge[i].w;
    }
    for(int k=1;k<=cntv;k++)
        for(int i=1;i<=cntv;i++)
            for(int j=1;j<=cntv;j++)
                dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
    for(int i=1;i<=cntv;i++){
        for(int j=i+1;j<=cntv;j++)
            ans.push_back(dis[i][j]);
    }
    sort(ans.begin(),ans.end());
    printf("%d\n",ans[k-1]);
	return 0;
}


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

const long long INF64 = 1e18;
const int maxn=2e5+10;
const int maxm=405;
struct Edge{
    int w,a,b;
    bool operator < (const Edge & e)const {
        return w<e.w;
    }
}edge[maxn];
int hs[2*maxm],cntv;
ll dis[maxm][maxm];
vector<int>ans;
int main()
{
    int n,m,k;
    scanf("%d %d %d",&n,&m,&k);
    for(int i=1;i<=m;i++)
        scanf("%d %d %d",&edge[i].a,&edge[i].b,&edge[i].w);
    sort(edge+1,edge+1+m);
    for(int i=1;i<=min(k,m);i++){
        hs[++cntv]=edge[i].a;
        hs[++cntv]=edge[i].b;
    }
    sort(hs+1,hs+1+cntv);
    cntv=unique(hs+1,hs+1+cntv)-hs-1;
    //cout<<cntv<<endl;
    for(int i=1;i<=cntv;i++)
        for(int j=1;j<=cntv;j++)
            dis[i][j]=1e9;
    for(int i=1;i<=min(k,m);i++){
        int x=lower_bound(hs+1,hs+1+cntv,edge[i].a)-hs;
        int y=lower_bound(hs+1,hs+1+cntv,edge[i].b)-hs;
        dis[x][y]=dis[y][x]=edge[i].w;
    }
    for(int k=1;k<=cntv;k++)
        for(int i=1;i<=cntv;i++)
            for(int j=1;j<=cntv;j++)
                dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
    for(int i=1;i<=cntv;i++){
        for(int j=i+1;j<=cntv;j++)
            ans.push_back(dis[i][j]);
    }
    sort(ans.begin(),ans.end());
    printf("%d\n",ans[k-1]);
	return 0;
}


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

const long long INF64 = 1e18;
const int maxn=2e5+10;
const int maxm=405;
struct Edge{
    int w,a,b;
    bool operator < (const Edge & e)const {
        return w<e.w;
    }
}edge[maxn];
int hs[2*maxm],cntv;
ll dis[2*maxm][2*maxm];
vector<ll>ans;
int main()
{
    int n,m,k;
    scanf("%d %d %d",&n,&m,&k);
    for(int i=1;i<=m;i++)
        scanf("%d %d %d",&edge[i].a,&edge[i].b,&edge[i].w);
    sort(edge+1,edge+1+m);
    for(int i=1;i<=min(k,m);i++){
        hs[++cntv]=edge[i].a;
        hs[++cntv]=edge[i].b;
    }
    sort(hs+1,hs+1+cntv);
    cntv=unique(hs+1,hs+1+cntv)-hs-1;
    //cout<<cntv<<endl;
    for(int i=1;i<=cntv;i++)
        for(int j=1;j<=cntv;j++)
            dis[i][j]=1e18;
    for(int i=1;i<=min(k,m);i++){
        int x=lower_bound(hs+1,hs+1+cntv,edge[i].a)-hs;
        int y=lower_bound(hs+1,hs+1+cntv,edge[i].b)-hs;
        dis[x][y]=dis[y][x]=edge[i].w;
    }
    for(int k=1;k<=cntv;k++)
        for(int i=1;i<=cntv;i++)
            for(int j=1;j<=cntv;j++)
                dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
    for(int i=1;i<=cntv;i++){
        for(int j=i+1;j<=cntv;j++)
            ans.push_back(dis[i][j]);
    }
    sort(ans.begin(),ans.end());
    printf("%lld\n",ans[k-1]);
	return 0;
}


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

const long long INF64 = 1e18;
const int maxn=2e5+10;
const int maxm=405;
struct Edge{
    int w,a,b;
    bool operator < (const Edge & e)const {
        return w<e.w;
    }
}edge[maxn];
int hs[2*maxm],cntv;
ll dis[maxm][maxm];
vector<ll>ans;
int main()
{
    int n,m,k;
    scanf("%d %d %d",&n,&m,&k);
    for(int i=1;i<=m;i++)
        scanf("%d %d %d",&edge[i].a,&edge[i].b,&edge[i].w);
    sort(edge+1,edge+1+m);
    for(int i=1;i<=min(k,m);i++){
        hs[++cntv]=edge[i].a;
        hs[++cntv]=edge[i].b;
    }
    sort(hs+1,hs+1+cntv);
    cntv=unique(hs+1,hs+1+cntv)-hs-1;
    //cout<<cntv<<endl;
    for(int i=1;i<=cntv;i++)
        for(int j=1;j<=cntv;j++)
            dis[i][j]=1e18;
    for(int i=1;i<=min(k,m);i++){
        int x=lower_bound(hs+1,hs+1+cntv,edge[i].a)-hs;
        int y=lower_bound(hs+1,hs+1+cntv,edge[i].b)-hs;
        dis[x][y]=dis[y][x]=edge[i].w;
    }
    for(int k=1;k<=cntv;k++)
        for(int i=1;i<=cntv;i++)
            for(int j=1;j<=cntv;j++)
                dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
    for(int i=1;i<=cntv;i++){
        for(int j=i+1;j<=cntv;j++)
            ans.push_back(dis[i][j]);
    }
    sort(ans.begin(),ans.end());
    printf("%lld\n",ans[k-1]);
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define MAXN 200010
#define int long long
struct E {
	int u, v, w;
} e[MAXN];
int n, m, x, y, p, z, G[810][810], tot, vis[MAXN], col[MAXN], l;
bool cmp(E a, E b) {
	return a.w < b.w;
}
signed main() {
	scanf("%I64d%I64d%I64d", &n, &m, &p);
	for (int i = 1; i <= m; i++) {
		scanf("%I64d%I64d%I64d", &x, &y, &z);
		e[i].u = x;
		e[i].v = y;
		e[i].w = z;
	}
	memset(G, 0x3f, sizeof(G));
	std::sort(e + 1, e + 1 + m, cmp);
	for (int i = 1; i <= p; i++) {
		vis[e[i].u] = 1;
		vis[e[i].v] = 1;
	}
	for (int i = 1; i <= n; i++) {
		col[i] = col[i - 1] + vis[i];
		G[i][i] = 0;
	}
	l = col[n];
	for (int i = 1; i <= p; i++) {
		G[col[e[i].v]][col[e[i].u]] = G[col[e[i].u]][col[e[i].v]] = e[i].w;
	}
	memset(e, 0, sizeof(e));
	for (int k = 1; k <= l; k++) {
		for (int i = 1; i <= l; i++) {
			for (int j = 1; j <= l; j++) {
				G[i][j] = std::min(G[i][j], G[i][k] + G[k][j]);
			}
		}
	}
	for (int i = 1; i < l; i++) {
		for (int j = i; j <= l; j++) {
			if (i == j) continue;
			e[++tot].u = i;
			e[tot].v = j;
			e[tot].w = G[i][j];
		}
	}
	std::sort(e + 1, e + 1 + tot, cmp);
	printf("%I64d", e[p].w);
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define MAXN 200010
#define int long long
struct E {
	int u, v, w;
} e[MAXN];
int n, m, x, y, p, z, G[810][810], tot, vis[MAXN], col[MAXN], l;
bool cmp(E a, E b) {
	return a.w < b.w;
}
signed main() {
	scanf("%I64d%I64d%I64d", &n, &m, &p);
	for (int i = 1; i <= m; i++) {
		scanf("%I64d%I64d%I64d", &x, &y, &z);
		e[i].u = x;
		e[i].v = y;
		e[i].w = z;
	}
	memset(G, 0x3f, sizeof(G));
	std::sort(e + 1, e + 1 + m, cmp);
	for (int i = 1; i <= p; i++) {
		vis[e[i].u] = 1;
		vis[e[i].v] = 1;
	}
	for (int i = 1; i <= n; i++) {
		col[i] = col[i - 1] + vis[i];
		G[i][i] = 0;
	}
	l = col[n];
	for (int i = 1; i <= p; i++) {
		G[col[e[i].v]][col[e[i].u]] = G[col[e[i].u]][col[e[i].v]] = e[i].w;
	}
	memset(e, 0, sizeof(e));
	n = l;
	for (int k = 1; k <= n; k++) {
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				G[i][j] = std::min(G[i][j], G[i][k] + G[k][j]);
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j < i; j++) {
			if (i == j) continue;
			e[++tot].u = i;
			e[tot].v = j;
			e[tot].w = G[i][j];
		}
	}
	std::sort(e + 1, e + 1 + tot, cmp);
	printf("%I64d", e[p].w);
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define MAXN 200010
struct E {
	int u, v, w;
} e[MAXN];
int n, m, x, y, p, z, tot, vis[MAXN], col[MAXN], l;
long long G[810][810];
bool cmp(E a, E b) {
	return a.w < b.w;
}
signed main() {
	scanf("%d%d%d", &n, &m, &p);
	for (int i = 1; i <= m; i++) {
		scanf("%d%d%d", &x, &y, &z);
		e[i].u = x;
		e[i].v = y;
		e[i].w = z;
	}
	memset(G, 0x3f, sizeof(G));
	std::sort(e + 1, e + 1 + m, cmp);
	for (int i = 1; i <= p; i++) {
		vis[e[i].u] = 1;
		vis[e[i].v] = 1;
	}
	for (int i = 1; i <= n; i++) {
		col[i] = col[i - 1] + vis[i];
	}
	l = col[n];
	for (int i = 1; i <= p; i++) {
		G[col[e[i].v]][col[e[i].u]] = G[col[e[i].u]][col[e[i].v]] = e[i].w;
	}
	memset(e, 0, sizeof(e));
	n = l;
	for (int k = 1; k <= n; k++) {
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				G[i][j] = std::min(G[i][j], G[i][k] + G[k][j]);
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j < i; j++) {
			if (i == j) continue;
			e[++tot].u = i;
			e[tot].v = j;
			e[tot].w = G[i][j];
		}
	}
	std::sort(e + 1, e + 1 + tot, cmp);
	std::cout << e[p].w;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define MAXN 200010
#define int long long
struct E {
	int u, v, w;
} e[MAXN];
int n, m, x, y, p, z, G[810][810], tot, vis[MAXN], col[MAXN], l;
bool cmp(E a, E b) {
	return a.w < b.w;
}
signed main() {
	scanf("%I64d%I64d%I64d", &n, &m, &p);
	for (int i = 1; i <= m; i++) {
		scanf("%I64d%I64d%I64d", &x, &y, &z);
		e[i].u = x;
		e[i].v = y;
		e[i].w = z;
	}
	memset(G, 0x3f, sizeof(G));
	std::sort(e + 1, e + 1 + m, cmp);
	for (int i = 1; i <= p; i++) {
		vis[e[i].u] = 1;
		vis[e[i].v] = 1;
	}
	for (int i = 1; i <= n; i++) {
		col[i] = col[i - 1] + vis[i];
	}
	l = col[n];
	for (int i = 1; i <= p; i++) {
		G[col[e[i].v]][col[e[i].u]] = G[col[e[i].u]][col[e[i].v]] = e[i].w;
	}
	memset(e, 0, sizeof(e));
	n = l;
	for (int k = 1; k <= n; k++) {
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				G[i][j] = std::min(G[i][j], G[i][k] + G[k][j]);
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j < i; j++) {
			if (i == j) continue;
			e[++tot].u = i;
			e[tot].v = j;
			e[tot].w = G[i][j];
		}
	}
	std::sort(e + 1, e + 1 + tot, cmp);
	printf("%I64d", e[p].w);
}


    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <algorithm>
    #define MAXN 200010
    #define int long long
    struct E {
    	int u, v, w;
    } e[MAXN << 2];
    int n, m, x, y, p, z, G[810][810], tot, vis[MAXN], col[MAXN], l;
    bool cmp(E a, E b) {
    	return a.w < b.w;
    }
    signed main() {
    	scanf("%I64d%I64d%I64d", &n, &m, &p);
    	for (int i = 1; i <= m; i++) {
    		scanf("%I64d%I64d%I64d", &x, &y, &z);
    		e[i].u = x;
    		e[i].v = y;
    		e[i].w = z;
    	}
    	memset(G, 0x3f, sizeof(G));
    	std::sort(e + 1, e + 1 + m, cmp);
    	for (int i = 1; i <= p; i++) {
    		vis[e[i].u] = 1;
    		vis[e[i].v] = 1;
    	}
    	for (int i = 1; i <= n; i++) {
    		col[i] = col[i - 1] + vis[i];
    	}
    	l = col[n];
    	for (int i = 1; i <= p; i++) {
    		G[col[e[i].v]][col[e[i].u]] = G[col[e[i].u]][col[e[i].v]] = e[i].w;
    	}
    	memset(e, 0, sizeof(e));
    	n = l;
    	for (int k = 1; k <= n; k++) {
    		for (int i = 1; i <= n; i++) {
    			for (int j = 1; j <= n; j++) {
    				G[i][j] = std::min(G[i][j], G[i][k] + G[k][j]);
    			}
    		}
    	}
    	for (int i = 1; i <= n; i++) {
    		for (int j = 1; j < i; j++) {
    			if (i == j) continue;
    			e[++tot].u = i;
    			e[tot].v = j;
    			e[tot].w = G[i][j];
    		}
    	}
    	std::sort(e + 1, e + 1 + tot, cmp);
    	printf("%I64d", e[p].w);
    }


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define MAXN 200010
#define int long long
struct E {
	int u, v, w;
} e[MAXN];
int n, m, x, y, p, z, G[810][810], tot;
bool cmp(E a, E b) {
	return a.w < b.w;
}
signed main() {
	scanf("%I64d%I64d%I64d", &n, &m, &p);
	for (int i = 1; i <= m; i++) {
		scanf("%I64d%I64d%I64d", &x, &y, &z);
		e[i].u = x;
		e[i].v = y;
		e[i].w = z;
	}
	memset(G, 0x3f, sizeof(G));
	for (int i = 1; i <= n; i++) {
		G[i][i] = 0;
	}
	std::sort(e + 1, e + 1 + m, cmp);
	for (int i = 1; i <= p; i++) {
		G[e[i].u][e[i].v] = G[e[i].v][e[i].u] = e[i].w;
	}
	memset(e, 0, sizeof(e));
	for (int k = 1; k <= n; k++) {
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				G[i][j] = std::min(G[i][j], G[i][k] + G[k][j]);
			}
		}
	}
	for (int i = 1; i < n; i++) {
		for (int j = i; j <= n; j++) {
			if (i == j) continue;
			e[++tot].u = i;
			e[tot].v = j;
			e[tot].w = G[i][j];
		}
	}
	std::sort(e + 1, e + 1 + tot, cmp);
	printf("%I64d", e[p].w);
}


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

#define ff first
#define ss second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define check(x) cout << #x << " : " << (x) << endl
#define all(v) v.begin(),v.end()
#define endl '\n'
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair< ll , ll > mypair;
typedef priority_queue <ll> max_heap;
typedef priority_queue <ll, vector<ll>, greater<ll> > min_heap;
const ll mod=1e9+7;
const int inf=1e9;
const int N=402;

int main()
{
	boost;
	int n,m,k;
	cin>>n>>m>>k;
	/*
	if(k<=m)
	{
		vector<int> ans;
		while(m--)
		{
			int x,y,w;
			cin>>x>>y>>w;
			ans.pb(w);
		}
		sort(all(ans));
		cout<<ans[k-1];
		return 0;
	}*/
	vector<vector<ll> > dp(n+1,vector<ll>(n+1,inf));
	while(m--)
	{
		int x,y,w;
		cin>>x>>y>>w;
		x--;y--;
		dp[x][y]=w;
		dp[y][x]=w;
	}
	vector<ll> ans;
	for(int i=0;i<n;i++) dp[i][i]=0;
	for(int p=0;p<n;p++)
		for(int i=0;i<n;++i)
			for(int j=0;j<n;++j)
				dp[i][j]=min(dp[i][j],dp[i][p]+dp[p][j]);
	for(int i=0;i<n;i++)
		for(int j=0;j<i;j++)
			ans.pb(dp[i][j]);
	sort(all(ans));
	cout<<ans[k-1];
	return 0;
}


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

#define ff first
#define ss second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define check(x) cout << #x << " : " << (x) << endl
#define all(v) v.begin(),v.end()
#define endl '\n'
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair< ll , ll > mypair;
typedef priority_queue <ll> max_heap;
typedef priority_queue <ll, vector<ll>, greater<ll> > min_heap;
const ll mod=1e9+7;
const ll inf=1e16;
const ll N=402;

using edge=pair< ll,pair<ll,ll> >;

int main()
{
	boost;
	int n,m,k;
	cin>>n>>m>>k;

	std::vector<edge> v;
	for(int i=0;i<m;i++)
	{
		ll x,y,w;
		cin>>x>>y>>w;
		x--;y--;
		v.pb(mp(w,mp(x,y)));
	}
	sort(all(v));
	m=min(k,m);
	set< ll> s;
	map< ll , ll> now;
	for(int i=0;i<m;i++) s.insert(v[i].ss.ff),s.insert(v[i].ss.ss);
	int vertex=0;
	for(auto &i:s) 	now[i]=(vertex++);
	n=s.size();
	vector<vector<ll> > dp(n+1,vector<ll>(n+1,inf));
	for(int i=0;i<m;i++)
	{
		ll x,y,w;
		x=now[v[i].ss.ff];
		y=now[v[i].ss.ss];
		w=v[i].ff;
		dp[x][y]=w;
		dp[y][x]=w;
	}
	vector<ll> ans;
	for(int i=0;i<n;i++) dp[i][i]=0;
	for(int p=0;p<n;p++)
		for(int i=0;i<n;++i)
			for(int j=0;j<n;++j)
				dp[i][j]=min(dp[i][j],dp[i][p]+dp[p][j]);
	for(int i=0;i<n;i++)
		for(int j=0;j<i;j++)
			ans.pb(dp[i][j]);
	sort(all(ans));
	cout<<ans[k-1];
	return 0;
}


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

#define ff first
#define ss second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define check(x) cout << #x << " : " << (x) << endl
#define all(v) v.begin(),v.end()
#define endl '\n'
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair< ll , ll > mypair;
typedef priority_queue <ll> max_heap;
typedef priority_queue <ll, vector<ll>, greater<ll> > min_heap;
const ll mod=1e9+7;
const int inf=1e16;
const int N=402;

int main()
{
	boost;
	int n,m,k;
	cin>>n>>m>>k;
	/*
	if(k<=m)
	{
		vector<int> ans;
		while(m--)
		{
			int x,y,w;
			cin>>x>>y>>w;
			ans.pb(w);
		}
		sort(all(ans));
		cout<<ans[k-1];
		return 0;
	}*/
	vector<vector<ll> > dp(n+1,vector<ll>(n+1,inf));
	while(m--)
	{
		ll x,y,w;
		cin>>x>>y>>w;
		x--;y--;
		dp[x][y]=w;
		dp[y][x]=w;
	}
	vector<ll> ans;
	for(int i=0;i<n;i++) dp[i][i]=0;
	for(int p=0;p<n;p++)
		for(int i=0;i<n;++i)
			for(int j=0;j<n;++j)
				dp[i][j]=min(dp[i][j],dp[i][p]+dp[p][j]);
	for(int i=0;i<n;i++)
		for(int j=0;j<i;j++)
			ans.pb(dp[i][j]);
	sort(all(ans));
	cout<<ans[k-1];
	return 0;
}


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

#define ff first
#define ss second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define check(x) cout << #x << " : " << (x) << endl
#define all(v) v.begin(),v.end()
#define endl '\n'
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair< ll , ll > mypair;
typedef priority_queue <ll> max_heap;
typedef priority_queue <ll, vector<ll>, greater<ll> > min_heap;
const ll mod=1e9+7;
const int inf=1e9;
const int N=402;

int main()
{
	boost;
	int n,m,k;
	cin>>n>>m>>k;
	/*
	if(k<=m)
	{
		vector<int> ans;
		while(m--)
		{
			int x,y,w;
			cin>>x>>y>>w;
			ans.pb(w);
		}
		sort(all(ans));
		cout<<ans[k-1];
		return 0;
	}*/
	vector<vector<int> > dp(n+1,vector<int>(n+1,inf));
	while(m--)
	{
		int x,y,w;
		cin>>x>>y>>w;
		x--;y--;
		dp[x][y]=w;
		dp[y][x]=w;
	}
	vector<int> ans;
	for(int i=0;i<n;i++) dp[i][i]=0;
	for(int p=0;p<n;p++)
		for(int i=0;i<n;++i)
			for(int j=0;j<n;++j)
				dp[i][j]=min(dp[i][j],dp[i][p]+dp[p][j]);
	for(int i=0;i<n;i++)
		for(int j=0;j<i;j++)
			ans.pb(dp[i][j]);
	sort(all(ans));
	cout<<ans[k-1];
	return 0;
}


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

#define ff first
#define ss second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define check(x) cout << #x << " : " << (x) << endl
#define all(v) v.begin(),v.end()
#define endl '\n'
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair< ll , ll > mypair;
typedef priority_queue <ll> max_heap;
typedef priority_queue <ll, vector<ll>, greater<ll> > min_heap;
const ll mod=1e9+7;
const ll inf=1e16;
const ll N=402;

int main()
{
	boost;
	int n,m,k;
	cin>>n>>m>>k;
	/*
	if(k<=m)
	{
		vector<int> ans;
		while(m--)
		{
			int x,y,w;
			cin>>x>>y>>w;
			ans.pb(w);
		}
		sort(all(ans));
		cout<<ans[k-1];
		return 0;
	}*/
	vector<vector<ll> > dp(n+1,vector<ll>(n+1,inf));
	while(m--)
	{
		ll x,y,w;
		cin>>x>>y>>w;
		x--;y--;
		dp[x][y]=w;
		dp[y][x]=w;
	}
	vector<ll> ans;
	for(int i=0;i<n;i++) dp[i][i]=0;
	for(int p=0;p<n;p++)
		for(int i=0;i<n;++i)
			for(int j=0;j<n;++j)
				dp[i][j]=min(dp[i][j],dp[i][p]+dp[p][j]);
	for(int i=0;i<n;i++)
		for(int j=0;j<i;j++)
			ans.pb(dp[i][j]);
	sort(all(ans));
	cout<<ans[k-1];
	return 0;
}


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

#define ff first
#define ss second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define check(x) cout << #x << " : " << (x) << endl
#define all(v) v.begin(),v.end()
#define endl '\n'
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair< ll , ll > mypair;
typedef priority_queue <ll> max_heap;
typedef priority_queue <ll, vector<ll>, greater<ll> > min_heap;
const ll mod=1e9+7;
const int inf=1e9;
const int N=402;

int main()
{
	boost;
	int n,m,k;
	cin>>n>>m>>k;
	/*
	if(k<=m)
	{
		vector<int> ans;
		while(m--)
		{
			int x,y,w;
			cin>>x>>y>>w;
			ans.pb(w);
		}
		sort(all(ans));
		cout<<ans[k-1];
		return 0;
	}*/
	vector<vector<ll> > dp(n+1,vector<ll>(n+1,inf));
	while(m--)
	{
		ll x,y,w;
		cin>>x>>y>>w;
		x--;y--;
		dp[x][y]=w;
		dp[y][x]=w;
	}
	vector<ll> ans;
	for(int i=0;i<n;i++) dp[i][i]=0;
	for(int p=0;p<n;p++)
		for(int i=0;i<n;++i)
			for(int j=0;j<n;++j)
				dp[i][j]=min(dp[i][j],dp[i][p]+dp[p][j]);
	for(int i=0;i<n;i++)
		for(int j=0;j<i;j++)
			ans.pb(dp[i][j]);
	sort(all(ans));
	cout<<ans[k-1];
	return 0;
}


#include<iostream>
#include<string.h>
#include<vector>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
int n,m,k;
struct edge
{
    int to;
    ll cost;
};
vector<edge> G[200005];
bool cmp(edge& e1,edge &e2)
{
    return e1.cost<e2.cost;
}
int b[3000005];int tot=0;
bool vis[200005];
void dfs(int d,int u,int md,ll cc)
{
    if(d==md)
    {
        b[++tot]=cc;
        return ;
    }
    else {
        for(int j=0;j<G[u].size();j++)
        {
            if(vis[G[u][j].to])continue;
            vis[G[u][j].to]=1;
            dfs(d+1,G[u][j].to,md,cc+G[u][j].cost);
        }
    }
}
int all=5000000;int Cnt=0;
void dfs2(int d,int u,ll cc)
{
    if(Cnt>=all)
    {
        b[++tot]=cc;
        return ;
    }
    else {
        Cnt++;
           if(Cnt>=all)return;
        for(int j=0;j<G[u].size();j++)
        {
           if(Cnt>=all)return;
            if(vis[G[u][j].to])continue;
            vis[G[u][j].to]=1;
            dfs2(d+1,G[u][j].to,cc+G[u][j].cost);
           if(Cnt>=all)return;
        }
    }
           if(Cnt>=all)return;
}
int main()
{
#ifndef ONLINE_JUDGE
    freopen("in.txt","r",stdin);
#endif
    ios::sync_with_stdio(0);
    cin>>n>>m>>k;
   int x,y;ll c;
  while(m--)
  {
      cin>>x>>y>>c;
      G[x].push_back((edge){y,c});
      G[y].push_back((edge){x,c});
        b[++tot]=c;
  }
    sort(b+1,b+1+tot);
    for(int md=2;md<=400;md++)
    {
        memset(vis,0,sizeof(vis));
        for(int i=1;i<=n;i++)
    {
        vis[i]=1;
        dfs(0,i,md,0ll);
        vis[i]=0;
    }
  }
    sort(b+1,b+1+tot);
  for(int i=1;i<=n;i++)sort(G[i].begin(),G[i].end(),cmp);

        memset(vis,0,sizeof(vis));
        for(int i=1;i<=n;i++)
    {
        vis[i]=1;
        dfs2(0,i,0ll);
        vis[i]=0;
    }
   sort(b+1,b+1+tot);
  cout<<b[k]<<endl;
    return 0;

}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,m,k;
ll d[808][808];
int mp[200005];
struct edge
{
	int from;int to;ll cost;
};
edge es[200005];
bool cmp(edge &e1, edge &e2)
{
	return e1.cost<e2.cost;
}
ll tmp[770005];
int main() {
#ifndef ONLINE_JUDGE
  freopen("in.txt","r",stdin);
#endif // ONLINE_JUDGE
  ios::sync_with_stdio(0);
  cin>>n>>m>>k;
  for(int i=1;i<=m;i++)cin>>es[i].from>>es[i].to>>es[i].cost;
  sort(es+1,es+m+1,cmp);
  int nume = min(k,m);
  int cnt=0;int u,v;int w;
  memset(mp,-1,sizeof(mp));
  memset(d,0x3f,sizeof(d));
  ll INF=d[0][0];
  for(int i=1;i<=nume;i++)
  {
  	u = es[i].from ;
  	v = es[i].to ;
  	w = es[i].cost;
    if(mp[u]==-1)mp[u]=++cnt;
    if(mp[v]==-1)mp[v]=++cnt;
    d[mp[u]][mp[v]] = d[mp[v]][mp[u]] = w;
  }
    for(int i=1;i<=cnt;i++)
    {
        for(int j=1;j<=cnt;j++)
        {
            for(int k=1;k<=cnt;k++)
                d[i][j] = min( d[i][j] , d[i][k] + d[k][j] );

        }
    }
    int cnt2=0;
    for(int i=1;i<=cnt;i++)
        for(int j=i+1;j<=cnt;j++)
            if(d[i][j] != INF) tmp[++cnt2] = d[i][j];
    sort(tmp+1,tmp+1+cnt2);
    cout << tmp[k] <<endl;
  return 0;
}


#include<iostream>
#include<string.h>
#include<vector>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
int n,m,k;
struct edge
{
    int to;
    ll cost;
};
vector<edge> G[200005];
bool cmp(edge& e1,edge &e2)
{
    return e1.cost<e2.cost;
}
int b[3000005];int tot=0;
bool vis[200005];
void dfs(int d,int u,int md,ll cc)
{
    if(d==md)
    {
        b[++tot]=cc;
        return ;
    }
    else {
        for(int j=0;j<G[u].size();j++)
        {
            if(vis[G[u][j].to])continue;
            vis[G[u][j].to]=1;
            dfs(d+1,G[u][j].to,md,cc+G[u][j].cost);
        }
    }
}
int all=1000000;int Cnt=0;
void dfs2(int d,int u,ll cc)
{
    if(Cnt>=all)
    {
        b[++tot]=cc;
        return ;
    }
    else {
        Cnt++;
           if(Cnt>=all)return;
        for(int j=0;j<G[u].size();j++)
        {
           if(Cnt>=all)return;
            if(vis[G[u][j].to])continue;
            vis[G[u][j].to]=1;
            dfs2(d+1,G[u][j].to,cc+G[u][j].cost);
           if(Cnt>=all)return;
        }
    }
           if(Cnt>=all)return;
}
int main()
{
#ifndef ONLINE_JUDGE
    freopen("in.txt","r",stdin);
#endif
    ios::sync_with_stdio(0);
    cin>>n>>m>>k;
   int x,y;ll c;
  while(m--)
  {
      cin>>x>>y>>c;
      G[x].push_back((edge){y,c});
      G[y].push_back((edge){x,c});
        b[++tot]=c;
  }
    sort(b+1,b+1+tot);
    for(int md=2;md<=400;md++)
    {
        memset(vis,0,sizeof(vis));
        for(int i=1;i<=n;i++)
    {
        vis[i]=1;
        dfs(0,i,md,0ll);
        vis[i]=0;
    }
  }
    sort(b+1,b+1+tot);
  for(int i=1;i<=n;i++)sort(G[i].begin(),G[i].end(),cmp);

        memset(vis,0,sizeof(vis));
        for(int i=1;i<=n;i++)
    {
        vis[i]=1;
        dfs2(0,i,0ll);
        vis[i]=0;
    }

    return 0;

}


#include<iostream>
#include<string.h>
#include<vector>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
int n,m,k;
struct edge
{
    int to;
    ll cost;
};
vector<edge> G[200005];
bool cmp(edge& e1,edge &e2)
{
    return e1.cost<e2.cost;
}
int b[3000005];int tot=0;
bool vis[200005];
void dfs(int d,int u,int md,ll cc)
{
    if(d==md)
    {
        b[++tot]=cc;
        return ;
    }
    else {
        for(int j=0;j<G[u].size();j++)
        {
            if(vis[G[u][j].to])continue;
            vis[G[u][j].to]=1;
            dfs(d+1,G[u][j].to,md,cc+G[u][j].cost);
        }
    }
}
int all=8000000;int Cnt=0;
void dfs2(int d,int u,ll cc)
{
    if(Cnt>=all)
    {
        b[++tot]=cc;
        return ;
    }
    else {
        Cnt++;
           if(Cnt>=all)return;
        for(int j=0;j<G[u].size();j++)
        {
           if(Cnt>=all)return;
            if(vis[G[u][j].to])continue;
            vis[G[u][j].to]=1;
            dfs2(d+1,G[u][j].to,cc+G[u][j].cost);
           if(Cnt>=all)return;
        }
    }
           if(Cnt>=all)return;
}
int main()
{
#ifndef ONLINE_JUDGE
    freopen("in.txt","r",stdin);
#endif
    ios::sync_with_stdio(0);
    cin>>n>>m>>k;
   int x,y;ll c;
  while(m--)
  {
      cin>>x>>y>>c;
      G[x].push_back((edge){y,c});
      G[y].push_back((edge){x,c});
        b[++tot]=c;
  }
    sort(b+1,b+1+tot);
    for(int md=2;md<=400;md++)
    {
        memset(vis,0,sizeof(vis));
        for(int i=1;i<=n;i++)
    {
        vis[i]=1;
        dfs(0,i,md,0ll);
        vis[i]=0;
    }
  }
    sort(b+1,b+1+tot);
  for(int i=1;i<=n;i++)sort(G[i].begin(),G[i].end(),cmp);

        memset(vis,0,sizeof(vis));
        for(int i=1;i<=n;i++)
    {
        vis[i]=1;
        dfs2(0,i,0ll);
        vis[i]=0;
    }
   sort(b+1,b+1+tot);
  cout<<b[k]<<endl;
    return 0;

}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,m,k;
ll d[808][808];
int mp[200005];
struct edge
{
	int from;int to;ll cost;
};
edge es[200005];
bool cmp(edge &e1, edge &e2)
{
	return e1.cost<e2.cost;
}
ll tmp[770005];
int main() {
#ifndef ONLINE_JUDGE
  freopen("in.txt","r",stdin);
#endif // ONLINE_JUDGE
  ios::sync_with_stdio(0);
  cin>>n>>m>>k;
  for(int i=1;i<=m;i++)cin>>es[i].from>>es[i].to>>es[i].cost;
  sort(es+1,es+m+1,cmp);
  int nume = min(k,m);
  int cnt=0;int u,v;int w;
  memset(mp,-1,sizeof(mp));
  memset(d,0x3f,sizeof(d));
  ll INF=d[0][0];
  for(int i=1;i<=nume;i++)
  {
  	u = es[i].from ;
  	v = es[i].to ;
  	w = es[i].cost;
    if(mp[u]==-1)mp[u]=++cnt;
    if(mp[v]==-1)mp[v]=++cnt;
    d[mp[u]][mp[v]] = d[mp[v]][mp[u]] = w;
  }
    for(int i=1;i<=cnt;i++)
    {
        for(int j=1;j<=cnt;j++)
        {
            for(int k=1;k<=cnt;k++)
                d[i][j] = min( d[i][j] , d[i][k] + d[k][j] );

        }
    }
    int cnt2=0;
    for(int i=1;i<=cnt;i++)
        for(int j=i+1;j<=cnt;j++)
            tmp[++cnt2] = d[i][j];
    sort(tmp+1,tmp+1+cnt2);
    cout << tmp[k] <<endl;
  return 0;
}


#include<iostream>
#include<string.h>
#include<vector>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
int n,m,k;
struct edge
{
    int to;
    ll cost;
};
vector<edge> G[200005];
int b[3000005];int tot=0;
bool vis[200005];
void dfs(int d,int u,int md,ll cc)
{
    if(d==md)
    {
        b[++tot]=cc;
        return ;
    }
    else {
        for(int j=0;j<G[u].size();j++)
        {
            if(vis[G[u][j].to])continue;
            vis[G[u][j].to]=1;
            dfs(d+1,G[u][j].to,md,cc+G[u][j].cost);
        }
    }
}
int main()
{
#ifndef ONLINE_JUDGE
    freopen("in.txt","r",stdin);
#endif
    ios::sync_with_stdio(0);
    cin>>n>>m>>k;
   int x,y;ll c;
  while(m--)
  {
      cin>>x>>y>>c;
      G[x].push_back((edge){y,c});
      G[y].push_back((edge){x,c});
        b[++tot]=c;
  }
    sort(b+1,b+1+tot);
    for(int md=2;md<=400;md++)
    {
        memset(vis,0,sizeof(vis));
        for(int i=1;i<=n;i++)
    {
        vis[i]=1;
        dfs(0,i,md,0ll);
        vis[i]=0;
    }
  }
    sort(b+1,b+1+tot);
   cout<<b[k]<<endl;
  return 0;

}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,m,k;
ll d[808][808];
int mp[200005];
struct edge
{
	int from;int to;ll cost;
};
edge es[200005];
bool cmp(edge &e1, edge &e2)
{
	return e1.cost<e2.cost;
}
ll tmp[770005];
int main() {
#ifndef ONLINE_JUDGE
  freopen("in.txt","r",stdin);
#endif // ONLINE_JUDGE
  ios::sync_with_stdio(0);
  cin>>n>>m>>k;
  for(int i=1;i<=m;i++)cin>>es[i].from>>es[i].to>>es[i].cost;
  sort(es+1,es+m+1,cmp);
  int nume = min(k,m);
  int cnt=0;int u,v;int w;
  memset(mp,-1,sizeof(mp));
  memset(d,0x3f,sizeof(d));
  ll INF=d[0][0];
  for(int i=1;i<=nume;i++)
  {
  	u = es[i].from ;
  	v = es[i].to ;
  	w = es[i].cost;
    if(mp[u]==-1)mp[u]=++cnt;
    if(mp[v]==-1)mp[v]=++cnt;
    d[mp[u]][mp[v]] = d[mp[v]][mp[u]] = w;
  }
  for(int k=1;k<=cnt;k++)
    for(int i=1;i<=cnt;i++)
    {
        for(int j=1;j<=cnt;j++)
        {
                d[i][j] = min( d[i][j] , d[i][k] + d[k][j] );

        }
    }
    int cnt2=0;
    for(int i=1;i<=cnt;i++)
        for(int j=i+1;j<=cnt;j++)
            tmp[++cnt2] = d[i][j];
    sort(tmp+1,tmp+1+cnt2);
    cout << tmp[k] <<endl;
  return 0;
}


#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
typedef long long ll;
using namespace std;
vector<pair<int,int> >g[200001];
map<pair<int,int>,int>used;
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,m,k;cin>>n>>m>>k;
    set<pair<int,pair<int,int> > >st;
    vector<pair<int,pair<int,int> > >v;
    for (int i=1;i<=m;i++){
        int a,b,c;cin>>a>>b>>c;
        if (a>b) swap(a,b);
        g[a].push_back({b,c});
        g[b].push_back({a,c});
        st.insert({c,{a,b}});
        used[{a,b}]=c;
        if (st.size()>k){
            pair<int,pair<int,int> >last=*st.rbegin();
            used[last.second]=0;
            st.erase(last);
        }
    }
    int cnt=0;
    while (true){
        if (st.size()>k){
            pair<int,pair<int,int> >last=*st.rbegin();
            used[last.second]=0;
            st.erase(last);
        }
        pair<int,pair<int,int> >cur=*st.begin();
        used[cur.second]=cur.first;
        int a=cur.second.first;
        int b=cur.second.second;
        int c=cur.first;
        st.erase(st.begin());
        cnt++;
        if (cnt==k){
            cout<<c;
            return 0;
        }
        for (auto x:g[a]){
            int to=x.first;
            int w=x.second;
            int i=min(to,b);
            int j=max(to,b);
            if (i==j) continue;
            int d=used[{i,j}];
            if (!d){
                d=c+w;
                st.insert({d,{i,j}});
                used[{i,j}]=d;
            } else if (d>c+w){
                st.erase({d,{i,j}});
                d=c+w;
                st.insert({d,{i,j}});
                used[{i,j}]=d;
            }
        }
        for (auto x:g[b]){
            int to=x.first;
            int w=x.second;
            int i=min(to,a);
            int j=max(to,a);
            if (i==j) continue;
            int d=used[{i,j}];
            if (!d){
                d=c+w;
                st.insert({d,{i,j}});
                used[{i,j}]=d;
            } else if (d>c+w){
                st.erase({d,{i,j}});
                d=c+w;
                st.insert({d,{i,j}});
                used[{i,j}]=d;
            }
        }

    }
    return 0;
}


#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
typedef long long ll;
using namespace std;
int mp[200001];
int d[1001][1001];
char in[1<<21]; // sizeof in varied in problem
char const*o;

void init_in()
{
    o = in;
    in[ fread(in,1,sizeof(in)-4,stdin)]=0;//set 0 at the end of buffer.
}

int readInt(){
   unsigned u = 0, s = 0;

   while(*o && *o <= 32)++o; //skip whitespaces...

   if (*o == '-')s = ~s, ++o; else if (*o == '+')++o; // skip sign

   while(*o>='0' && *o<='9')u = (u<<3) + (u << 1) + (*o++ - '0');  // u * 10 = u * 8 + u * 2 :)

   return static_cast<int>( (u^s) + !!s) ;
}
void read(int &n){
    n=readInt();
}
int32_t main() {
   /* ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);*/
    int n,m,k;read(n);read(m);read(k);
    vector<pair<int,pair<int,int> > >u;
    for (int i=1;i<=m;i++){
        int a,b,c;read(a);read(b);read(c);
        u.push_back({c,{a,b}});
    }
    sort(u.begin(),u.end());
    while (u.size()>k) u.pop_back();
    int timer=0;
    for (int i=0;i<=1000;i++) for (int j=0;j<=1000;j++) d[i][j]=1000000000000001ll;
    for (auto cur:u){
        if (!mp[cur.second.first]) mp[cur.second.first]=++timer;
        if (!mp[cur.second.second]) mp[cur.second.second]=++timer;
        d[mp[cur.second.first]][mp[cur.second.second]]=cur.first;
        d[mp[cur.second.second]][mp[cur.second.first]]=cur.first;
    }
    for (int i=1;i<=timer;i++) d[i][i]=0;
    for (int i=1;i<=timer;i++){
        for (int j=1;j<=timer;j++){
            for (int t=1;t<=timer;t++){
                d[j][t]=min(d[j][t],d[j][i]+d[i][t]);
            }
        }
    }
    vector<int>ans;
    for (int i=1;i<=timer;i++){
        for (int j=i+1;j<=timer;j++){
            ans.push_back(d[i][j]);
        }
    }
    sort(ans.begin(),ans.end());
    cout<<ans[k-1];
    return 0;
}


#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
typedef long long ll;
using namespace std;
int mp[200001];
int d[1001][1001];
char in[1<<21]; // sizeof in varied in problem
char const*o;

void init_in()
{
    o = in;
    in[ fread(in,1,sizeof(in)-4,stdin)]=0;//set 0 at the end of buffer.
}

int readInt(){
   unsigned u = 0, s = 0;

   while(*o && *o <= 32)++o; //skip whitespaces...

   if (*o == '-')s = ~s, ++o; else if (*o == '+')++o; // skip sign

   while(*o>='0' && *o<='9')u = (u<<3) + (u << 1) + (*o++ - '0');  // u * 10 = u * 8 + u * 2 :)

   return static_cast<int>( (u^s) + !!s) ;
}
void read(int &n){
    n=readInt();
}
int32_t main() {
   /* ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);*/
    init_in();
    int n,m,k;read(n);read(m);read(k);
    vector<pair<int,pair<int,int> > >u;
    for (int i=1;i<=m;i++){
        int a,b,c;read(a);read(b);read(c);
        u.push_back({c,{a,b}});
    }
    sort(u.begin(),u.end());
    while (u.size()>k) u.pop_back();
    int timer=0;
    for (int i=0;i<=1000;i++) for (int j=0;j<=1000;j++) d[i][j]=1000000000000001ll;
    for (auto cur:u){
        if (!mp[cur.second.first]) mp[cur.second.first]=++timer;
        if (!mp[cur.second.second]) mp[cur.second.second]=++timer;
        d[mp[cur.second.first]][mp[cur.second.second]]=cur.first;
        d[mp[cur.second.second]][mp[cur.second.first]]=cur.first;
    }
    for (int i=1;i<=timer;i++) d[i][i]=0;
    for (int i=1;i<=timer;i++){
        for (int j=1;j<=timer;j++){
            for (int t=1;t<=timer;t++){
                d[j][t]=min(d[j][t],d[j][i]+d[i][t]);
            }
        }
    }
    vector<int>ans;
    for (int i=1;i<=timer;i++){
        for (int j=i+1;j<=timer;j++){
            ans.push_back(d[i][j]);
        }
    }
    sort(ans.begin(),ans.end());
    cout<<ans[k-1];
    return 0;
}


#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
typedef long long ll;
using namespace std;
int mp[200001];
int d[1001][1001];
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,m,k;cin>>n>>m>>k;
    vector<pair<int,pair<int,int> > >u;
    for (int i=1;i<=m;i++){
        int a,b,c;cin>>a>>b>>c;
        u.push_back({c,{a,b}});
    }
    sort(u.begin(),u.end());
    while (u.size()>k) u.pop_back();
    int timer=0;
    for (int i=0;i<=1000;i++) for (int j=0;j<=1000;j++) d[i][j]=1000000000000001ll;
    for (auto cur:u){
        if (!mp[cur.second.first]) mp[cur.second.first]=++timer;
        if (!mp[cur.second.second]) mp[cur.second.second]=++timer;
        d[mp[cur.second.first]][mp[cur.second.second]]=cur.first;
        d[mp[cur.second.second]][mp[cur.second.first]]=cur.first;
    }
    for (int i=1;i<=timer;i++) d[i][i]=0;
    for (int i=1;i<=timer;i++){
        for (int j=1;j<=timer;j++){
            for (int t=1;t<=timer;t++){
                d[j][t]=min(d[j][t],d[j][i]+d[i][t]);
            }
        }
    }
    vector<int>ans;
    for (int i=1;i<=timer;i++){
        for (int j=i+1;j<=timer;j++){
            ans.push_back(d[i][j]);
        }
    }
    sort(ans.begin(),ans.end());
    cout<<ans[k-1];
    return 0;
}


#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
typedef long long ll;
using namespace std;
int mp[200001];
int d[1001][1001];
template <class nmsl> inline void read(nmsl &x)
{
	x=0;
	char ch=getchar(), w=0;
	while(!isdigit(ch))w=(ch=='-'), ch=getchar();
	while(isdigit(ch))x=(x<<1)+(x<<3)+(ch^48), ch=getchar();
	x=w?-x:x;
}
int32_t main() {
   /* ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);*/
    int n,m,k;read(n);read(m);read(k);
    vector<pair<int,pair<int,int> > >u;
    for (int i=1;i<=m;i++){
        int a,b,c;read(a);read(b);read(c);
        u.push_back({c,{a,b}});
    }
    sort(u.begin(),u.end());
    while (u.size()>k) u.pop_back();
    int timer=0;
    for (int i=0;i<=1000;i++) for (int j=0;j<=1000;j++) d[i][j]=1000000000000001ll;
    for (auto cur:u){
        if (!mp[cur.second.first]) mp[cur.second.first]=++timer;
        if (!mp[cur.second.second]) mp[cur.second.second]=++timer;
        d[mp[cur.second.first]][mp[cur.second.second]]=cur.first;
        d[mp[cur.second.second]][mp[cur.second.first]]=cur.first;
    }
    for (int i=1;i<=timer;i++) d[i][i]=0;
    for (int i=1;i<=timer;i++){
        for (int j=1;j<=timer;j++){
            for (int t=1;t<=timer;t++){
                d[j][t]=min(d[j][t],d[j][i]+d[i][t]);
            }
        }
    }
    vector<int>ans;
    for (int i=1;i<=timer;i++){
        for (int j=i+1;j<=timer;j++){
            ans.push_back(d[i][j]);
        }
    }
    sort(ans.begin(),ans.end());
    cout<<ans[k-1];
    return 0;
}


#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
typedef long long ll;
using namespace std;
vector<pair<int,int> >g[200001];
map<pair<int,int>,int>used;
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,m,k;cin>>n>>m>>k;
    set<pair<int,pair<int,int> > >st;
    vector<pair<int,pair<int,int> > >v;
    for (int i=1;i<=m;i++){
        int a,b,c;cin>>a>>b>>c;
        if (a>b) swap(a,b);
        g[a].push_back({b,c});
        g[b].push_back({a,c});
        st.insert({c,{a,b}});
        used[{a,b}]=c;
    }
    int cnt=0;
    while (true){
        pair<int,pair<int,int> >cur=*st.begin();
        used[cur.second]=cur.first;
        int a=cur.second.first;
        int b=cur.second.second;
        int c=cur.first;
        st.erase(st.begin());
        cnt++;
        if (cnt==k){
            cout<<c<<endl;
            return 0;
        }
        for (auto x:g[a]){
            int to=x.first;
            int w=x.second;
            int i=min(to,b);
            int j=max(to,b);
            if (i==j) continue;
            int d=used[{i,j}];
            if (!d){
                d=c+w;
                st.insert({d,{i,j}});
                used[{i,j}]=d;
            } else if (d>c+w){
                st.erase({d,{i,j}});
                d=c+w;
                st.insert({d,{i,j}});
                used[{i,j}]=d;
            }
        }
        for (auto x:g[b]){
            int to=x.first;
            int w=x.second;
            int i=min(to,a);
            int j=max(to,a);
            if (i==j) continue;
            int d=used[{i,j}];
            if (!d){
                d=c+w;
                st.insert({d,{i,j}});
                used[{i,j}]=d;
            } else if (d>c+w){
                st.erase({d,{i,j}});
                d=c+w;
                st.insert({d,{i,j}});
                used[{i,j}]=d;
            }
        }

    }
    return 0;
}