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

```

Measured memory_bytes: 16353