import std.stdio, std.bigint;

void main(){
	BigInt x = "0", mod = "4294967311";
	int n, op, y;
	scanf("%d", &n);
	foreach(i; 0..n){
		scanf("%d%d", &op, &y);
		if(op == 1) x += y;
		else if(op == 2) x -= y;
		else if(op == 3) x *= y;
		else if(op == 4) x *= inv(BigInt(y), mod);
		x %= mod;
	}

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

	writeln(x);
}

BigInt inv(BigInt y, BigInt mod){
	BigInt ret = "1";
	for(long e=mod.toLong-2; e; e>>=1, y=y*y%mod)if(e&1){
		ret = ret * y % mod;
	}
	return ret;
}