function f(x){if(x!=p=P[x]){s=f(p);Q[x]+=Q[p];P[x]=s;x=s}return x}
$2{
	x=f(-$1);y=f(-$2);
	if(x==y)t+=Q[-$1]+$3!=Q[-$2];
	else
	{
		P[y]=x;
		Q[y]=Q[-$1]+$3-Q[-$2];
	}
}
!x{for(;i++<$1;)P[-i]=-i}
END{print t?"No":"Yes"}
