use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

type Weight = (i64, i64);
#[allow(dead_code)]
#[derive(Clone, Debug, Eq, PartialEq)]
struct Edge {
    index: usize,
    src: usize,
    dest: usize,
    weight: Weight,
}
#[allow(dead_code)]
impl Edge {
    fn new(index: usize, src: usize, dest: usize, weight: Weight) -> Edge {
        Edge {
            index: index,
            src: src,
            dest: dest,
            weight: weight,
        }
    }
}
impl std::cmp::Ord for Edge {
    fn cmp(&self, other: &Self) -> std::cmp::Ordering {
        (self.weight, self.src, self.dest).cmp(&(other.weight, other.src, other.dest))
    }
}
impl std::cmp::PartialOrd for Edge {
    fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
        Some(self.cmp(other))
    }
}
type Edges = Vec<Edge>;
type Graph = Vec<Edges>;
#[allow(dead_code)]
fn graph_new(n: usize) -> Graph {
    vec![vec![]; n]
}
#[allow(dead_code)]
fn add_bi_edge(graph: &mut Graph, index: &mut usize, src: usize, dest: usize, weight: Weight) {
    graph[src].push(Edge::new(*index, src, dest, weight));
    graph[dest].push(Edge::new(*index, dest, src, weight));
    *index += 1;
}
#[allow(dead_code)]
fn add_uni_edge(graph: &mut Graph, index: &mut usize, src: usize, dest: usize, weight: Weight) {
    graph[src].push(Edge::new(*index, src, dest, weight));
    *index += 1;
}

#[allow(dead_code)]
struct LCA {
    log_size: usize,
    parent: Vec<Vec<usize>>,
    cnts: Vec<Vec<usize>>,
    weights: Vec<Vec<i64>>,
    depth: Vec<usize>,
}
#[allow(dead_code)]
impl LCA {
    fn new(g: &Graph, root: usize, c: i64) -> LCA {
        let n = g.len();
        let mut log_size = 0;
        while (1 << log_size) <= n {
            log_size += 1;
        }
        let mut parent = vec![vec![root; log_size]; n];
        let mut cnts = vec![vec![0; log_size]; n];
        let mut weights = vec![vec![0; log_size]; n];
        let mut depth = vec![0; n];

        let mut que = vec![];
        que.push(root);
        while let Some(node) = que.pop() {
            for edge in g[node].iter() {
                if edge.dest == parent[node][0] {
                    continue;
                }
                parent[edge.dest][0] = node;
                cnts[edge.dest][0] = if c == -1 || c == edge.weight.1 { 1 } else { 0 };
                weights[edge.dest][0] = cnts[edge.dest][0] as i64 * edge.weight.0;
                depth[edge.dest] = depth[node] + 1;
                que.push(edge.dest);
            }
        }

        for iter in 0..log_size - 1 {
            for i in 0..n {
                cnts[i][iter + 1] = cnts[i][iter] + cnts[parent[i][iter]][iter];
                weights[i][iter + 1] = weights[i][iter] + weights[parent[i][iter]][iter];
                parent[i][iter + 1] = parent[parent[i][iter]][iter];
            }
        }
        LCA {
            log_size: log_size,
            parent: parent,
            cnts: cnts,
            weights: weights,
            depth: depth,
        }
    }

    // return (lca, cnt, weight)
    fn lca(&self, mut u: usize, mut v: usize) -> (usize, usize, i64) {
        if self.depth[u] > self.depth[v] {
            std::mem::swap(&mut u, &mut v);
        }
        let mut cnt = 0;
        let mut weight = 0;
        for i in 0..self.log_size {
            if (((self.depth[u] ^ self.depth[v]) >> i) & 1) == 1 {
                cnt += self.cnts[v][i];
                weight += self.weights[v][i];
                v = self.parent[v][i];
            }
        }
        if u == v {
            return (u, cnt, weight);
        }
        for i in (0..self.log_size).rev() {
            if self.parent[u][i] != self.parent[v][i] {
                cnt += self.cnts[u][i];
                cnt += self.cnts[v][i];
                weight += self.weights[u][i];
                weight += self.weights[v][i];
                u = self.parent[u][i];
                v = self.parent[v][i];
            }
        }
        cnt += self.cnts[u][0];
        cnt += self.cnts[v][0];
        weight += self.weights[u][0];
        weight += self.weights[v][0];
        return (self.parent[u][0], cnt, weight);
    }
}

#[derive(Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Debug)]
struct Query {
    color: i64,
    d: i64,
    f: usize,
    t: usize,
    index: usize,
}

impl Query {
    fn new(color: i64, d: i64, f: usize, t: usize, index: usize) -> Query {
        Query {
            color: color,
            d: d,
            f: f,
            t: t,
            index: index,
        }
    }
}

fn main() {
    let n = read::<usize>();
    let q = read::<usize>();
    let mut g = graph_new(n);
    let mut index = 0;
    let mut color_edges = vec![vec![]; n];
    for _i in 0..n - 1 {
        let a = read::<usize>() - 1;
        let b = read::<usize>() - 1;
        let c = read::<i64>() - 1;
        let d = read::<i64>();
        color_edges[c as usize].push(Edge::new(index, a, b, (d, c)));
        add_bi_edge(&mut g, &mut index, a, b, (d, c));
    }
    let mut query_color_cnts = vec![0; n];
    let mut queries = vec![Query::new(0, 0, 0, 0, 0); q];
    for i in 0..q {
        queries[i].color = read::<i64>() - 1;
        queries[i].d = read::<i64>();
        queries[i].f = read::<usize>() - 1;
        queries[i].t = read::<usize>() - 1;
        queries[i].index = i;
        query_color_cnts[queries[i].color as usize] += 1;
    }
    queries.sort_by_key(|query| query.color);
    let mut anss = vec![0; q];
    let base_lca = LCA::new(&g, 0, -1);
    let mut color_lca = LCA::new(&graph_new(1), 0, -1);
    let mut has_color_lca = false;
    let mut prev_color = -1;
    for i in 0..q {
        let color = queries[i].color;
        let d = queries[i].d;
        let f = queries[i].f;
        let t = queries[i].t;
        if prev_color != color {
            prev_color = color;
            if color_edges[color as usize].len() * query_color_cnts[color as usize] > 16 * n {
                color_lca = LCA::new(&g, 0, color);
                has_color_lca = true;
            } else {
                has_color_lca = false;
            }
        }
        let (l, _, mut ans) = base_lca.lca(f, t);
        if has_color_lca {
            let (_, cnt, total_weight) = color_lca.lca(f, t);
            ans += cnt as i64 * d - total_weight;
        } else {
            for e in color_edges[color as usize].iter() {
                let mut from = e.src;
                let mut to = e.dest;
                if base_lca.depth[from] > base_lca.depth[to] {
                    std::mem::swap(&mut from, &mut to);
                };
                if base_lca.depth[to] <= base_lca.depth[l] {
                    continue;
                }
                if base_lca.lca(to, f).0 == to || base_lca.lca(to, t).0 == to {
                    // hit
                    ans += d - e.weight.0;
                }
            }
        }
        anss[queries[i].index] = ans;
    }
    for i in 0..q {
        println!("{}", anss[i]);
    }
}


Measured memory_bytes: 231536