k = int(eval(input()))

from math import gcd



ans=0

for i in range(k):

    ans+=i+1

    for j in range(i+1, k):

        x=gcd(i+1,j+1)

        ans+=6*gcd(i+1,j+1)

        for l in range(j+1, k):

            ans+=6*gcd(x,l+1)

print(ans)

n=3

k=int(eval(input()))

INF=10**9+7

l=[0]*k

ans=0

for i in range(k-1,-1,-1):

    x=i+1

    temp=pow(k//x,n,INF)

    for j in range(2,k//x+1):

        temp=(temp-l[j*x-1])%INF

    l[i]=temp

    ans=(ans+x*temp)%INF

print(ans)



k = int(eval(input()))
from math import gcd

ans = 0
for i in range(k):
    ans += i + 1
    for j in range(i + 1, k):
        x = gcd(i + 1, j + 1)
        ans += 6 * gcd(i + 1, j + 1)
        for l in range(j + 1, k):
            ans += 6 * gcd(x, l + 1)
print(ans)

n = 3
k = int(eval(input()))
INF = 10**9 + 7
l = [0] * k
ans = 0
for i in range(k - 1, -1, -1):
    x = i + 1
    temp = pow(k // x, n, INF)
    for j in range(2, k // x + 1):
        temp = (temp - l[j * x - 1]) % INF
    l[i] = temp
    ans = (ans + x * temp) % INF
print(ans)

+n = 3 -from math import gcd - +INF = 10**9 + 7 +l = [0] * k -for i in range(k): -    ans += i + 1 -    for j in range(i + 1, k): -        x = gcd(i + 1, j + 1) -        ans += 6 * gcd(i + 1, j + 1) -        for l in range(j + 1, k): -            ans += 6 * gcd(x, l + 1) +for i in range(k - 1, -1, -1): +    x = i + 1 +    temp = pow(k // x, n, INF) +    for j in range(2, k // x + 1): +        temp = (temp - l[j * x - 1]) % INF +    l[i] = temp +    ans = (ans + x * temp) % INF