You are given an unweighted tree with N$N$ nodes (numbered 1$1$ through N$N$). Let's denote the distance between any two nodes p$p$ and q$q$ by d(p,q)$d(p, q)$.
You should answer Q$Q$ queries. In each query, you are given parameters a$a$, da$d_a$, b$b$, db$d_b$, and you should find a node x$x$ such that d(x,a)=da$d(x, a) = d_a$ and d(x,b)=db$d(x, b) = d_b$, or determine that there is no such node.

-----Input-----
- The first line of the input contains a single integer T$T$ denoting the number of test cases. The description of T$T$ test cases follows.
- The first line of each test case contains two space-separated integers N$N$ and Q$Q$.
- Each of the next N−1$N-1$ lines contains two space-separated integers u$u$ and v$v$ denoting that nodes u$u$ and v$v$ are connected by an edge.
- Each of the next Q$Q$ lines contains four space-separated integers a$a$, da$d_a$, b$b$ and db$d_b$ describing a query.

-----Output-----
For each query, print a single line containing one integer ― the number of a node satisfying the given requirements, or −1$-1$ if no such node exists.
If there are multiple solutions, you may output any one.

-----Constraints-----
- 1≤T≤1,000$1 \le T \le 1,000$
- 1≤N,Q≤106$1 \le N, Q \le 10^6$
- 1≤u,v≤N$1 \le u, v \le N$
- the graph on the input is a tree
- 1≤a,b≤N$1 \le a, b \le N$
- 1≤da,db<N$1 \le d_a, d_b < N$
- the sum of N$N$ over all test cases does not exceed 106$10^6$
- the sum of Q$Q$ over all test cases does not exceed 106$10^6$

-----Subtasks-----
Subtask #1 (50 points):
- 1≤N,Q≤1,000$1 \le N, Q \le 1,000$
- the sum of N$N$ over all test cases does not exceed 1,000$1,000$
- the sum of Q$Q$ over all test cases does not exceed 1,000$1,000$
Subtask #2 (50 points): original constraints

-----Example Input-----
1
5 3
1 2
2 3
3 4
3 5
2 1 4 1
2 2 4 2
1 1 2 1

-----Example Output-----
3
5
-1

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

ns = {"__name__": "__main__"}
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = "class TestCase:\r\n    def __init__(self):\r\n        [self.node_count, self.query_count] = read_line()\r\n        \r\n    def fill_nodes(self):\r\n        self.nodes = {n+1: [] for n in range(self.node_count)}\r\n        for i in range(self.node_count -1):\r\n            new_node_1, new_node_2 = read_line()\r\n            self.nodes[new_node_1].append(new_node_2)\r\n            self.nodes[new_node_2].append(new_node_1)\r\n            \r\n    def resolve_query(self, query):\r\n        a, d_a, b, d_b = query\r\n        suiting_a = self.find_nodes_with_distance(a, d_a)\r\n        suiting_b = self.find_nodes_with_distance(b, d_b)\r\n        fitting = [node for node in suiting_a if node in suiting_b]\r\n        \r\n        if len(fitting) == 0:\r\n            return -1\r\n        else:\r\n            return fitting[0]\r\n        \r\n    def find_nodes_with_distance(self, start_node, distance):\r\n        from_nodes = {start_node}\r\n        passed_nodes = from_nodes\r\n        \r\n        for i in range(distance):\r\n            to_nodes = set()\r\n            # add all adjacent nodes\r\n            for node in from_nodes:\r\n                to_nodes.update(self.nodes[node])\r\n            \r\n            # no backtracking\r\n            for node in passed_nodes:\r\n                if node in to_nodes:\r\n                    to_nodes.remove(node)\r\n            \r\n            # update which nodes are passed\r\n            passed_nodes.update(to_nodes)\r\n            # go another round with the new nodes found\r\n            from_nodes = to_nodes\r\n        return list(from_nodes)\r\n\r\ndef read_line():\r\n    line = input()\r\n    return [int(s) for s in line.split(' ')]\r\n\r\nnum_testcases = int(input())\r\nfor i in range(num_testcases):\r\n    testcase = TestCase()\r\n    testcase.fill_nodes()\r\n    for q in range(testcase.query_count):\r\n        query = read_line()\r\n        print(testcase.resolve_query(query))"
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 16353