exec({'RUBY_THREAD_VM_STACK_SIZE'=>'1000000000'}, '/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

N, Q = gets.split.map(&:to_i)
ABCDs = (N - 1).times.map{gets.split.map(&:to_i)}
XYUVs = Q.times.map{gets.split.map(&:to_i)}

@g = Array.new(N + 1){[]}
ABCDs.each{|a, b, c, d| @g[a] << [b, c, d]; @g[b] << [a, c, d]}

def euler_tour(x, d = 0, p = nil, acc = [])
  acc << [x, d]
  @g[x].each do |y, _, _|
    next if y == p
    acc = euler_tour(y, d + 1, x, acc)
    acc << [x, d]
  end
  acc
end

vds = euler_tour(1)
@tv, @td = vds.transpose
@v2i = @tv.map.with_index.to_h
@v2d = vds.to_h
s = @tv.size
@sp = [[*0 ... s]]
(1 ... s.bit_length).each do |i|
  ps = @sp[-1]
  w = 1 << (i - 1)
  n1 = ps[0 ... -w]
  n2 = ps[w .. -1]
  @sp << n1.zip(n2).map{|l, r| @td[l] < @td[r] ? l : r}
end

def lca(x, y)
  ix = @v2i[x]
  iy = @v2i[y]
  ix, iy = iy, ix if ix > iy
  items = iy - ix + 1
  l = items.bit_length - 1
  n1 = @sp[l][ix]
  n2 = @sp[l][iy - (1 << l) + 1]
  @tv[@td[n1] < @td[n2] ? n1 : n2]
end

@ts = Array.new(N + 1){[]}
XYUVs.each_with_index do |(x, y, u, v), i|
  @ts[u] << [i, x, y, 1]
  @ts[v] << [i, x, y, 1]
  @ts[lca(u, v)] << [i, x, y, -2]
end

def dfs(x = 1, ss = [0] * (N + 1), ns = [0] * (N + 1), t = 0, p = 0, acc = [0] * Q)
  @ts[x].each{|i, c, d, f| acc[i] += f * (t - ss[c] + ns[c] * d)}
  @g[x].each do |y, c, d|
    next if y == p
    ss[c] += d
    ns[c] += 1
    t += d
    dfs(y, ss, ns, t, x, acc)
    ss[c] -= d
    ns[c] -= 1
    t -= d
  end
  acc
end

puts dfs.join("\n")