exp

Two sequences of n positive integers, x1, …, xn, and respectively y1, …, yn and a sequence of n numerical operators from group {+, -} s1, …, sn are given.

Task

Determine the maximum value of expression:
s1c1·d1s2c2·d2 … sn-1cn-1·dn-1sncn·dn
where ci is a digit of xi, and di is a digit of yi, for i=1, 2, …, n.

Input Data

Input file exp.in contains on the first line the positive integer n, on the second line operators s1, …, sn, without any space in between, and on each of the following n lines a pair of positive integers in the form of xi yi, i=1, 2, …, n, each separated by a space.

Output Data

Output file exp.out will contain a single line with the maximum value of the expression.

Constraints and Statements

Example
exp.in exp.out Explanation
3
-+-
1834 1230
2001 4205
5827 25311

8

One way to obtain the maximum value of the expression is
-4·0+2·5-2·1 = 8

Time limit: 0.2 seconds/test

prof. Doru Popescu Anastasiu
"Radu Greceanu" Slatina National High School
Contact:dopopan@yahoo.com