import std.stdio;

immutable mod = 4294967311L;

void main(){
	long x, y;
	int n, op;
	scanf("%d", &n);
	long[] inv = new long[1000_001];
	inv[1] = 1;
	foreach(i; 2..inv.length){
		inv[i] = mul(inv[mod%i], mod - mod/i);
	}
	foreach(_; 0..n){
		scanf("%d%lld", &op, &y);
		if(op >= 3 && y < 0) x = -x, y = -y;
		if(op == 1) x += y;
		else if(op == 2) x -= y;
		else if(op == 3) x *= y;
		else if(op == 4) x = mul(x, inv[cast(int)y]);
		x %= mod;
	}

	if(x < 0) x += mod;
	if(x > int.max) x -= mod;

	writeln(x);
}

long mul(long x, long y){
	return ( ((x*(y>>16)%mod)<<16) + (x*(y&0xffff)) ) % mod;
}