#include <iostream>
#include <vector>
#include <cstdio>
#include <sstream>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <functional>
#include <set>
#include <ctime>
#include <random>
#include <chrono>
#include <cassert>
#include <tuple>
#include <utility>
using namespace std;

namespace {
  using Integer = long long; //__int128;
  template<class T, class S> istream& operator >> (istream& is, pair<T,S>& p){return is >> p.first >> p.second;}
  template<class T> istream& operator >> (istream& is, vector<T>& vec){for(T& val: vec) is >> val; return is;}
  template<class T> istream& operator ,  (istream& is, T& val){ return is >> val;}
  template<class T, class S> ostream& operator << (ostream& os, const pair<T,S>& p){return os << p.first << " " << p.second;}
  template<class T> ostream& operator << (ostream& os, const vector<T>& vec){for(size_t i=0; i<vec.size(); i++) os << vec[i] << (i==vec.size()-1?"":" "); return os;}
  template<class T> ostream& operator ,  (ostream& os, const T& val){ return os << " " << val;}

  template<class H> void print(const H& head){ cout << head; }
  template<class H, class ... T> void print(const H& head, const T& ... tail){ cout << head << " "; print(tail...); }
  template<class ... T> void println(const T& ... values){ print(values...); cout << endl; }

  template<class H> void eprint(const H& head){ cerr << head; }
  template<class H, class ... T> void eprint(const H& head, const T& ... tail){ cerr << head << " "; eprint(tail...); }
  template<class ... T> void eprintln(const T& ... values){ eprint(values...); cerr << endl; }

  class range{ Integer start_, end_, step_; public: struct range_iterator{ Integer val, step_; range_iterator(Integer v, Integer step) : val(v), step_(step) {} Integer operator * (){return val;} void operator ++ (){val += step_;} bool operator != (range_iterator& x){return step_ > 0 ? val < x.val : val > x.val;} }; range(Integer len) : start_(0), end_(len), step_(1) {} range(Integer start, Integer end) : start_(start), end_(end), step_(1) {} range(Integer start, Integer end, Integer step) : start_(start), end_(end), step_(step) {} range_iterator begin(){ return range_iterator(start_, step_); } range_iterator   end(){ return range_iterator(  end_, step_); } };

  inline string operator "" _s (const char* str, size_t size){ return move(string(str)); }
  constexpr Integer my_pow(Integer x, Integer k, Integer z=1){return k==0 ? z : k==1 ? z*x : (k&1) ? my_pow(x*x,k>>1,z*x) : my_pow(x*x,k>>1,z);}
  constexpr Integer my_pow_mod(Integer x, Integer k, Integer M, Integer z=1){return k==0 ? z%M : k==1 ? z*x%M : (k&1) ? my_pow_mod(x*x%M,k>>1,M,z*x%M) : my_pow_mod(x*x%M,k>>1,M,z);}
  constexpr unsigned long long operator "" _ten (unsigned long long value){ return my_pow(10,value); }

  inline int k_bit(Integer x, int k){return (x>>k)&1;} //0-indexed

  mt19937 mt(chrono::duration_cast<chrono::nanoseconds>(chrono::steady_clock::now().time_since_epoch()).count());

  template<class T> string join(const vector<T>& v, const string& sep){ stringstream ss; for(size_t i=0; i<v.size(); i++){ if(i>0) ss << sep; ss << v[i]; } return ss.str(); }

  inline string operator * (string s, int k){ string ret; while(k){ if(k&1) ret += s; s += s; k >>= 1; } return ret; }
}

class HeavyLightDecomposition{
 public:
  struct heavy_set{
    vector<int> element;
    int depth;
    int parent_vertex;
    heavy_set(int v, int d, int par) : element(1,v), depth(d), parent_vertex(par){}
  };

  vector<vector<int>>& G;
  vector<heavy_set> S;
  vector<int> subtree_size;
  vector<int> set_index;
  vector<int> ele_index;

 private:
  int get_subtree_size(int pos, int par){
    int sz = 1;
    for(int ch : G[pos]){
      if(ch == par) continue;
      sz += get_subtree_size(ch, pos);
    }
    return subtree_size[pos] = sz;
  }

  void make_path(int pos, int par, int set_id){
    set_index[pos] = set_id;
    ele_index[pos] = S[set_id].element.size()-1;

    int largest_child = -1;
    int value = 0;

    for(int ch : G[pos]){
      if(ch == par) continue;
      if(value < subtree_size[ch]){
        value = subtree_size[ch];
        largest_child = ch;
      }
    }

    for(int ch : G[pos]){
      if(ch == par) continue;
      if(largest_child == ch){
        S[set_id].element.push_back(ch);
        make_path(ch, pos, set_id);
      }else{
        S.emplace_back( ch, S[set_id].depth+1, pos );
        make_path(ch, pos, S.size()-1);
      }
    }
  }

  void init(int root){
    subtree_size.resize(G.size(), 0);
    get_subtree_size(root,root);

    set_index.resize(G.size(), 0);
    ele_index.resize(G.size(), 0);

    S.emplace_back( root,0,root );

    make_path( root, root, 0 );

    subtree_size.clear();
  }

 public:
  HeavyLightDecomposition(vector<vector<int>>& G_, int root = 0) : G(G_){
    init(root);
  }

  //set_index, element_index
  //S[set_index].element[element_index] == v
  pair<int,int> get_position(int v){
    return {set_index[v], ele_index[v]};
  }
};


int LCA(HeavyLightDecomposition& T, int u, int v){
  auto pu = T.get_position(u);
  auto pv = T.get_position(v);
  if(pu.first == pv.first){
    return pu.second < pv.second ? u : v;
  }

  if(T.S[pu.first].depth > T.S[pv.first].depth){
    swap(pu, pv);
    swap(u,v);
  }

  while(T.S[pu.first].depth != T.S[pv.first].depth){
    v = T.S[pv.first].parent_vertex;
    pv = T.get_position( v );
  }

  while(pu.first != pv.first){
    u = T.S[pu.first].parent_vertex;
    v = T.S[pv.first].parent_vertex;
    pu = T.get_position(u);
    pv = T.get_position(v);
    if(T.S[pv.first].depth == 0) break;
    if(T.S[pv.first].depth == 0) break;
  }

  if(pu.first == pv.first){
    return pu.second < pv.second ? u : v;
  }else{
    abort();
  }
  return -1;
}


void Euler_tour(vector<vector<int>>& G, int pos, int last, vector<int>& res, vector<int>& et_fst){
  et_fst[pos] = res.size();
  res.push_back(pos);
  for(int nx : G[pos]){
    if(nx == last) continue;
    Euler_tour(G, nx, pos, res, et_fst);
  }
  res.push_back(pos);
}

int main(){
  int n, q;
  cin >> n,q;

  vector<int> color(n+n-1, 0);
  vector<int> weight(n+n-1, 0);
  vector<vector<int>> g(n+n-1);
  for(int i=0; i<n-1; i++){
    int u,v,c,d;
    cin >> u,v,c,d;
    u--; v--;
    int ei = i + n;

    color[ei] = c;
    weight[ei] = d;
    g[u].push_back(ei);
    g[v].push_back(ei);

    g[ei].push_back(u);
    g[ei].push_back(v);
  }

  vector<int> et;
  vector<int> et_fst(g.size());
  Euler_tour(g, 0, -1, et, et_fst);
  vector<int> weight_sum(et.size());
  vector<vector<int>> cidx(n);
  vector<vector<int>> weight_sum_color(n);
  vector<vector<int>> cnt_sum_color(n);
  for(int i=0; i<et.size(); i++){
    int v = et[i];
    int c = color[v];
    cidx[c].push_back(i);
    if(i == et_fst[v]){
      weight_sum[i] = weight[v];
      weight_sum_color[c].push_back(weight[v]);
      cnt_sum_color[c].push_back(1);
    }else{
      weight_sum[i] = -weight[v];
      weight_sum_color[c].push_back(-weight[v]);
      cnt_sum_color[c].push_back(-1);
    }
  }
  for(int i=1; i<et.size(); i++){
    weight_sum[i] += weight_sum[i-1];
  }
  for(int c=0; c<n; c++){
    for(int i=1; i<weight_sum_color[c].size(); i++){
      weight_sum_color[c][i] += weight_sum_color[c][i-1];
      cnt_sum_color[c][i] += cnt_sum_color[c][i-1];
    }
  }

  HeavyLightDecomposition hl(g, 0);

  for(int i=0; i<q; i++){
    int x,y, u,v;
    cin >> x,y, u,v;
    u--; v--;
    int p = LCA(hl, u,v);
    int sum_w = 0;
    int sum_c = 0;
    int cnt_c = 0;
    for(int z: {u,v}){
      if(z == p) continue;
      int l = et_fst[p];
      int r = et_fst[z];
      sum_w += weight_sum[r] - weight_sum[l];
      int cl = lower_bound(cidx[x].begin(), cidx[x].end(), l) - cidx[x].begin() - 1;
      int cr = lower_bound(cidx[x].begin(), cidx[x].end(), r) - cidx[x].begin() - 1;
      if(cr >= 0){
        sum_c += weight_sum_color[x][cr];
        cnt_c += cnt_sum_color[x][cr];
      }
      if(cl >= 0){
        sum_c -= weight_sum_color[x][cl];
        cnt_c -= cnt_sum_color[x][cl];
      }
    }
    int ans = sum_w - sum_c + cnt_c * y;
    println(ans);
  }

  return 0;
}


Measured memory_bytes: 72692