##### Canadian Computing Competition: 2010 Stage 2, Day 1, Problem 1

You live in a neighbourhood of dogs. Dogs like dogs. Dogs like barking even better. But best of all, dogs like barking when other dogs bark.

Each dog has a collection of dogs that can hear him/her. Each dog has a delay time in barking if they hear another dog bark.

Dog 1 always starts barking first, and this first bark occurs during second number .

Your job is to figure out how many times each dog has barked in the first seconds (inclusive). You can assume that sound travels instantly from the mouth of one dog into the ear of another.

Each dog spends any given second doing one of three things: sleeping, waiting, or barking. If dog hears a bark during a second when it is sleeping, the dog wakes up and waits during seconds through inclusive, barks during second , then goes back to sleep from second onward. If a dog hears a bark during a second in which it is waiting or barking, it ignores the bark.

During second number , all the dogs except Dog are sleeping.

#### Input Specification

The first line of input is , the number of dogs in the neighbourhood.

The next lines of each contain an integer representing the time (in seconds) that dog waits before considering to bark upon hearing a bark.

The next line contains the number . On each of the next lines, there are two integers: and , representing that when dog barks, dog hears this bark. It is never the case that .

The next line (which is the last line of input) contains the integer , the number of seconds during which your program is to monitor the dogs.

#### Output Specification

Produce one line of output for each dog in order from dog to dog . On line , output the number of seconds between and inclusive that dog spent barking.

#### Sample Input 1

```
3
1
1
3
3
1 2
2 3
3 1
10
```

#### Sample Output 1

```
3
2
2
```

#### Sample Input 2

```
3
3
1
3
3
1 2
2 3
3 1
10
```

#### Sample Output 2

```
2
2
1
```

## Comments

I'm not sure I understand sample input 1. This is what I get:

Dog 1 barks at second 0

Between seconds 1 to 10:

I agree, the output specification should say the number of seconds between and inclusive that dog spent barking.