klskr
#include<bits/stdc++.h>
using namespace std;
const int N=1e5;
int c,n,m,p[N],ans;
struct eg{
int a,b,w;
bool operator <(const eg& egs){
return w<egs.w;
}
}e[N];
int find(int x){
if(p[x]!=x)p[x]=find(p[x]);
return p[x];
}
void klskr(){
for(int i=0;i<m;i++){
int x=find(e[i].a),y=find(e[i].b);
if(x!=y){
ans+=e[i].w;
p[x]=y;
}
}
}
int main(){
while(cin>>c>>m>>n){
ans=0;
for(int i=1;i<=n;i++)p[i]=i;
for(int i=1;i<=m;i++){
int a,b,w;
cin>>a>>b>>w;
e[i]={a,b,w};
}
sort(e+1,e+1+m);
klskr();
if(ans<=c)cout<<"Yes"<<endl;
else cout<<"No";
}
return 0;
}