Alice got an array of length $n$ as a birthday present once again! This is the third year in a row! 

And what is more disappointing, it is overwhelmengly boring, filled entirely with zeros. Bob decided to apply some changes to the array to cheer up Alice.

Bob has chosen $m$ changes of the following form. For some integer numbers $x$ and $d$, he chooses an arbitrary position $i$ ($1 \le i \le n$) and for every $j \in [1, n]$ adds $x + d \cdot dist(i, j)$ to the value of the $j$-th cell. $dist(i, j)$ is the distance between positions $i$ and $j$ (i.e. $dist(i, j) = |i - j|$, where $|x|$ is an absolute value of $x$).

For example, if Alice currently has an array $[2, 1, 2, 2]$ and Bob chooses position $3$ for $x = -1$ and $d = 2$ then the array will become $[2 - 1 + 2 \cdot 2,~1 - 1 + 2 \cdot 1,~2 - 1 + 2 \cdot 0,~2 - 1 + 2 \cdot 1]$ = $[5, 2, 1, 3]$. Note that Bob can't choose position $i$ outside of the array (that is, smaller than $1$ or greater than $n$).

Alice will be the happiest when the elements of the array are as big as possible. Bob claimed that the arithmetic mean value of the elements will work fine as a metric.

What is the maximum arithmetic mean value Bob can achieve?


-----Input-----

The first line contains two integers $n$ and $m$ ($1 \le n, m \le 10^5$) — the number of elements of the array and the number of changes.

Each of the next $m$ lines contains two integers $x_i$ and $d_i$ ($-10^3 \le x_i, d_i \le 10^3$) — the parameters for the $i$-th change.


-----Output-----

Print the maximal average arithmetic mean of the elements Bob can achieve.

Your answer is considered correct if its absolute or relative error doesn't exceed $10^{-6}$.


-----Examples-----
Input
2 3
-1 3
0 0
-1 -4

Output
-2.500000000000000

Input
3 2
0 2
5 0

Output
7.000000000000000

Difficulty: interview

Starter code:

Solutions:
n, m = list(map(int, input().split()))
res = 0
mx = (n-1)*n//2
mn = 0
if n&1:
    mn = (n//2)*(n//2+1)
else:
    mn = n*n//4
for i in range(m):
    x, d = list(map(int, input().split()))
    res += x*n
    if d > 0:
        res += mx*d
    else:
        res += mn*d
print('%.10f'%(res/n))


n, m = list(map(int, input().split()))
a = (n * (n - 1)) // 2
n2 = n // 2
b = n2 * (n2 + 1)
if n % 2 == 0:
    b -= n2
s = 0
for i in range(m):
    x, d = list(map(int, input().split()))
    s += x * n
    s += d * (a if d > 0 else b)

print(s / n)


import time
from copy import deepcopy
import itertools
from bisect import bisect_left
from bisect import bisect_right
import math
from collections import deque
from collections import Counter


def read():
    return int(input())


def readmap():
    return map(int, input().split())


def readlist():
    return list(map(int, input().split()))


n, m = readmap()
X = []
D = []
for _ in range(m):
    x, d = readmap()
    X.append(x)
    D.append(d)

summ = n * sum(X)

for i in range(m):
    d = D[i]
    if d < 0:
        if n % 2 == 1:
            summ += d * (n // 2) * (n // 2 + 1)
        else:
            summ += d * (n // 2) * (n // 2)
    else:
        summ += d * (n - 1) * n // 2

print(summ / n)

n, m = list(map(int,input().split()))


max_dist = (n - 1)* n//2
min_dist = max_dist
curr_value = max_dist
for i in range(n):
    curr_value = i * (i + 1) // 2 + (n - 1 - i)*(n - i)//2
    min_dist = min(min_dist, curr_value)

answer = 0
add_value = 0

for i in range(m):
    x, d = list(map(int, input().split()))
    answer+=x
    if d >= 0:
        add_value += d*max_dist
    else:
        add_value += d * min_dist

        
print(answer + (add_value / n))
    
            


n,m  = list(map(int,input().split()))
ans  = 0
num1 = n // 2
num2 = n // 2
num3 = n * (n-1) // 2
if n % 2 == 0:
    num1 -=  1

num1 = (num1+1) * num1 // 2
num2 = (num2+1) * num2 // 2

while m > 0:
    x, d  = list(map(int,input().split()))
    ans += x * n
    if d < 0:
        ans += d * num1
        ans += d * num2 
    else:
        ans += d * num3
    m -= 1

print(ans / n)




def main():
    n, m = list(map(int, input().split(' ')))
    s = 0
    Ms = n * (n - 1) //2
    ms = n // 2 * (n // 2 + 1)
    if n % 2 == 0: ms -= n // 2
    for _ in range(m):
        x, d = list(map(int, input().split(' ')))
        s += x * n
        s += Ms * d if d >= 0 else ms * d
    print(s / n)

def __starting_point():
    main()

__starting_point()

n, m = input().split(' ')
n, m = int(n), int(m)
s = 0
for i in range(m):
    x, d = input().split(' ')
    x, d = int(x), int(d)
    s = s + n*x
    if d >= 0:
        s = s + d*((n*(n-1))//2)
    else:
        s = s + 2*d*((((n-1)//2)*((n-1)//2+1))//2)
        if n % 2 == 0:
            s = s + d*(n//2)
print(s/n)


rd = lambda: list(map(int, input().split()))
n, m = rd()
t = (n - 1) * n // 2
a = n - 1 >> 1
tt = a * (a + 1) + [a + 1, 0][n & 1]
r = 0
for i in range(m):
    x, d = rd()
    if d > 0:
        r += t * d + n * x
    else:
        r += tt * d + n * x
print(r / n)


n,m=[int(x) for x in input().split()]
ans=0
off=0
def summ(x):
    return x*(x+1)//2
def minn():
    x=n//2
    left=x
    right=n-x-1
    return summ(left)+summ(right)
def maxx():
    x=0
    left=x
    right=n-x-1
    return summ(left)+summ(right)

for i in range(m):
    a,b=[int(x) for x in input().split()]
    off+=a
    if b<0:
        ans+=b*minn()
    else:
        ans+=b*maxx()
print(ans/n+off)


n, m = list(map(int, (input().split())))
xSum = 0
res = 0
posMult = n * (n - 1) // 2;
negMult = n // 2 * (1 + n // 2)
if (n % 2 == 0):
    negMult -= n // 2

for i in range(m):
    x, d = list(map(int, (input().split())))
    xSum += x
    if d < 0:
        res += negMult * d
    else:
        res += posMult * d

print(xSum + res/n)


len, que = [int(x) for x in input().split(" ")]
total = 0

full = (len*(len-1))//2
if(len%2!=0):
    half = len//2
    half = (half*(half+1))
else:
    half = len//2
    half = half*half

for i in range(que):
    curr = [int(x) for x in input().split(" ")]
    total+=(curr[0]*len)
    if(curr[1]>=0):
        total+=curr[1]*full
    else:
        total+=curr[1]*half

print(float(total)/len)

n, m = list(map(int, input().split()))
num1 = n * (n -  1) // 2
if n % 2 == 0:
  num2 = (n // 2 + 1) * (n // 2) // 2 + \
         (n // 2 - 1) * (n // 2) // 2
else:
  num2 = (n // 2 + 1) * (n // 2)
s = 0
for _ in range(m):
  x, d = list(map(int, input().split()))
  s += x * n
  if d > 0:
    s += d * num1
  else:
    s += d * num2
print(s / n)


n,m=map(int,input().split())
ans=0
for i in range(m):
    x,d=map(int,input().split())
    ans+=(x*n)
    if d>=0:
        r=(n*(n-1))//2
        ans+=(r*d)
    elif n%2!=0:
        r=n//2
        r=r*(r+1)
        ans+=(r*d)
    else:
        r=n//2;k=r-1
        r=((r*(r+1))//2)+((k*(k+1))//2)
        ans+=(r*d)
print(ans/n)

n,m = list(map(int, input().split()))
avg = 0
sumd = 0
for i in range(m):
    x, d = list(map(int, input().split()))
    avg += x
    if d > 0:
        sumd += d*((n*(n-1))//2)
    elif d < 0:
        k = (n-1)//2
        sumd += d*k*(k+1)
        if n%2 == 0:
            sumd += d*(n//2)
print(avg+sumd/n)


R = lambda: map(int, input().split())

n, m = R()

max_s = min_s = 0
t = (n + 1) // 2
for i in range(1, n+1):
    max_s += i - 1
    min_s += abs(i - t)

s = 0
for _ in range(m):
    x, d = map(int, input().split())
    if d > 0:
        s += n*x + d * max_s
    else:
        s += n*x + d * min_s
print('{:.8f}'.format(s / n))

m,n = map(int, input().split())
mx = 0
for i in range(n):
    a,b = map(int, input().split())
    mx += a * m
    if b > 0:
        mx += b * (m - 1)*m//2
    else:
        if m % 2 == 1:
            k = m // 2 + 1
            mx += b * (k-1)*k
        else:
            k = m // 2
            mx += b * k*k
print(mx/m)

n, m = map(int, input().split())
ans = 0
s1 = (n * (n - 1)) // 2
fi = n // 2
se = n - fi - 1
s2 = (fi * (fi + 1)) // 2 + (se * (se + 1)) // 2
for i in range(m):
    x, d = map(int, input().split())
    if d < 0:
        ans += n * x + d * s2
    else:
        ans += n * x + d * s1
print(ans / n)

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import time

(n, m) = (int(i) for i in input().split())

ans = 0


start = time.time()

for i in range(m):
    (x, d)  = (int(i) for i in input().split())
    ans += n*x
    if d > 0:
        ans +=d*((n-1)*n//2)
    else:
        if n%2 == 0:
            ans += d*n*n//4
        else:
            ans += d*(n+1)*(n-1)//4
print(ans/n)
finish = time.time()
#print(finish - start)


n, m = list(map(int, input().split()))
t = n//2
s = 0
for i in range(m):
    a, b = list(map(int, input().split()))
    if b < 0:
        if n%2:
            s += b*t*(t + 1)
        else:
            s += b*t*(t - 1)//2 + b * (t + 1) * t // 2
    if b > 0:
        s += b * n * (n - 1) // 2
    s += n * a
    
print(s/n)


n,m=list(map(int,input().split()))
ans=0
a=[]
for i in range(m):
    ip=list(map(int,input().split()))
    ans+=ip[0]
    a.append(ip[1])
ans*=n
pos=n*(n-1)//2
nn=n//2
neg=nn*(nn+1)
#print(ans,pos,neg)
if(n%2==0):
    neg-=nn
#print(ans,pos,neg)
for i in range(m):
    if(a[i]>0):
        ans+=a[i]*pos
    else:
        ans+=a[i]*neg
print(ans/n)

import sys
n, m = list(map(int, input().split()))
a = 0
s = n * n // 4 if n % 2 == 0 else (n // 2) * (n // 2 + 1)
t = n * (n - 1) // 2
for _ in range(m):
	x, d = list(map(int, sys.stdin.readline().split()))
	a += (x * n) + (s * d if d < 0 else t * d)
print(a/n)


# def Bob(pos,x,d,a):
#     pos -= 1
#     for i in range(len(a)):
#         a[i] += x + d*abs(i-pos)
#     return a

def main():
    n,m = [int(x) for x in input().split()]
    a = [0]*n
    xx = 0
    dd = 0

    for _ in range(m):
        x,d = [int(x) for x in input().split()]
        xx += x*n
        if d>0:
            dd += d*(n*(n-1))//2
        else:
            z = (n+1)//2
            dd += d*(z*(z-1))
            if n%2==0:
                dd += (n//2)*d
    print((xx+dd)/n)

main()


n,m=map(int,input().split())
ans=0
k1=((n-1)*n)//2
if(n%2==0):
    z=n//2
    k2=z**2
else:
    z=n//2
    k2=z*(z+1)
fans=0
f2=0
for i in range(m):
    x,d=map(int,input().split())
    if(d<0):
        ans+=x*n+d*k2
    else:
        ans+=x*n+d*k1

print(ans/n)

n,m = list(map(int,input().split(' ')))

if n%2==0:
    l = -1 + n//2
    h = n//2 
    k = l*(l+1)//2 + h*(h+1)//2 
else:
    z = n//2
    k = z*(z+1)
ans = 0
for i in range(m):
    x,d = list(map(int,input().split(' ')))
    ans += n*x

    if d>=0:
        ans+=d*((n*(n-1))//2)
    else:
        ans+=d*k

print(ans/n)
        
        
        


n, m = map(int, input().split())
sumx = 0
bigsum = (n - 1) * n // 2
mid = (n + 1) // 2
if n & 1:
    smallsum = mid * (mid - 1)
else:
    smallsum = mid * (mid - 1) + mid
for i in range(1, m + 1):
    x, d = map(int, input().split())
    sumx += x * n
    if d < 0:
        sumx += d * smallsum
    elif d > 0:
        sumx += d * bigsum
print("%.15f" % (sumx / n))