N,Q = gets.split.map &:to_i
cds = (0..N).map{ {} }
(N-1).times {
  a,b,c,d = gets.split.map &:to_i
  cds[a][b] = cds[b][a] = [c,d]
}

M = Math.sqrt(N).floor
$stderr.puts N, M
edges = Array.new(N+1, 0)
distances = Array.new(N+1, 0)
dtotal = Array.new(N+1,0)
td = 0
visited = { 1 => 1 }
queue = cds[1].map{ |n,_| [1,n] }.flatten
trail = [1]
lv = nil
express = {}
upes   = Array.new(N+1,nil)
lcatrail = Array.new(N+1,nil)
depth = Array.new(N+1,nil)
depth[1] = 0

while queue.size > 0 do
  n = queue.pop
  if !visited[n]
    #p "> #{n}"
    visited[n] = 1
    parent = queue[-1]
    c,d = cds[parent][n]
    #p parent, n, c,d
    edges[c] += 1
    distances[c] += d
    td += d
    dtotal[n] = td
    cds[n].each{ |m,_|
      next if visited[m]
      queue << n; queue << m
    }
    if trail.size % M == 0
      express[n] = [edges.dup,distances.dup]
    end
    i = 1
    ts = []
    while i <= trail.size do
      ts << trail[-i]
      i *= 2
    end
    lcatrail[n] = ts
    depth[n] = trail.size
    trail << n
    #p trail
  else
    #p "#{n} <"
    c,d = cds[lv][n]
    upes[lv] = n
    edges[c] -= 1
    distances[c] -= d
    td -= d
    trail.pop
  end
  lv = n
end

#p express, lcatrail, depth, upes, dtotal

def hop(lcatrail, u, d)
  while d > 0 do
    ts = lcatrail[u]
    m = d.bit_length-1
    u = ts[m]
    d -= (1 << m)
  end
  u
end

def lca(lcatrail, depth, u, v)
  d = depth[u] - depth[v]
  u2 = hop(lcatrail, u, d >= 0 ?  d : 0)
  v2 = hop(lcatrail, v, d <= 0 ? -d : 0)
  #p [u,v,d,u2,v2]
  while u2 != v2 do
    j = (0...lcatrail[u2].size).reverse_each.find{ |i|
      lcatrail[u2][i] != lcatrail[v2][i]
    } || 0
    u2 = lcatrail[u2][j]
    v2 = lcatrail[v2][j]
  end
  u2
end

def e_and_d(upes, cds, express, u, color)
  e,d = 0,0
  v = nil
  while u != 1 do
    if express[u]
      cos,dis = express[u]
      e += cos[color]
      d += dis[color]
      break
    end
    v = upes[u]
    co,di = cds[u][v]
    if co == color
      e += 1
      d += di
    end
    u = v
  end
  [e,d]
end

Q.times {
  x,y,u,v = gets.split.map &:to_i
  w = lca(lcatrail, depth, u, v)
  rs = [u,v,w].map{ |t| e_and_d(upes, cds, express, t, x) }
  xe = rs[0][0] + rs[1][0] - 2*rs[2][0]
  xd = rs[0][1] + rs[1][1] - 2*rs[2][1]
  td = dtotal[u] + dtotal[v] - 2*dtotal[w]
  p td - xd + xe*y
}
