Harryxun/stf_run huggingface dataset:
input_list = list(map(int, input().split()))
games = input_list[0]
temp = input_list[1]
input_list = list(map(int, input().split()))
r = input_list[0]
s = input_list[1]
p = input_list[2]
target = input()

def no_win_hand(next_hand):
  myhand = win_janken(next_hand)
  return myhand

def get_point(myhand):
  if myhand == 'r':
    point = r
  elif myhand == 's':
    point = s
  else:
    point = p
  return point

def win_janken(hand, next_hand = 'non', donate = 'non'):
  if hand == 'r':
    myhand = 'p'
  elif hand == 's':
    myhand = 'r'
  else:
    myhand = 's'
  point = get_point(myhand)
  if myhand == donate:
    nothand = no_win_hand(next_hand)[0]
    select_hands = ['r','s','p']
    for hand_1 in select_hands:
      if hand_1 is not donate and  hand_1 is not nothand:
        myhand = hand_1
    point = 0
  return myhand, point

allpoint = 0
for m in range(temp):
  group = ''
  for ind, n in enumerate(target):
    if ind % temp == m:
       group += n
  points = 0
  myhands =''
  for index, string in enumerate(group):
    if len(myhands) > 0:
      donate = myhands[index - 1]
    else:
      donate = 'non'
    if index < len(group) - 1:
      myhand, point = win_janken(string, group[index + 1], donate)
    else:
      myhand, point = win_janken(string, 'non', donate)
    points += point
    myhands += myhand
  allpoint += points
print(allpoint)

### FIXED CODE ###

strings = list(map(str, input().split()))
string = strings[1] + strings[0]
print(string)
pi = 3.141592
x = input()

print(x*2*pi)

### FIXED CODE ###

import numpy as np
r = int(input())
 
print(r*2*np.pi)
a,b = input().split()
aa = int(a)
bb = b.replace(".","")
print(aa*bb//100)

### FIXED CODE ###

a,b = input().split()
aa = int(a)
bb = int(b.replace(".",""))
print(aa*bb//100)
import sys

N, K = map(int, sys.stdin.readline().split())
A = list(map(int, sys.stdin.readline().strip().split()))

A.sort()
if K == 0:
    print(A[-1])
else:
    ans = 10**9
    l = 0
    r = 10**9
    while l < r:
        # t以下の長さにするのに必要な切る回数
        t = (l + r) // 2
        # print(t)
        n = K
        for a in A:
            n -= (a - 1) // t
            if n < 0:
                break
        if n >= 0:
            ans = min(ans, t)
        if n >= 0:
            r = t
        else:
            l = t + 1

    print(ans)

### FIXED CODE ###

import sys

N, K = map(int, sys.stdin.readline().split())
A = list(map(int, sys.stdin.readline().strip().split()))

A.sort()
if K == 0:
    print(A[-1])
else:
    ans = 10**9
    l = 0
    r = 10**9
    while l < r:
        # t以下の長さにするのに必要な切る回数
        t = (l + r) // 2
        if t == 0:
            break
        # print(t)
        n = K
        for a in A:
            n -= (a - 1) // t
            if n < 0:
                break
        if n >= 0:
            ans = min(ans, t)
        if n >= 0:
            r = t
        else:
            l = t + 1

    print(ans)
correct_str = "CODEFESTIVAL2016"
wrong_str = raw_input()
count = 0
for i in range(16):
  if wrong_str[i] != correct_str[i]:
    count count += 1

print str(count)

### FIXED CODE ###

correct = "CODEFESTIVAL2016"
wrong = raw_input()
count = 0

for i in range(16):
  if correct[i] != wrong[i]:
    count += 1

print count
N = int(input())
S = input()
listS = list(S)
setS = set(listS)

#異なる文字から2個を選ぶ場合（2項定理の利用）
if len(listS) == len(setS):
    res = 2**len(setS)-1
    print(res)
    sys.exit()
else:
    res = 0
for x in setS:
    n = listS.count(x)
    if n == 1:
        res += 1
    else:
        res += (2**(len(setS)-1))*n
print(res)

### FIXED CODE ###

mod = 10**9 + 7
N = int(input())
S = list(input())
al = [chr(ord("a") + i ) for i in range(26)]
cntAl = [ S.count(chr(ord("a") + i )) for i in range(26)]
ans = 1
for a in cntAl:
    if a != 0:ans *= (a+1)%mod
print((ans-1)%mod)
n, m = map(int, input().split())
p = list(map(int, input().split()))

par = {x:x for x in range(1, n+1)}

def root(node):
    if par[node] == node:
        return node
    par[node] = root(par[node])
    return par[node]

for _ in range(m):
    x, y  = map(int, input().split())
    par[root[x]] = root[y]
    
ans = 0
for i in range(1, n+1):
    if root[i] == root(p[i-1]):
        ans += 1

print(ans)

### FIXED CODE ###

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

par = {x:x for x in range(1, n+1)}

def root(node):
    if par[node] == node:
        return node
    par[node] = root(par[node])
    return par[node]

for _ in range(m):
    x, y  = map(int, input().split())
    par[root(x)] = root(y)
    
ans = 0
for i in range(1, n+1):
    if root(i) == root(p[i-1]):
        ans += 1

print(ans)
A = str(input())
B = str(input())
C = str(input())
na = int()
nb = int()
nc = int()
n = 'a'

while na < len(A)+1 and nb < len(B)+1 and nc < len(C)+1:
    if n == 'a':
        if A[na] == 'a':
            na += 1
            n = 'a'
        elif A[na] == 'b':
            na += 1
            n = 'b'
        elif A[na] == 'c':
            na += 1
            n = 'c'
    if n == 'b':
        if B[nb] == 'a':
            nb += 1
            n = 'a'
        elif B[nb] == 'b':
            nb += 1
            n = 'b'
        elif B[nb] == 'c':
            nb += 1
            n = 'c'
    if n == 'c':
        if C[nc] == 'a':
            nc += 1
            n = 'a'
        elif C[nc] == 'b':
            nc += 1
            n = 'b'
        elif C[nc] == 'c':
            nc += 1
            n = 'c'

print(n)


### FIXED CODE ###

from collections import deque
A = deque(list(input()+'A'))
B = deque(list(input()+'B'))
C = deque(list(input()+'C'))

x = A.popleft()
while(True):
    if x == 'a':
        x = A.popleft()
    elif x == 'b':
        x = B.popleft()
    elif x == 'c':
        x = C.popleft()
    else:
        break

print(x)
import sys
N,M,K=map(int,input().split())
s=[[]for i in range(N)]
tn=[0]*N
sys.setrecursionlimit(200000)
for i in range(M):
    a,b=map(int,input().split())
    s[a-1].append(b)
    s[b-1].append(a)
    tn[a-1]+=1
    tn[b-1]+=1
l=[None]*N
def hu(n,t):
    for i in s[n]:
        if l[i-1]==None:
            l[i-1]=t
            hu(i-1,t)
t=0
for i in range(N):
    if l[i]==None:
        hu(i,t)
        t+=1
c=[0]*t
for i in l:
    c[i]+=1
for i in range(K):
    a,b=map(int,input().split())
    if l[a-1]==l[b-1]:
        tn[a-1]+=1
        tn[b-1]+=1
for i in range(N):
    print(c[l[i]]-tn[i]-1,end=" ")

### FIXED CODE ###

import sys
N,M,K=map(int,input().split())
s=[[]for i in range(N)]
tn=[0]*N
sys.setrecursionlimit(200000)
for i in range(M):
    a,b=map(int,input().split())
    s[a-1].append(b)
    s[b-1].append(a)
    tn[a-1]+=1
    tn[b-1]+=1
l=[None]*N
def hu(n,t):
    l[n]=t
    for i in s[n]:
        if l[i-1]==None:
            l[i-1]=t
            hu(i-1,t)
t=0
for i in range(N):
    if l[i]==None:
        hu(i,t)
        t+=1
c=[0]*t
for i in l:
    c[i]+=1
for i in range(K):
    a,b=map(int,input().split())
    if l[a-1]==l[b-1]:
        tn[a-1]+=1
        tn[b-1]+=1
for i in range(N):
    print(c[l[i]]-tn[i]-1,end=" ")
def main():
    S = input()
    N = len(S)
    for k in range(N - 1, (N // 2) - 1, -1):
        first = S[0:k]
        union = k * 2 - N
        cut = first[-union:-1] + first[-1]
        if '1' in cut and '0' in cut:
            continue
        else:
            return print(k)


main()


### FIXED CODE ###

def ans():
    S = input()
    N = len(S)
    if not ('1' in S and '0' in S):
        return print(N)

    tmp = 1000000
    for i, v in enumerate(S):
        if i == 0:
            continue
        if S[i-1] != v:
            tmp = min(max(i, N-i), tmp)
    return print(tmp)

# main()
ans()
X=input()
if X >=30:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

x=int(input())
if x >=30:
    print("Yes")
else:
    print("No")
def main():
    s=input()
    a=s.find('C')
    if(a==-1):
        print('No')
    else
        a2=s.find('F',a+1,len(s))
        if(a2==-1):
            print('No')
        else:
            print('Yes')

main()


### FIXED CODE ###

def main():
    s=input()
    a=s.find('C')
    if(a==-1):
        print('No')
    else:
        a2=s.find('F',a+1,len(s))
        if(a2==-1):
            print('No')
        else:
            print('Yes')

main()
n=int(input())

m=-1

for i in range(3,1000,2):
    if i*i==8*n+1:
        m=(1+i)//2

if m==-1:
    print('No')
    exit(0)

cnt=1
s=[[0] for _ in range(n+1)]

for i in range(1,m+1):
    for j in range(i+1,m+1):
        s[i][0]+=1
        s[j][0]+=1

        s[i].append(cnt)
        s[j].append(cnt)

        cnt+=1

for i in range(1,m+1):
    print(' '.join([str(c) for c in s[i]]))

### FIXED CODE ###

n=int(input())

m=-1

for i in range(3,1000,2):
    if i*i==8*n+1:
        m=(1+i)//2

if m==-1:
    print('No')
    exit(0)

cnt=1
s=[[0] for _ in range(m+1)]

for i in range(1,m+1):
    for j in range(i+1,m+1):
        s[i][0]+=1
        s[j][0]+=1

        s[i].append(cnt)
        s[j].append(cnt)

        cnt+=1

print('Yes')
print(m)
for i in range(1,m+1):
    print(' '.join([str(c) for c in s[i]]))
def main():
    while True:
        n = int(input().strip())

        if n == 0:
            break

        phrases = []
        for _ in range(n):
            word = input().strip()
            phrases.append(word)

        PHRASE_LEN = [5,7,5,7,7]
        found_flag = False

        for i in range(n):
            acc_len = 0
            phrase_idx = 0
            for j in range(i, n):
                acc_len += len(phrases[j])

                if acc_len == PHRASE_LEN[phrase_idx]:
                    if phrase_idx == (len(PHRASE_LEN)-1):
                        found_flag = True
                        break

                    acc_len = 0
                    phrase_idx += 1
                elif acc_len > PHRASE_LEN[phrase_idx]:
                    break

            if found_flag:
                print(i+1)
                break

if __name__ == "__main__":
    main()
~                                                                                                                                                                                                                   
~                                                                                                                                                                                                                   
~                       


### FIXED CODE ###

def main():
    while True:
        n = int(input().strip())

        if n == 0:
            break

        phrases = []
        for _ in range(n):
            word = input().strip()
            phrases.append(word)

        PHRASE_LEN = [5,7,5,7,7]
        found_flag = False

        for i in range(n):
            acc_len = 0
            phrase_idx = 0
            for j in range(i, n):
                acc_len += len(phrases[j])

                if acc_len == PHRASE_LEN[phrase_idx]:
                    if phrase_idx == (len(PHRASE_LEN)-1):
                        found_flag = True
                        break

                    acc_len = 0
                    phrase_idx += 1
                elif acc_len > PHRASE_LEN[phrase_idx]:
                    break

            if found_flag:
                print(i+1)
                break

if __name__ == "__main__":
    main()
a = int(input())
b = int(input())
X = b - a 
s = int((X*(X+1))/2 - b)
print(s)

### FIXED CODE ###

data = list(map(int,input().split()))
a = data[0]
b = data[1]
X = b - a 
s = int((X*(X+1))/2 - b)
print(s)
import collections
import itertools
import operator


class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)


a,b =  map(int, input().split())
l = list(map(int, input().split()))
uf = UnionFind(a)
for i in range(b):
    x,y =map(int, input().split())
    x-=1
    y-=1
    uf.union(x, y)  # (3)
ans=0
for i,t in enumerate(l):
    if uf.same(t-1,l[i]-1):ans+=1

print(ans)


### FIXED CODE ###

import collections
import itertools
import operator


class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same(self, x, y):
        return self.find(x) == self.find(y)


a,b =  map(int, input().split())
l = list(map(int, input().split()))
uf = UnionFind(a)
for i in range(b):
    x,y =map(int, input().split())
    x-=1
    y-=1
    uf.union(x, y)  # (3)
ans=0
for i,t in enumerate(l):
    if uf.same(t-1,i):ans+=1

print(ans)
a = int(input())
b = [0] * (10 ** 5)
c = list(map(int, input().split()))
for i in c:
    b[i-1] += 1
d = 0
e = 0
for i in range(len(b)-1, -1, -1):
    if b[i] >= 2:
        if d == 0:
            d = i+1
        elif e == 0:
            e = i+1
        else:
            print(d*e)
            exit()
print(d*e)


### FIXED CODE ###

a = int(input())
b = list(map(int, input().split()))
b = sorted(b, reverse=True)
c = []
d = []
for i in range(1, len(b)):
    if i-1 not in d:
        if b[i] == b[i-1]:
            c.append(b[i])
            d.append(i)
        if len(c) == 2:
            print(c[0] * c[1])
            exit()
print(0)
n = (input()
a = []
for i in range(n):
     a.append(input())
  i+=1
for j in range(n):
     a.append(input())
   j+=1
j = 1
i = 0
max = a[j]-a[i]
 while i < n:
    while  j < n:
       if max < a[j]-a[i]:
          max = a[j]-a[i]
        j+ = 1
     i+ = 1
  print  max

### FIXED CODE ###

N = int(raw_input())
min = int(raw_input())
max = int(raw_input())

ans = max - min
if max < min:
    min = max
 
for i in range(N - 2):
    R = int(raw_input())
    if R - min > ans:
        ans = R - min
    if R < min:
        min = R
 
print ans
while(True):
  h,w=map(int,input())
  if h==0 and w==0:
    break
  rect='#'*w+'\n'
  rect+=('#'+'.'*(w-2)+'#\n')*(h-2)
  rect='#'*w+'\n'
  print(rect)

### FIXED CODE ###

while(True):
  h,w=map(int,input().split())
  if h==0 and w==0:
    break
  rect='#'*w+'\n'
  rect+=('#'+'.'*(w-2)+'#\n')*(h-2)
  rect+='#'*w+'\n'
  print(rect)
[a,b,c]=[int(x) for x in input().split]
if a<b<c:
 print("Yes")
else:
 print("No")

### FIXED CODE ###

[a,b,c]=[int(x) for x in input().split()]
if a<b<c:
 print("Yes")
else:
 print("No")
import math
def func(x):
    return math.pi*2*x
  
x=R
print(func(x))

### FIXED CODE ###

import math
n=int(input())
def func(n):
    return math.pi*n*2
print(func(n))
import bisect

N,Q = map(int,(input().split()))
S = list(input())

l = []
for i in range(N):
    if S[i] == "A" and S[i+1] == "C":
        l.append(i+1.5)
s = 0
for i in range(Q):
    a,b = map(int,(input().split()))
    if l:
        print(bisect.bisect_left(l,b) - bisect.bisect_left(l,a))
    else:
        print(0)

### FIXED CODE ###

import bisect

N,Q = map(int,(input().split()))
S = list(input())

l = []
for i in range(N-1):
    if S[i] == "A" and S[i+1] == "C":
        l.append(i+1.5)

for i in range(Q):
    a,b = map(int,(input().split()))
    print(bisect.bisect_left(l,b) - bisect.bisect_left(l,a))
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]
 
sys.setrecursionlimit(1000000)
mod = 1000000007
 
def solve():
    n,k = map(int,input().split())
    if n%k == 0:
      print(0)
    else:
      print(math.gcd(n,k))
    
    return
 
#Solve
if __name__ == "__main__":
    solve()

### FIXED CODE ###

#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,k = map(int,input().split())
    print(min(n%k,-n%k))
    return

#Solve
if __name__ == "__main__":
    solve()
a169
#  値 A × B を整数として出力せよ。

#   入力（スペース区切りの2整数を受け取る）
a, b = map(int, input().split())
#   print(a, b)

#   処理
answer = a * b

#   出力
print(answer)

### FIXED CODE ###

#   a169
#  値 A × B を整数として出力せよ。

#   入力（スペース区切りの2整数を受け取る）
a, b = map(int, input().split())
#   print(a, b)

#   処理
answer = a * b

#   出力
print(answer)
#コピペAC
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9
def dfs(cur, a, b, c):
if cur == N:
return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
ret0 = dfs(cur + 1, a, b, c)
ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))

### FIXED CODE ###

#コピペAC
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9
def dfs(cur, a, b, c):
  if cur == N:
    return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
  ret0 = dfs(cur + 1, a, b, c)
  ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
  ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
  ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
  return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))
from collections import deque
K = int(input())
queue = deque([1,2,3,4,5,6,7,8,9])
count = 1
while count <= K:
  num = queue.popleft()
  if num%10!=0:
    queue.append(num*10+num%10-1)
  queue.append(num*10+num%10)
  if num%!=9:
    queue.append(num*10+num%10+1)
  
print(num)

### FIXED CODE ###

from collections import deque
K = int(input())
queue = deque([1,2,3,4,5,6,7,8,9])
count = 1
while count <= K:
  num = queue.popleft()
  if num%10!=0:
    queue.append(num*10+num%10-1)
  queue.append(num*10+num%10)
  if num%10!=9:
    queue.append(num*10+num%10+1)
  count+=1
  
print(num)
N,T = map(int, input().split())

min_t = T + 1
ans = "TLE"

for i in range(N):
  c,t = map(int, input().split())
  if t<min_t:
    min_t = t
    ans = c
  elif t==min_t:
    if ans>c:
      ans=c
print(ans)

### FIXED CODE ###

N,T = map(int, input().split())

ans = 10000

for i in range(N):
  c,t = map(int, input().split())
  
  if t<=T and c<ans:
    ans=c

if ans!=10000:
  print(ans)
else:
  print("TLE")
import sys
from collections import defaultdict


def read():
    n, v = map(int, sys.stdin.readline().split())
    a = tuple(map(int, sys.stdin.readline().split()))
    b = tuple(map(int, sys.stdin.readline().split()))
    c = tuple(map(int, sys.stdin.readline().split()))
    d = tuple(map(int, sys.stdin.readline().split()))

def main():
    read()
    mp = defaultdict(int)
    for val1 in c:
        for val2 in d:
            mp[val1 + val2] += 1
    print(sum(mp[v - val1 - val2] for val1 in a for val2 in b))

if __name__ == '__main__':
    main()



### FIXED CODE ###

import sys
from collections import defaultdict


def main():
    n, v = map(int, sys.stdin.readline().split())
    a = list(map(int, sys.stdin.readline().split()))
    b = list(map(int, sys.stdin.readline().split()))
    c = list(map(int, sys.stdin.readline().split()))
    d = list(map(int, sys.stdin.readline().split()))
    mp = defaultdict(int)
    for val1 in c:
        for val2 in d:
            mp[val1 + val2] += 1
    print(sum(mp[v - val1 - val2] for val1 in a for val2 in b))

if __name__ == '__main__':
    main()
#83b
n,a,b=map(int,input().split())
n=[str(i) for i in range(1,n+1)]
ans=0

for i in n:
    temp=[int(x) for x in list(str(i)) ]
    temp=sum(temp)
    if a<=temp<=b:
        ans+=i

print(ans)


### FIXED CODE ###

#83b
n,a,b=map(int,input().split())
n=[str(i) for i in range(1,n+1)]
ans=0

for i in n:
    temp=[int(x) for x in list(str(i)) ]
    temp=sum(temp)
    if a<=temp<=b:
        ans+=int(i)

print(ans)
D,N=map(int,input().split())
if D==0:
	if N=100:
		print(101)
	else:
		print(N)
elif D==1:
	if N=100:
		print(101*100)
	else:
		print(N*100)
	
elif D==2:
	if N=100:
		print(101*100*100)
	else:
		print(N*100*100)

### FIXED CODE ###

D,N=map(int,input().split())
if D==0:
	if N==100:
		print(101)
	else:
		print(N)
elif D==1:
	if N==100:
		print(101*100)
	else:
		print(N*100)
	
elif D==2:
	if N==100:
		print(101*100*100)
	else:
		print(N*100*100)
import sys
import numpy as np
from collections import Counter

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]


from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N = INT()
S = [[s for s in input().strip()] for _ in range(N)]

words = []
for s in S:
	s.sort()
	words.append(s)

words.sort()

ans = []
tmp = ''
num = -1
for w in words:
	#print(tmp , w, num)
	if tmp == w:
		#print('same')
		ans[num] += 1
		#print(ans)
	else:
		#print('different')
		tmp = w
		num+=1
		ans.append(1)
		#print(ans)
		
#print(ans)

count = 0
for a in ans:
	if a != 1: count += cmb(a, 2)

print(count)

### FIXED CODE ###

import sys
import numpy as np
from collections import Counter

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]


from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N = INT()
S = [[s for s in input().strip()] for _ in range(N)]

words = []
for s in S:
	s.sort()
	words.append(s)

words.sort()

ans = []
tmp = ''
num = -1
for w in words:
	#print(tmp , w, num)
	if tmp == w:
		#print('same')
		ans[num] += 1
		#print(ans)
	else:
		#print('different')
		tmp = w
		num+=1
		ans.append(1)
		#print(ans)
		
#print(ans)

count = 0
for a in ans:
	if a != 1: count += cmb(a, 2)

print(count)
import math
r = input()
m = r ** 2 * math.pi
l = r * 2 * math.pi
print('{:6f} {:.6f}'.format(m, l))

### FIXED CODE ###

import math
r = float(input())
m = r ** 2 * math.pi
l = r * 2 * math.pi
print('{:.6f} {:.6f}'.format(m, l))