#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_ll.hpp>

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,b,a) for(ll i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
double pi=acos(-1);
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
// #define mp make_pair
#define pq priority_queue
const ll mod=1e9+7;
#define f first
#define s second
#define pii pair< ll, ll >
#define vi vector<ll>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc ll t; cin >> t; while(t--)

// using namespace boost::multiprecision;
using namespace std;
void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<vector<pii>> adj;
vector<ll> store;
void dfs(ll u,ll p){
  for(auto i:adj[u]){
    if(i.f!=p){
      store[i.f]=store[u]^i.s;
      dfs(i.f,u);
    }
  }
}
void solve(){
  ll n,x,y,w;
  cin>>n;
  adj=vector<vector<pii>>(n);
  store=vector<ll>(n,0);
  rep(i,0,n-1){
    cin>>x>>y>>w;
    adj[x-1].pb({y-1,w});
    adj[y-1].pb({x-1,w});
  }
  dfs(0,0);
  ll dp[61],dp1[61];
  rep(i,0,61) dp[i]=0,dp1[i]=0;
  ll ans=0,c1,c2;
  rep(j,0,61){
     c1=0,c2=0;
      rep(i,0,n){
        if( store[i] & (1LL<<j)) c1++;
        else c2++;
      }
      ll z=1LL<<j;
      z%=mod;
      ans=(ans+(((z*c1)%mod)*c2)%mod)%mod;
  }
  cout<<ans<<endl;
}

int main(){
    optimizeIO();
    solve();
}

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
const int N=205;
int n,a[N];
vector<int>v,res1,res2;
vector<int>save[N];
bool flag;
void dfs(int cur,int sum){
	sum%=200;
	if(flag)	return;
	if(cur==n+1){
		if(save[sum].size()&&v.size()){
			flag=true;
			res1=save[sum];
			res2=v;
		}
		else	save[sum]=v;
		return;
	}
	dfs(cur+1,sum);
	
	v.push_back(cur);
	dfs(cur+1,sum+a[cur]);
	v.pop_back();
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)	scanf("%d",&a[i]);
	dfs(1,0);
	if(flag){
		puts("Yes");
		cout<<res1.size()<<" ";
		for(int i=0;i<res1.size();i++)	cout<<res1[i]<<" ";
		puts("");
		cout<<res2.size()<<" ";
		for(int i=0;i<res2.size();i++)	cout<<res2[i]<<" ";
	}
	else	puts("No");
	return 0;
}
/*
鸽巢原理
如果n个巢里有kn+1个鸽子，那么至少有一个巢里面有kn+1个鸽子 
*/
