def f(n,u,c) res=[0] $gs[n].each{|u2| next if u==u2 res<0 then res3<