#K7991. Calculate Final Difficulty

    ID: 35413 Type: Default 1000ms 256MiB

Calculate Final Difficulty

Calculate Final Difficulty

You are given a series of stages to update a game level's difficulty. Initially, the difficulty is set to \(1\). For each stage:

  • If the stage type is \(1\), add the given value to the current difficulty.
  • If the stage type is \(2\), multiply the current difficulty by the given value.

Your task is to compute the final difficulty after applying all stages in order.

Note: All operations are applied sequentially starting from the initial difficulty of \(1\).

inputFormat

The input is provided via standard input (stdin) and consists of the following:

  • The first integer \(n\) represents the number of stages.
  • Followed by \(2n\) integers. Each stage is described by a pair of integers: the first integer is the stage type (either \(1\) for addition or \(2\) for multiplication), and the second integer is the value associated with the operation.

For example, an input of 3 1 3 2 2 1 5 corresponds to 3 stages: add 3, multiply by 2, and add 5.

outputFormat

Output a single integer representing the final difficulty after applying all the stages. The result should be printed to standard output (stdout).

## sample
1 1 3
4