Suceava city consists of neighborhoods, indexed from to , connected by bidirectional streets. It is widely recognized that you can travel between any two neighborhoods by using one or more streets.
Suceava is home to gangs, all of which are in conflict and indexed from to . Initially, each street is occupied by a gang.
Over the course of days, some gang may conquer a street occupied by another gang.
We define the insecurity level of a gang as the maximum number of streets you can traverse that are occupied by the gang, while ensuring each street is traversed only once.
Being given queries , you need to determine the insecurity level of gang on day .
Input
The first line contains two integers (, the number of neighborhoods and the number of gangs. The next lines contain three integers (the street connecting neighborhoods and , occupied by clan .
The following line contains integer (, the number of days. The next lines contains three integers (the street connecting neighborhoods and that is being conquered by gang .
The following line contains integer (, the number of queries. The next lines contains two integers (describing the query.
Output
For each query print the answer on a single line.
Example 1
stdin
6 3
4 3 2
1 2 1
3 2 2
5 2 1
2 6 1
4
6 2 2
2 5 2
2 3 1
6 2 1
4
2 3
1 2
1 4
3 2
stdout
2
1
2
0
Example 2
stdin
8 3
1 2 2
1 3 1
1 4 1
2 5 2
4 6 1
6 7 3
6 8 1
5
1 4 3
1 2 3
1 3 2
4 6 3
1 2 2
6
1 1
2 1
2 2
3 3
3 4
2 5
stdout
2
2
1
2
4
3