#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>


using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CLEAR(arr, val) memset(arr, val, sizeof(arr))

#define rep(i, n) for (int i = 0; i < n; ++i)

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

typedef long long ll;
typedef pair<int, int> pint;

const double EPS = 1e-8;
const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };
bool valid_pos(int x, int y, int w, int h) { return 0 <= x && x < w && 0 <= y && y < h; }


ll mod_mul(ll x, ll n, ll mod)
{
	if (n == 0)
		return 0;
	if (x < 0)
		x = (x + mod) % mod;
	if (n < 0)
		n = (n + mod) % mod;
	if ((double)x * n + 1000 < LLONG_MAX)
		return (x * n) % mod;

	ll res = 0;
	while (n > 0)
	{
		if (n & 1)
			res = (res + x) % mod;
		x = x * 2 % mod;
		n /= 2;
	}

	return res;
}
ll ext_gcd(ll a, ll b, ll &x, ll &y)
{
	if (b)
	{
		ll g = ext_gcd(b, a % b, y, x);
		y -= (a / b) * x;
		return g;
	}
	else
	{
		x = 1, y = 0;
		return a;
	}
}
ll mod_inverse(ll a, ll mod)
{
	ll x, y;
	if (ext_gcd((a + mod) % mod, mod, x, y) == 1)
		return (mod + x % mod) % mod;
	else
		return 0;
}
int main()
{
	ios::sync_with_stdio(false);

	const ll mod = 9999999967LL;

	int n;
	cin >> n;
	ll x = 0;
	while (n--)
	{
		int o, y;
		cin >> o >> y;
		if (o == 1)
			x += y;
		else if (o == 2)
			x -= y;
		else if (o == 3)
			x = mod_mul(x, y, mod);
		else
			x = mod_mul(x, mod_inverse(y, mod), mod);

		x = (x + mod) % mod;
	}
	if (x >= 1LL << 31)
		x -= mod;
	cout << x << endl;
}
### Prompt

Please create a solution in Cpp to the following problem:

Problem statement

There is a rational number sequence $ X_0, X_1, X_2, ..., X_N $. Each term is defined as follows.


1. $ X_0 = 0 $
2. $ X_i = X_ {i-1} $ $ op_i $ $ Y_i $ ($ 1 \ leq i \ leq N $). However, $ op_i $ is $ + $, $ − $, $ × $, $ ÷ $ Either.



Find $ X_N $.

Constraint

* $ 1 \ leq N \ leq 10 ^ 5 $
* $ 1 \ leq o_i \ leq 4 $
* $ -10 ^ 6 \ leq Y_i \ leq 10 ^ 6 $
* If $ o_i = 4 $, then $ Y_i \ neq 0 $
* $ X_N $ is an integer greater than or equal to $ -2 ^ {31} $ and less than $ 2 ^ {31} $.



input

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


$ N $
$ o_1 $ $ Y_1 $
$ o_2 $ $ Y_2 $
$ ... $
$ o_N $ $ Y_N $

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

output

Print the value of $ X_N $ on one line.

Example

Input

4
1 1
4 2
2 4
3 4


Output

-14

### Response

```cpp
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>


using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CLEAR(arr, val) memset(arr, val, sizeof(arr))

#define rep(i, n) for (int i = 0; i < n; ++i)

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

typedef long long ll;
typedef pair<int, int> pint;

const double EPS = 1e-8;
const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };
bool valid_pos(int x, int y, int w, int h) { return 0 <= x && x < w && 0 <= y && y < h; }


ll mod_mul(ll x, ll n, ll mod)
{
	if (n == 0)
		return 0;
	if (x < 0)
		x = (x + mod) % mod;
	if (n < 0)
		n = (n + mod) % mod;
	if ((double)x * n + 1000 < LLONG_MAX)
		return (x * n) % mod;

	ll res = 0;
	while (n > 0)
	{
		if (n & 1)
			res = (res + x) % mod;
		x = x * 2 % mod;
		n /= 2;
	}

	return res;
}
ll ext_gcd(ll a, ll b, ll &x, ll &y)
{
	if (b)
	{
		ll g = ext_gcd(b, a % b, y, x);
		y -= (a / b) * x;
		return g;
	}
	else
	{
		x = 1, y = 0;
		return a;
	}
}
ll mod_inverse(ll a, ll mod)
{
	ll x, y;
	if (ext_gcd((a + mod) % mod, mod, x, y) == 1)
		return (mod + x % mod) % mod;
	else
		return 0;
}
int main()
{
	ios::sync_with_stdio(false);

	const ll mod = 9999999967LL;

	int n;
	cin >> n;
	ll x = 0;
	while (n--)
	{
		int o, y;
		cin >> o >> y;
		if (o == 1)
			x += y;
		else if (o == 2)
			x -= y;
		else if (o == 3)
			x = mod_mul(x, y, mod);
		else
			x = mod_mul(x, mod_inverse(y, mod), mod);

		x = (x + mod) % mod;
	}
	if (x >= 1LL << 31)
		x -= mod;
	cout << x << endl;
}
```