//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <vector>

namespace n91 {

using i8 = std::int_fast8_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

constexpr usize operator"" _z(unsigned long long x) noexcept {
  return static_cast<usize>(x);
}

class rep {
  const usize f, l;

public:
  class itr {
    friend rep;
    usize i;
    constexpr itr(const usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr rep(const usize first, const usize last) noexcept
      : f(first), l(last) {}
  constexpr itr begin() const noexcept { return itr(f); }
  constexpr itr end() const noexcept { return itr(l); }
};
class revrep {
  const usize f, l;

public:
  class itr {
    friend revrep;
    usize i;
    constexpr itr(usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr revrep(usize first, usize last) noexcept : f(--first), l(--last) {}
  constexpr itr begin() const noexcept { return itr(l); }
  constexpr itr end() const noexcept { return itr(f); }
};
template <class T> using vec_alias = std::vector<T>;
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) {
  return a < b ? b - a : a - b;
}

} // namespace n91

#include <cassert>
#include <cstddef>
#include <memory>
#include <utility>
#include <vector>

template <class ValueMonoid, class OperatorMonoid, class Modifier>
class lazy_st_trees {
public:
  using value_structure = ValueMonoid;
  using value_type = typename value_structure::value_type;
  using operator_structure = OperatorMonoid;
  using operator_type = typename operator_structure::value_type;
  using modifier = Modifier;

private:
  class node_type {
  public:
    node_type *left, *right, *parent;
    typename lazy_st_trees::value_type value, sum;
    typename lazy_st_trees::operator_type lazy;
    bool reversed; // reverse->lazy
    node_type(node_type *const p)
        : left(p), right(p), parent(p), value(value_structure::identity()),
          sum(value_structure::identity()),
          lazy(operator_structure::identity()), reversed(0) {}
  };

  using container_type = ::std::vector<node_type>;

public:
  using size_type = typename container_type::size_type;

private:
  using pointer = node_type *;
  using const_pointer = const node_type *;

  static void reverse(const pointer ptr) {
    ptr->lazy = operator_structure::reverse(::std::move(ptr->lazy));
    ptr->reversed ^= 1;
  }
  static void push(const pointer ptr) {
    if (ptr->reversed) {
      ptr->reversed = 0;
      ptr->value = value_structure::reverse(::std::move(ptr->value));
      ::std::swap(ptr->left, ptr->right);
      reverse(ptr->left);
      reverse(ptr->right);
    }
    ptr->left->lazy = operator_structure::operation(ptr->left->lazy, ptr->lazy);
    ptr->right->lazy =
        operator_structure::operation(ptr->right->lazy, ptr->lazy);
    ptr->value = modifier::operation(ptr->value, ptr->lazy);
    ptr->lazy = operator_structure::identity();
  }
  void propagate(pointer ptr) {
    pointer prev = nullptr;
    while (ptr != nil()) {
      ::std::swap(ptr->parent, prev);
      ::std::swap(ptr, prev);
    }
    while (prev) {
      push(prev);
      ::std::swap(prev->parent, ptr);
      ::std::swap(prev, ptr);
    }
    nil()->sum = value_structure::identity();
    nil()->lazy = operator_structure::identity();
    nil()->reversed = 0;
  }
  static value_type reflect(const const_pointer ptr) {
    return modifier::operation(
        ptr->reversed ? value_structure::reverse(ptr->sum) : ptr->sum,
        ptr->lazy);
  }
  static void calc(const pointer ptr) {
    ptr->sum = value_structure::operation(
        value_structure::operation(reflect(ptr->left), ptr->value),
        reflect(ptr->right));
  }
  static void rotate_l(const pointer ptr, const pointer ch) {
    ptr->right = ch->left;
    ch->left->parent = ptr;
    calc(ptr);
    ch->left = ptr;
    ptr->parent = ch;
  }
  static void rotate_r(const pointer ptr, const pointer ch) {
    ptr->left = ch->right;
    ch->right->parent = ptr;
    calc(ptr);
    ch->right = ptr;
    ptr->parent = ch;
  }
  static void splay(const pointer ptr) {
    for (pointer x, y = ptr;;) {
      x = ptr->parent;
      if (x->left == y) {
        y = x->parent;
        ptr->parent = y->parent;
        if (y->left == x)
          rotate_r(y, x), rotate_r(x, ptr);
        else if (y->right == x)
          rotate_l(y, ptr), rotate_r(x, ptr);
        else
          return ptr->parent = y, rotate_r(x, ptr);
      } else if (x->right == y) {
        y = x->parent;
        ptr->parent = y->parent;
        if (y->right == x)
          rotate_l(y, x), rotate_l(x, ptr);
        else if (y->left == x)
          rotate_r(y, ptr), rotate_l(x, ptr);
        else
          return ptr->parent = y, rotate_l(x, ptr);
      } else {
        return;
      }
    }
  }
  void expose(const pointer ptr) {
    propagate(ptr);
    pointer x = ptr, prev = nil();
    while (x != nil()) {
      splay(x);
      x->right = prev;
      calc(x);
      prev = x;
      x = x->parent;
    }
    splay(ptr);
    calc(ptr);
  }
  void reroot(const pointer ptr) {
    expose(ptr);
    reverse(ptr);
  }

  container_type nodes;

  pointer get_ptr(const size_type v) { return nodes.data() + v; }
  pointer nil() { return &nodes.back(); }

public:
  lazy_st_trees() : nodes() {}
  explicit lazy_st_trees(const size_type size) : nodes() {
    nodes.reserve(size + 1);
    nodes.resize(size + 1, node_type(nodes.data() + size));
  }

  bool empty() const { return size() == 0; }
  size_type size() const { return nodes.size() - 1; }

  bool connected(const size_type v, const size_type u) {
    assert(v < size());
    assert(u < size());
    expose(get_ptr(v));
    expose(get_ptr(u));
    return nodes[v].parent != nil() || v == u;
  }
  value_type fold_path(const size_type v, const size_type u) {
    assert(v < size());
    assert(u < size());
    assert(connected(v, u));
    reroot(get_ptr(v));
    expose(get_ptr(u));
    return nodes[u].sum;
  }

  void link(const size_type parent, const size_type child) {
    assert(parent < size());
    assert(child < size());
    assert(!connected(parent, child));
    reroot(get_ptr(child));
    nodes[child].parent = get_ptr(parent);
  }
  void cut(const size_type v) {
    assert(v < size());
    expose(get_ptr(v));
    nodes[v].left->parent = nil();
    nodes[v].left = nil();
    nodes[v].sum = nodes[v].value;
  }
  void update_path(const size_type v, const size_type u,
                   const operator_type &value) {
    assert(v < size());
    assert(u < size());
    assert(connected(v, u));
    reroot(get_ptr(v));
    expose(get_ptr(u));
    nodes[u].lazy = value;
  }
  template <class F> void update_vertex(const size_type v, const F &f) {
    assert(v < size());
    expose(get_ptr(v));
    nodes[v].value = f(::std::move(nodes[v].value));
    calc(get_ptr(v));
  }
};

#include <algorithm>
#include <iostream>
#include <utility>

namespace n91 {

class trivial_group {
public:
  class value_type {};
  static constexpr value_type operation(const value_type,
                                        const value_type) noexcept {
    return value_type();
  }
  static constexpr value_type identity() noexcept { return value_type(); }
  static constexpr value_type inverse(const value_type) noexcept {
    return value_type();
  }
  static constexpr value_type reverse(const value_type) noexcept {
    return value_type();
  }
};

template <class T> class trivial_action {
public:
  static constexpr typename T::value_type
  operation(const typename T::value_type &lhs,
            const typename trivial_group::value_type &) noexcept {
    return lhs;
  }
};

void main_() {
  using v = std::pair<u32, u32>;

  struct vop {
    using value_type = v;
    static constexpr v operation(const v &l, const v &r) noexcept {
      return {l.first + r.first, l.second + r.second};
    }
    static constexpr v identity() noexcept { return {}; }
    static constexpr v reverse(const v &x) noexcept { return x; }
  };

  usize n, q;
  std::cin >> n >> q;

  lazy_st_trees<vop, trivial_group, trivial_action<vop>> lst(n + n - 1_z);

  struct edge {
    usize index;
    u32 cost;
  };

  auto es = md_vec(n - 1_z, 0_z, edge());

  for (const auto i : rep(0_z, n - 1_z)) {
    usize a, b, c;
    u32 d;
    std::cin >> a >> b >> c >> d;
    --a;
    --b;
    --c;
    lst.update_vertex(n + i, [d](auto) { return v(static_cast<u32>(0), d); });
    lst.link(n + i, a);
    lst.link(n + i, b);
    es[c].push_back({i, d});
  }

  std::vector<u32> ans(q);

  struct query {
    usize index;
    u32 cost;
    usize u, v;
  };

  auto qs = md_vec(n - 1_z, 0_z, query());

  for (const auto i : rep(0_z, q)) {
    usize x;
    u32 y;
    usize u, v;
    std::cin >> x >> y >> u >> v;
    --x;
    --u;
    --v;
    qs[x].push_back({i, y, u, v});
  }

  for (const auto i : rep(0_z, n - 1_z)) {
    for (const auto &e : es[i]) {
      lst.update_vertex(n + e.index, [](const auto &) {
        return v(static_cast<u32>(1), static_cast<u32>(0));
      });
    }
    for (const auto e : qs[i]) {
      const auto ret = lst.fold_path(e.u, e.v);
      ans[e.index] = e.cost * ret.first + ret.second;
    }
    for (const auto &e : es[i]) {
      lst.update_vertex(n + e.index, [&e](const auto &) {
        return v(static_cast<u32>(0), e.cost);
      });
    }
  }

  for (const auto &e : ans) {
    std::cout << e << std::endl;
  }
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


Measured memory_bytes: 27248