Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ACM-ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

G. New Year Running

time limit per test

4 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard outputNew Year is coming in Tree Island! In this island, as the name implies, there are *n* cities connected by *n* - 1 roads, and for any two distinct cities there always exists exactly one path between them. For every person in Tree Island, it takes exactly one minute to pass by exactly one road.

There is a weird New Year tradition for runnners in Tree Island, which is called "extreme run". This tradition can be done as follows.

A runner chooses two distinct cities *a* and *b*. For simplicity, let's denote the shortest path from city *a* to city *b* as *p*_{1}, *p*_{2}, ..., *p*_{l} (here, *p*_{1} = *a* and *p*_{l} = *b* holds). Then following happens:

- The runner starts at city
*a*. - The runner runs from city
*a*to*b*, following the shortest path from city*a*to city*b*. - When the runner arrives at city
*b*, he turns his direction immediately (it takes no time), and runs towards city*a*, following the shortest path from city*b*to city*a*. - When the runner arrives at city
*a*, he turns his direction immediately (it takes no time), and runs towards city*b*, following the shortest path from city*a*to city*b*. - Repeat step 3 and step 4 forever.

In short, the course of the runner can be denoted as:

Two runners JH and JY decided to run "extremely" in order to celebrate the New Year. JH has chosen two cities *u* and *v*, and JY has chosen two cities *x* and *y*. They decided to start running at the same moment, and run until they meet at the same city for the first time. Meeting on a road doesn't matter for them. Before running, they want to know the amount of time they will run.

It is too hard for JH and JY to calculate this, so they ask you for help.

Input

The first line contains a single positive integer *n* (5 ≤ *n* ≤ 2 × 10^{5}) — the number of cities in Tree Island.

Next *n* - 1 lines describe the roads of Tree Island. The *i*-th line (1 ≤ *i* ≤ *n* - 1) of them contains two space-separated integers *a*_{i} and *b*_{i} (1 ≤ *a*_{i}, *b*_{i} ≤ *n*, *a*_{i} ≠ *b*_{i}) — the vertices connected by a single road of the tree.

The next line contains an integer *t* (1 ≤ *t* ≤ 2 × 10^{5}) — the number of test cases.

Next *t* lines describes the test cases. The *j*-th line (1 ≤ *j* ≤ *t*) of them contains four space-separated integers *u*_{j}, *v*_{j}, *x*_{j}, *y*_{j} (1 ≤ *u*_{j}, *v*_{j}, *x*_{j}, *y*_{j} ≤ *n*, *u*_{j} ≠ *v*_{j}, *x*_{j} ≠ *y*_{j}). It means that in this test case, JH has chosen two cities *u*_{j} and *v*_{j}, JY has chosen two cities *x*_{j} and *y*_{j}. JH starts running at city *u*_{j}, and JY starts running at city *x*_{j}.

Output

For each test case, print an integer describing the amount of time they should run in minutes. If they have to run for an infinitely long time (in other words, if they never meet at the same city), print -1 instead. If they meet at the beginning of their run, print 0.

Examples

Input

7

1 3

3 6

7 4

3 7

5 4

7 2

4

6 5 5 3

3 5 4 6

1 5 1 3

1 5 3 1

Output

2

1

0

-1

Note

The example looks like:

Codeforces (c) Copyright 2010-2017 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: May/25/2017 00:24:02 (c3).

Desktop version, switch to mobile version.
User lists

Name |
---|