Groundhog and Golden Apple
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

Groundhog is the leader of the Apple religion. 

Groundhog intends to spread the Apple Religion in the ZL country. The ZL country consists of    cities.The cities is connected by  undirected roads. Groundhog sent the  follower to the  city, and the followers could go to other cities through roads. 

However, due to cultural differences, the guards on the road numbered  will only allow the followers  numbered from  to  to pass. The leader gave the  follower  Golden Apples,which can be used to bribe the guard to let the follower pass. Now Groundhog wants to know the number of cities each follwer can reach(if there exists one possible path) to spread the Apple Religion, but Groundhog is too busy eating apple, so the problem is left to you. If you solve this problem, maybe you can get an Golden Apple.

输入描述:

The first line contains an integer  , denoting the number of cities.
In the second line, there are integers , as described.
The next  lines each contains four positive integers which means that city and are connected by the road and allows followers numbered from  to  to pass.

输出描述:

output  lines,the  line contains an integer denoting the number of cities  follower can reach.
示例1

输入

复制
5
1 1 1 0 0
1 2 1 1
1 3 3 3
3 4 3 3
4 5 5 5

输出

复制
3
2
5
1
2

说明

In the sample , the 3^{rd} follower can go in route 3\to1\to2 or 3\to 4\to 5, so the answer is {5}.

备注:

.