PROGRAMMING:Buy a pencil
The teacher needs to go to the store to buy n pencils as gifts for the children. She found that there are three kinds of pencils in the store. The number of pencils in different packages may be different, and the price may also be different. To be fair, the teacher decided to buy only pencils in the same package.
The store does not allow the pencil to be unpacked, so the teacher may need to buy more than n pencils to send gifts to the children.
Now the teacher wants to know how much it costs to buy at least n pencils when the number of each package in the store is enough.
###Input format:
The first line contains a positive integer n, indicating the number of pencils required.
In the next three lines, each line uses two positive integers to describe a kind of pencil package: the first integer represents the number of pencils in the package, and the second integer represents the price of the package.
Ensure that all 7 numbers are positive integers with a maximum of 10000.
###Output format:
1 integer, indicating the minimum cost of the teacher.
###Input sample 1:
```in
fifty-seven
2 2
50 30
30 27
```
###Output sample 1:
```out
fifty-four
```
###Input sample 2:
```in
nine thousand nine hundred and ninety-eight
128 233
128 2333
128 666
```
###Output sample 2:
```out
eighteen thousand four hundred and seven
```
###Input sample 3:
```in
nine thousand nine hundred and ninety-nine
101 1111
1 9999
1111 9999
```
###Output sample 3:
```out
eighty-nine thousand nine hundred and ninety-one
```
answer:If there is no answer, please comment
The store does not allow the pencil to be unpacked, so the teacher may need to buy more than n pencils to send gifts to the children.
Now the teacher wants to know how much it costs to buy at least n pencils when the number of each package in the store is enough.
###Input format:
The first line contains a positive integer n, indicating the number of pencils required.
In the next three lines, each line uses two positive integers to describe a kind of pencil package: the first integer represents the number of pencils in the package, and the second integer represents the price of the package.
Ensure that all 7 numbers are positive integers with a maximum of 10000.
###Output format:
1 integer, indicating the minimum cost of the teacher.
###Input sample 1:
```in
fifty-seven
2 2
50 30
30 27
```
###Output sample 1:
```out
fifty-four
```
###Input sample 2:
```in
nine thousand nine hundred and ninety-eight
128 233
128 2333
128 666
```
###Output sample 2:
```out
eighteen thousand four hundred and seven
```
###Input sample 3:
```in
nine thousand nine hundred and ninety-nine
101 1111
1 9999
1111 9999
```
###Output sample 3:
```out
eighty-nine thousand nine hundred and ninety-one
```
answer:If there is no answer, please comment