import std.stdio;

immutable mod = 4294967311L;
long[] inv_;

void main(){
	long x;
	int n, y, op;
	scanf("%d", &n);
	inv_ = new long[1_000_001];
	inv_[1] = 1;
	foreach(i; 2..50) inv_[i]=mul(inv_[mod%i], mod-mod/i)%mod;
	foreach(_; 0..n){
		scanf("%d%d", &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(y));
		x %= mod;
	}

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

	writeln(x);
}

long inv(int x){
	return inv_[x] ? inv_[x] : (inv_[x]=mod-(inv(mod%x)*(mod/x))%mod);
}

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