#D4828. Four Arithmetic Operations

    ID: 4013 Type: Default 1000ms 134MiB

Four Arithmetic Operations

Four Arithmetic Operations

Problem statement

There is a rational number sequence X0,X1,X2,...,XN X_0, X_1, X_2, ..., X_N . Each term is defined as follows.

  1. X0=0 X_0 = 0
  2. Xi=Xi1 X_i = X_ {i-1} opi op_i Yi Y_i (1 leqi leqN 1 \ leq i \ leq N ). However, opi op_i is + + , , × × , ÷ ÷ Either.

Find XN X_N .

Constraint

  • 1 leqN leq105 1 \ leq N \ leq 10 ^ 5
  • 1 leqoi leq4 1 \ leq o_i \ leq 4
  • 106 leqYi leq106 -10 ^ 6 \ leq Y_i \ leq 10 ^ 6
  • If oi=4 o_i = 4 , then Yi neq0 Y_i \ neq 0
  • XN X_N is an integer greater than or equal to 231 -2 ^ {31} and less than 231 2 ^ {31} .

input

Input follows the following format. All given numbers are integers.

N N o1 o_1 Y1 Y_1 o2 o_2 Y2 Y_2 ... ... oN o_N YN Y_N

When oi=1 o_i = 1 , opi op_i is +, when oi=2 o_i = 2 , opi op_i is −, when oi=3 o_i = 3 , opi op_i is ×, and when oi=4 o_i = 4 , opi op_i is ÷.

output

Print the value of XN X_N on one line.

Example

Input

4 1 1 4 2 2 4 3 4

Output

-14

inputFormat

input

Input follows the following format. All given numbers are integers.

N N o1 o_1 Y1 Y_1 o2 o_2 Y2 Y_2 ... ... oN o_N YN Y_N

When oi=1 o_i = 1 , opi op_i is +, when oi=2 o_i = 2 , opi op_i is −, when oi=3 o_i = 3 , opi op_i is ×, and when oi=4 o_i = 4 , opi op_i is ÷.

outputFormat

output

Print the value of XN X_N on one line.

Example

Input

4 1 1 4 2 2 4 3 4

Output

-14

样例

4
1 1
4 2
2 4
3 4
-14