This page is still under construction.

Parts of this page are still being built. What you see may change.

City Development

Time limit3sMemory limit512 MB

Level

Not classified yet

Solved
No attempts yet

Problem

The city of Baytsburg has a historical part and a new part. The historical part is a tree of nn squares connected by n−1n-1 avenues. The squares are numbered consecutively from 1 to nn. The main square of the city, vertex 1, is the root of the tree.

At the start, the city consists only of the historical part. Each year the city develops as follows. Let mm be the number of squares at the start of the year.

  • Choose a square ff in the historical part and a square tt among those already built (in the historical part or in the new part).
  • The subtree TT of the historical part rooted at ff is copied entirely into the new part, then the root of the copied subtree is connected by an avenue to square tt. All built objects (squares and avenues) belong to the new part. The historical part stays unchanged.
  • Let TT consist of kk squares. The new squares get numbers from m+1m+1 to m+km+k. If square ii has a smaller number than square jj in TT, then the square i′i' corresponding to ii has a smaller number than the square j′j' corresponding to jj.

You are given the configuration of the historical part and the development data for yy years. Answer queries that ask for the shortest distance between two squares.

Input

The first line contains three integers nn, yy and qq: the number of squares in the historical part, the number of years the new part was built, and the number of queries (1≤n,y,q≤1051 \le n,y,q \le 10^5).

Each of the next n−1n-1 lines contains two integers aa and bb, the numbers of two squares in the historical part connected by an avenue (1≤a,b≤n1 \le a,b \le n; a≠ba \ne b). It is guaranteed that the squares and avenues form a tree. The main square, the root of the tree, has number 1.

Each of the next yy lines contains two integers ff and tt: the number of the source square in the historical part and the number of the square to which the copy is attached (1≤f≤n1 \le f \le n; t≥1t \ge 1, and tt does not exceed the number of squares at the start of the corresponding year).

Each of the next qq lines contains two integers ii and jj, the numbers of the squares whose distance must be found. Let MM be the total number of squares after yy years of construction. Then 1≤i,j≤M1 \le i,j \le M.

Output

For each query, print one integer: the shortest distance between the corresponding squares.

Examples1

  1. Example 1

    Input
    5 2 4
    1 3
    1 4
    3 2
    3 5
    3 4
    4 2
    5 9
    1 8
    6 3
    4 7
    
    Expected output
    3
    3
    4
    1