Submit solution

Points:
15 (partial)

Time limit:
1.0s

Memory limit:
256M

Author:

Problem type

Allowed languages

Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, ~~CommonLisp~~, D, Dart, F#, Forth, Fortran, Go, ~~Groovy~~, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, ~~Nim~~, ~~ObjC~~, OCaml, ~~Octave~~, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

guards. There are two types of guards, ones with bulletproof armour and ones with fireproof armour. has two weapons, molotov cocktails and shotguns. Unfortunately, pairs of guards are one-way friends with each other, therefore must kill some guards before others. He would like to know the minimum number of times he needs to change weapons while following the order of friendships.

has sneaked into an Amestris military base and is waiting for Fuhrer King Bradley's arrival. But first, he must take care of the#### Input Specification

Line : and ()

Line : integers, either or , representing the type of each guard

Lines : 2 integers and , representing that must be killed before

It is guaranteed that it will be possible to kill all guards. There may be multiple connections between the same pair.

#### Output Specification

Print on the first line the minimum number of times

is required to change his weapon.#### Sample Input

```
6 4
0 1 0 1 1 1
0 1
3 2
1 2
2 5
```

#### Sample Output

`3`

## Comments

This comment is hidden due to too much negative feedback. Click here to view it.