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(_; 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]=mul(inv_(mod%x), mod-mod/x));
}

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