Pagini recente » Cod sursa (job #2046058) | Cod sursa (job #2369721) | Cod sursa (job #1224161) | Cod sursa (job #1293257) | Cod sursa (job #290543)
Cod sursa(job #290543)
{$n+}
program ozz;
type vect=array[1..10000] of extended;
var t:boolean;
v:vect;
f,g:text;
i,j,m,n,x,y:longint;
z:extended;
begin
assign(f,'oz.in');assign(g,'oz.out');reset(f);rewrite(g);
readln(f,n,m);t:=true;
for i:=1 to m do begin
readln(f,x,y,z);
if v[x]=0 then v[x]:=z
else if trunc(v[x]/z)*z<>v[x] then if v[x]*z<=2000000000 then v[x]:=v[x]*z
else t:=false;
if v[y]=0 then v[y]:=z
else if trunc(v[y]/z)*z<>v[y] then if v[y]*z<=2000000000 then v[y]:=v[y]*z
else t:=false;
end;
if t then for i:=1 to n do write(g,v[i]:0:0,' ')
else write(g,-1);
close(f);close(g);end.