Niebieskie ksi.eczki
III Olympiad in Informatics 1995/1996

Task: MOK
Author: Piotr Chrz±stowski-Wachtel
Containers

I stage contest  

We are given n containers, where 1 <= n <= 4. At the beginning all of them are full of water. The liter capacity of the i-th container is a natural number oi satisfying inequalities 1 <= oi <= 49. 
Three kinds of moves can be made:  

  1. Pouring the whole content of one container into another. This move can be made unless there is too little room in the second container. 
  2. Filling up one container with part of the water from another one
  3. Pouring away the whole content of one container into a drain. 

Task

Write a program that:

Input

In the first line of the text file MOK.IN one positive integer n is written, n <= 4, this is the number of containers. There are n positive integers written in the second line. These are the capacities of the containers (the i-th integer oi denotes the capacity if the i-th  container,1 <= oi <= 49). In the third line of the input file there are written n numbers. These are the requested final volumes of water in the containers (the i-th integer wi denotes the requested final volume of water in the i-th container, 1 <= wi <= oi). All integers in the second and the third line are separated by single spaces.

Output

If it is not possible to result in requested final situation making only allowed moves, your program should write only one word "NIE" ("no" in Polish ) into the text file MOK.OUT, otherwise only one integer equal to the minimal number of moves which lead to the requested final situation should be written.

Example

For the input file MOK.IN:
3
3 5 5
0 0 4

the correct solution is the following file MOK.OUT:
6

For the input file MOK.IN:
2
20 25
10 16

the correct solution is the following file MOK.OUT:
NIE

Your program should look for the file MOK.IN in the current directory and produce the output file MOK.OUT in the current directory too. The file containing the source code of your program should have a name MOK.???, whereas you should put three-letter abbreviation of the used programming language name instead of ???. The same program in executable form should be written in file MOK.EXE