import std.stdio;

immutable mod = 4294967311L;

void main(){
	long x, y;
	int n, op;
	scanf("%d", &n);
	foreach(i; 0..n){
		scanf("%d%lld", &op, &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(y));
		x %= mod;
	}

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

	writeln(x);
}

long inv(long y){
	long ret = 1;
	for(long e=mod-2; e; e>>=1, y=mul(y,y))if(e&1){
		ret = mul(ret, y);
	}
	return ret;
}

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