Bessie and the cows are playing with sequences and need your help. They start with a sequence, initially containing just the number 0, and perform n operations. Each operation is one of the following:  Add the integer x_{i} to the first a_{i} elements of the sequence.  Append an integer k_{i} to the end of the sequence. (And hence the size of the sequence increases by 1)  Remove the last element of the sequence. So, the size of the sequence decreases by one. Note, that this operation can only be done if there are at least two elements in the sequence. 

After each operation, the cows would like to know the average of all the numbers in the sequence. Help them!


-----Input-----

The first line contains a single integer n (1 ≤ n ≤ 2·10^5) — the number of operations. The next n lines describe the operations. Each line will start with an integer t_{i} (1 ≤ t_{i} ≤ 3), denoting the type of the operation (see above). If t_{i} = 1, it will be followed by two integers a_{i}, x_{i} (|x_{i}| ≤ 10^3; 1 ≤ a_{i}). If t_{i} = 2, it will be followed by a single integer k_{i} (|k_{i}| ≤ 10^3). If t_{i} = 3, it will not be followed by anything.

It is guaranteed that all operations are correct (don't touch nonexistent elements) and that there will always be at least one element in the sequence.


-----Output-----

Output n lines each containing the average of the numbers in the sequence after the corresponding operation.

The answer will be considered correct if its absolute or relative error doesn't exceed 10^{ - 6}.


-----Examples-----
Input
5
2 1
3
2 3
2 1
3

Output
0.500000
0.000000
1.500000
1.333333
1.500000

Input
6
2 1
1 2 20
2 2
1 2 -3
3
3

Output
0.500000
20.500000
14.333333
12.333333
17.500000
17.000000



-----Note-----

In the second sample, the sequence becomes $\{0 \} \rightarrow \{0,1 \} \rightarrow \{20,21 \} \rightarrow \{20,21,2 \} \rightarrow \{17,18,2 \} \rightarrow \{17,18 \} \rightarrow \{17 \}$

Difficulty: competition

Starter code:

Solutions:
n = int(input())
a, b = [0] * (n + 2), [0] * (n + 2)
s, l = 0, 1
p = [0] * n
for i in range(n):
    t = list(map(int, input().split()))
    if t[0] == 1:
        b[t[1] - 1] += t[2]
        s += t[1] * t[2]
    elif t[0] == 2:
        a[l] = t[1]
        l += 1
        s += t[1]
    else:
        l -= 1
        s -= a[l] + b[l]
        b[l - 1] += b[l]
        b[l] = 0
    p[i] = str(s / l)
print('\n'.join(p))

n = int(input())
a, b = [0] * (n + 2), [0] * (n + 2)
s, l = 0, 1
p = [0] * n
for i in range(n):
    t = list(map(int, input().split()))
    if t[0] == 1:
        b[t[1] - 1] += t[2]
        s += t[1] * t[2]
    elif t[0] == 2:
        a[l] = t[1]
        l += 1
        s += t[1]
    else:
        l -= 1
        s -= a[l] + b[l]
        b[l - 1] += b[l]
        b[l] = 0
    p[i] = str(s / l)
print('\n'.join(p))

from sys import stdin
input = stdin.readline
n = int(input())
val = [0] * (n + 1)
add = [0] * (n + 1)
ptr = 1
sum = 0
res = [0] * n
for i in range(n):
	l = [int(x) for x in input().split()]
	if l[0] == 1:
		a, x = l[1:]
		add[a - 1] += x
		sum += a * x
	elif l[0] == 2:
		k = l[1]
		val[ptr] = k
		sum += k
		ptr += 1
	else:
		ptr -= 1
		sum -= val[ptr]
		sum -= add[ptr]
		add[ptr - 1] += add[ptr]
		add[ptr] = 0
	res[i] = sum / ptr
print('\n'.join(str(x) for x in res))


def main():
    l, base, res, le, tot = [0] * 200001, [0] * 200001, [], 1, 0
    for _ in range(int(input())):
        s = input()
        c = s[0]
        if c == '1':
            a, x = list(map(int, s[2:].split()))
            base[a] += x
            tot += a * x
        elif c == '2':
            l[le] = x = int(s[2:])
            tot += x
            le += 1
        else:
            x = base[le]
            base[le] = 0
            tot -= x
            le -= 1
            base[le] += x
            tot -= l[le]
        res.append(tot / le)
    print('\n'.join(map(str, res)))


def __starting_point():
    main()

__starting_point()

def main():
    l, base, res, le, tot = [0] * 200001, [0] * 200001, [], 1, 0
    for _ in range(int(input())):
        s = input()
        c = s[0]
        if c == '1':
            a, x = list(map(int, s[2:].split()))
            base[a] += x
            tot += a * x
        elif c == '2':
            l[le] = x = int(s[2:])
            tot += x
            le += 1
        else:
            x = base[le]
            if x:
                base[le] = 0
                tot -= x
                le -= 1
                base[le] += x
            else:
                le -= 1
            tot -= l[le]

        res.append(tot / le)
    print('\n'.join(map(str, res)))


def __starting_point():
    main()

__starting_point()

def main():
    n, res, le, tot = int(input()), [], 1, 0
    l, base = [0] * (n + 2), [0] * (n + 2)
    for _ in range(n):
        s = input()
        c = s[0]
        if c == '1':
            a, x = list(map(int, s[2:].split()))
            base[a] += x
            tot += a * x
        elif c == '2':
            l[le] = x = int(s[2:])
            tot += x
            le += 1
        else:
            x = base[le]
            if x:
                base[le] = 0
                tot -= x
                le -= 1
                base[le] += x
            else:
                le -= 1
            tot -= l[le]

        res.append(tot / le)
    print('\n'.join(map(str, res)))


def __starting_point():
    main()

__starting_point()

n = int(input())
a, b = [0] * (n + 2), [0] * (n + 2)
s, l = 0, 1
p = [0] * n
for i in range(n):
    t = list(map(int, input().split()))
    if t[0] == 1:
        b[t[1] - 1] += t[2]
        s += t[1] * t[2]
    elif t[0] == 2:
        a[l] = t[1]
        l += 1
        s += t[1]
    else:
        l -= 1
        s -= a[l] + b[l]
        b[l - 1] += b[l]
        b[l] = 0
    p[i] = str(s / l)
print('\n'.join(p))

import math
n = int(input())
d = [0]*200200
a = [0]
s = 0

ans = []
for i in range(n):
    x = tuple(map(int, input().split()))
    if x[0] == 1:
        d[x[1]] += x[2]
        s += x[1] * x[2]
    elif x[0] == 2:
        a.append(x[1])
        s += x[1]
    else:
        cc = len(a)
        s -= d[cc] + a.pop()
        d[cc-1] += d[cc]
        d[cc] = 0
    ans.append(str(s / len(a)))

print('\n'.join(ans))

n = int(input())

a, b = [0] * (n + 2), [0] * (n + 2)

s, l = 0, 1

p = [0] * n

for i in range(n):

    t = list(map(int, input().split()))

    if t[0] == 1:

        b[t[1] - 1] += t[2]

        s += t[1] * t[2]

    elif t[0] == 2:

        a[l] = t[1]

        l += 1

        s += t[1]

    else:

        l -= 1

        s -= a[l] + b[l]

        b[l - 1] += b[l]

        b[l] = 0

    p[i] = str(s / l)

print('\n'.join(p))

s = 0
ele =  1
n = int(input())
l =[0] *(n+2)
a =[0] *(n+2)
ans =[0]* n;
for x in range(n):
    inp = list(map(int,input().strip().split()))
    if inp[0] == 1:
        s += inp[1] * inp[2];
        a[inp[1] - 1] += inp[2]
    elif inp[0] == 2:
        s += inp[1]
        l[ele] = inp[1]
        ele += 1;
    else:
        ele -= 1
        s -= l[ele] + a[ele]
        a[ele -1 ] += a[ele]
        a[ele] = 0
    ans[x] =str( s / ele)
print("\n".join(ans))


'''input
5
2 1
3
2 3
2 1
3
'''

from sys import stdin, setrecursionlimit

setrecursionlimit(15000)


# main starts
n = int(stdin.readline().strip())
arr = [0]
cur_sum = 0
aux = [0]
for _ in range(n):
	op = list(map(int, stdin.readline().split()))
	
	# processing operations
	if op[0] == 1:
		aux[op[1] - 1] += op[2]
		cur_sum += op[1] * op[2]

	elif op[0] == 2:
		aux.append(0)
		arr.append(op[1])
		cur_sum += op[1]		
	else:
		cur_sum -= (arr[-1] + aux[-1])
		aux[-2] += aux[-1]
		aux.pop()
		arr.pop()
	print(cur_sum / len(arr))

import sys


d, ans = [0], []
s = 0

for _ in range(int(next(sys.stdin))):
    cmd = tuple(map(int, next(sys.stdin).split()))
    if cmd[0] == 1:
        s += cmd[1] * cmd[2]
        if cmd[1] == len(d):
            d[-1] += cmd[2]
        else:
            d[cmd[1] - 1] -= cmd[2]
    elif cmd[0] == 2:
        s += cmd[1]
        d.append(cmd[1])
        d[-2] = d[-1] - d[-2]
    else:
        s -= d[-1]
        d[-2] = d[-1] - d[-2]
        d.pop()

    # print(cmd, len(d), '-->', d)
    ans.append(str(s / len(d)))

print('\n'.join(ans))


# Target - Expert on CF
# Be Humblefool

import sys

inf = float("inf")
# sys.setrecursionlimit(1000000)

# abc='abcdefghijklmnopqrstuvwxyz'
# abd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod, MOD = 1000000007, 998244353
# words = {1:'one',2:'two',3:'three',4:'four',5:'five',6:'six',7:'seven',8:'eight',9:'nine',10:'ten',11:'eleven',12:'twelve',13:'thirteen',14:'fourteen',15:'quarter',16:'sixteen',17:'seventeen',18:'eighteen',19:'nineteen',20:'twenty',21:'twenty one',22:'twenty two',23:'twenty three',24:'twenty four',25:'twenty five',26:'twenty six',27:'twenty seven',28:'twenty eight',29:'twenty nine',30:'half'}
# vow=['a','e','i','o','u']
# dx,dy=[0,1,0,-1],[1,0,-1,0]

# import random
# from collections import deque, Counter, OrderedDict,defaultdict
# from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace
# from math import ceil,floor,log,sqrt,factorial,pi,gcd
# from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right

def get_array(): return list(map(int, sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()

Arr = [0]
dp = [0]
prev_sum = 0
prev_length = 1
n = int(input())
while n:
    arr = get_array()
    if len(arr)==2:
        number = arr[1]
        Arr.append(number)
        dp.append(0)
        ans = (prev_sum+number)/(prev_length+1)
        print(ans)
        prev_length+=1
        prev_sum+=number
    elif len(arr)==3:
        a,x = arr[1],arr[2]
        dp[a-1]+=x
        ans = (prev_sum + a*x)/(prev_length)
        print(ans)
        prev_sum+=a*x
    else:
        ans = (prev_sum - (Arr[-1]+dp[-1]))/(prev_length - 1)
        print(ans)
        prev_sum-=(Arr[-1]+dp[-1])
        prev_length-=1
        dp[-2]+=dp[-1]
        Arr.pop()
        dp.pop()
    n-=1

from sys import stdin
input = stdin.readline
n = int(input())
arr, cnt, curr_len, curr_sum = [0] * (n+1), [0] * (n+1), 1, 0
for _ in range(n):
    s = input()
    if s[0] == '1':
        _, x, y = list(map(int, s.split()))
        curr_sum += x*y
        cnt[x-1] += y
    elif s[0] == '2':
        _, x = list(map(int, s.split()))
        curr_sum += x
        arr[curr_len] = x
        curr_len += 1
    else:
        curr_len -= 1
        curr_sum -= arr[curr_len] + cnt[curr_len]
        cnt[curr_len-1] += cnt[curr_len]
        cnt[curr_len] = 0
    print('%.9f' % (curr_sum / curr_len))


from sys import stdin
input = stdin.readline
n = int(input())
arr, cnt, curr_len, curr_sum = [0] * (n+1), [0] * (n+1), 1, 0
for _ in range(n):
    s = input()
    if s[0] == '1':
        _, x, y = list(map(int, s.split()))
        curr_sum += x*y
        cnt[x-1] += y
    elif s[0] == '2':
        _, x = list(map(int, s.split()))
        curr_sum += x
        arr[curr_len] = x
        curr_len += 1
    else:
        curr_len -= 1
        curr_sum -= arr[curr_len] + cnt[curr_len]
        cnt[curr_len-1] += cnt[curr_len]
        cnt[curr_len] = 0
    print('%.9f' % (curr_sum / curr_len))


import sys
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))
n=int(input())
l=[0]
dp=[0]
s=0
c=1
while n:
    #print(l)
    t=get_array()
    if t[0]==2:
        l.append(t[1])
        dp.append(0)
        s+=t[1]
        c+=1
        print(s/c)
    elif t[0]==3:
        s-=(l[-1]+dp[-1])
        dp[-2]+=dp[-1]
        l.pop()
        dp.pop()
        c-=1
        print(s/c)
    else:
        dp[t[1]-1]+=t[2]
        s+=t[1]*t[2]
        print(s/c)
    n-=1
    #r=s/c
    #r="{0:.6f}".format(r)
    #print(r)


import sys
from math import log2,floor,ceil,sqrt,gcd
import bisect
# from collections import deque
# sys.setrecursionlimit(10**5)

Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
INF = 10 ** 18
MOD =  1000000007

n = int(ri())
sta  = [0]
extra = [0]*(n+1)
avg = 0
for i in range(n):
    temp = Ri()
    if temp[0] == 1:
        # print(avg)
        temp[1] = min(temp[1],len(sta))
        extra[temp[1]-1] += temp[2]
        # print(temp[1]*temp[2])
        avg = (avg*len(sta) + temp[1]*temp[2])/len(sta)
        # print(avg)
    elif temp[0] == 2:
        sta.append(temp[1])
        avg= (avg*(len(sta)-1) + temp[1])/len(sta)
        # print(avg)
    else:
        # print(len(sta),sta,extra)
        extra[len(sta)-2]+=extra[len(sta)-1]
        avg = (avg*len(sta) - (sta[-1]+extra[len(sta)-1]))/(len(sta)-1)
        extra[len(sta)-1] = 0
        sta.pop()
    print(avg)

n=int(input())
s=0
c=1
l=[0]
d=[0]
ans=[0]*n
for i in range(n):
    x=list(map(int,input().split()))
    if x[0]==1:
        d[x[1]-1]+=x[2]
        s=s+x[1]*x[2]
    elif x[0]==2:
        l.append(x[1])
        d.append(0)
        s=s+x[1]
        c=c+1
    else:
        t=d[-1]
        s=s-l[-1]-t 
        c=c-1
        l.pop()
        d.pop()
        d[-1]+=t
    ans[i]=str(s/c)
print('\n'.join(ans))

n = int(input())
t=1
a=[0]
p=[0]*(n+2)
s=0

ans=[0]*n
for i in range(n):
    
    m=list(map(int,input().split()))
    if len(m)==1:
        
        s-=(p[t-1]+a[-1])
        t-=1
        p[t-1]+=p[t]
        p[t]=0
        
        a.pop(-1)
    elif len(m)==2:
        a.append(m[1])
        s+=m[1]
        t+=1
        
    else:
        s+=m[1]*m[2]
        p[m[1]-1]+=m[2]
    ans[i]=str(s/t)
    #print(p[:n+4],a,k,t)
print("\n".join(ans))


#besme taala
#ya_hossein
from sys import stdin
input = stdin.readline
n, sum, point = int(input()), 0, 1
num = (n+1)*[0]
f = (n+1)*[0]
for i in range(n):
    k = list(map(int, input().split()))
    if k[0] == 1:
        f[k[1] - 1] += k[2]
        sum += k[2]*k[1]
    elif k[0] == 2:
        num[point] = k[1]
        sum += k[1]
        point += 1
    elif k[0] == 3:
        point -= 1
        sum -= num[point] + f[point]
        f[point - 1] += f[point]
        f[point] = 0
    print('%.6f' % (sum / point))