#include using namespace std; typedef long long ll; void read() { freopen("trade.in","r",stdin); freopen("trade.out","w",stdout); } const int maxn = 10006; ll i,j,p,q,n,m,k,koren,vr[maxn]; vector > v[maxn],g[maxn]; vector obr[maxn]; map act; bool gfl; vector cyc; string s,f; bool comp[maxn]; int br; bool b[maxn]; double raz[maxn]; double cur; int Find(string s) { if(act[s]) return act[s]; act[s] = ++br; return act[s]; } void dfs(int u) { comp[u] = true; b[u] = 1; for(auto i:obr[u]) { if(!b[i]) dfs(i); } } void dfs2(int u,double tek) { raz[u] = tek; b[u] = 1; for(auto j:v[u]) { p = j.first; double d = -j.second; if(b[p] && p==i) { double nt = tek*d; if(nt-raz[p]>0.0000001) { gfl=1; return ; } continue; } dfs2(p,tek*d); } raz[u] = 0; b[u] = 0; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); read(); cin>>n; for(i=1;i<=n;i++) { cin>>s; cin>>f; cin>>cur; //cout<