Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

h,w=map(int,input().split())
s=[list(input()) for _ in range(h)]
l=[[0]*w for _ in range(h)]
r=[[0]*w for _ in range(h)]
u=[[0]*w for _ in range(h)]
d=[[0]*w for _ in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j]=="#":
            continue
        if j==0:
            l[i][j]=1
        else:
            l[i][j]=l[i][j-1]+1
        if j==w-1:
            r[i][j]=1
        else:
            r[i][j]=r[i][j+1]+1
        if i==0:
            u[i][j]=1
        else:
            u[i][j]=u[i-1][j]+1
for i in range(h-1,-1,-1):
    for j in range(w-1,-1,-1):
        if s[i][j]=="#":
            continue
        if j==w-1:
            r[i][j]=1
        else:
            r[i][j]=r[i][j+1]+1
        if i==h-1:
            d[i][j]=1
        else:
            d[i][j]=d[i+1][j]+1
ans=0
for i in range(h):
    for j in range(w):
        ans=max(ans,l[i][j]+r[i][j]+u[i][j]+d[i][j]-3)
print(ans)


### FIXED CODE ###

h,w=map(int,input().split())
s=[list(input()) for _ in range(h)]
l=[[0]*w for _ in range(h)]
r=[[0]*w for _ in range(h)]
u=[[0]*w for _ in range(h)]
d=[[0]*w for _ in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j]=="#":
            continue
        if j==0:
            l[i][j]=1
        else:
            l[i][j]=l[i][j-1]+1
        if j==w-1:
            r[i][j]=1
        else:
            r[i][j]=r[i][j+1]+1
        if i==0:
            u[i][j]=1
        else:
            u[i][j]=u[i-1][j]+1
for i in range(h-1,-1,-1):
    for j in range(w-1,-1,-1):
        if s[i][j]=="#":
            continue
        if j==w-1:
            r[i][j]=1
        else:
            r[i][j]=r[i][j+1]+1
        if i==h-1:
            d[i][j]=1
        else:
            d[i][j]=d[i+1][j]+1
ans=0
for i in range(h):
    for j in range(w):
        ans=max(ans,l[i][j]+r[i][j]+u[i][j]+d[i][j]-3)
print(ans)
### BUGGY CODE ###

# 正解ではない

from queue import PriorityQueue

q = PriorityQueue()


def main():
    H, W = map(int, input().split())
    Ch, Cw = map(int, input().split())
    Dh, Dw = map(int, input().split())
    S = [list(input()) for i in range(H)]
    q.put((0, (Ch - 1, Cw - 1)))

    answer = resolve(S, (Dh - 1, Dw - 1), H, W)
    print(answer)


def resolve(S, D, H, W):
    while not q.empty():
        worp_count, (x, y) = q.get()
        S[x][y] = '/'

        if (x, y) == D:
            return worp_count

        for i, j in [(x - 1, y), (x + 1, y), (x, y - 1), (x, y + 1)]:
            if 0 <= i < H and 0 <= j < W and S[i][j] in ('.', '1'):
                q.put((worp_count, (i, j)))
                S[i][j] = '0'

        for i, j in [(x + a, y + b) for a in range(-2, 3) for b in range(-2, 3)]:
            if 0 <= i < H and 0 <= j < W and S[i][j] == '.':
                q.put((worp_count + 1, (i, j)))
                S[i][j] = '1'

    return -1


if __name__ == "__main__":
    main()


### FIXED CODE ###

from collections import deque


def main():
    H, W = map(int, input().split())
    Ch, Cw = map(int, input().split())
    Dh, Dw = map(int, input().split())
    S = [list(input()) for _ in range(H)]
    d = [[-1 for _ in range(W)] for _ in range(H)]

    q = deque([])
    q.appendleft((0, Ch - 1, Cw - 1))

    while len(q):
        worp_count, x, y = q.popleft()

        if d[x][y] != -1:
            continue
        d[x][y] = worp_count

        for i, j in ((a, b) for a in range(-2, 3) for b in range(-2, 3)):
            nx = x + i
            ny = y + j
            if 0 <= nx < H and 0 <= ny < W and S[nx][ny] == '.':
                if i == 0 and j == 0:
                    continue
                elif abs(i) + abs(j) == 1:
                    q.appendleft((worp_count, nx, ny))
                else:
                    q.append((worp_count + 1, nx, ny))

    print(d[Dh - 1][Dw - 1])


if __name__ == "__main__":
    main()
### BUGGY CODE ###

import sys

Num = int(sys.stdin.readline().rstrip())
list_stu_Num = list(sys.stdin.readline().rstrip().split())
list_attend_stu = []
list_stu_Serial_Num = list(range(1, Num + 1))
list_stu_Num_index = list(range(Num))
for i in list_stu_Serial_Num:
    for l in list_stu_Num_index:
        if list_stu_Num[l] == str(i):
            list_attend_stu.append(l + 1)
            break
print(*list_attend_stu)

### FIXED CODE ###

import sys
import numpy as np

Num = int(sys.stdin.readline().rstrip())
list_stu_Num = list(sys.stdin.readline().rstrip().split())
list_stu_Num_int = [int(s) for s in list_stu_Num]
print(*np.argsort(list_stu_Num_int) + 1)
### BUGGY CODE ###

def totalcost_recur(i,cost,N,lookup):
  if i>=N:
    return 0
  if i in lookup:
      return lookup[i]
  option1 = abs(cost[i]-cost[i+1]) + totalcost_recur(i+1,cost,N,lookup)
  ans = option1
  if i+2<=N:
    option2 = abs(cost[i]-cost[i+2]) + totalcost_recur(i+2,cost,N,lookup)
    ans = min(option2,ans)
  lookup[i] = ans
  return ans



def totalcost_dp(cost,N,k):
    dp = [0]*(N+1)
    dp[1] = 0
    
    
    for i in range(2,N+1):
        ans = float('inf')
        for j in range(1,k+1):
            if i-j < 1:
                break
            option = dp[i-j]+abs(cost[i]-cost[i-j])
            ans = min(ans,option)
        
        dp[i] = ans
        

    return dp[N]


n ,k= map(int,input().split())
cost = list(map(int,input().split()))
cost = [0]+cost
lookup = {}

print(totalcost_dp(cost,n,k))

### FIXED CODE ###


def totalcost_dp(cost,N,k):
    dp = [float('inf')]*(N+1)
    dp[1] = 0
    
    
    for i in range(1,N+1):
        
        for j in range(i+1,k+i+1):
            if j < N+1:
                dp[j] = min(dp[j],dp[i]+abs(cost[i]-cost[j]))
                
    return dp[N]


n ,k= map(int,input().split())
cost = list(map(int,input().split()))
cost = [0]+cost
print(totalcost_dp(cost,n,k))
### BUGGY CODE ###

num = 0
s = input()
k = int(input())
for _ in range(k):
  inp = input()
  if inp[0] == "1":
    num += 1
    num %= 2
  else:
    if (inp[2] == "1" and num == 0) or (inp[2] == "2" and num == 1):
      s = inp[4] + s
    else:
      s = s + inp[4]
if num:
      print(s[::-1])
else:
  print(s)

### FIXED CODE ###

num = 0
s = input()
k = int(input())
pre = ""
out = ""
for _ in range(k):
  inp = input()
  if inp[0] == "1":
    num += 1
    num %= 2
  else:
    if (inp[2] == "1" and num == 0) or (inp[2] == "2" and num == 1):
      pre = pre + inp[4]
    else:
      out = out + inp[4]
if num:
      print(out[::-1] + s[::-1] + pre)
else:
  print(pre[::-1] + s + out)
### BUGGY CODE ###

n = int(input())
s = input()
cnt = 0



for i in range(n):
    for j in range(1, n):
        for k in range(3, n):
            if (j - i != k - j) & (i < j < k):
                if (s[i] != s[j]) & (s[j] != s[k]) & (s[k] != s[i]):
                    cnt += 1
print(cnt)

### FIXED CODE ###

n = int(input())
s = list(input())
cnt = 0

cnt = s.count("R") * s.count("B") * s.count("G")
# j - i = k -j を求める。
sub = 0 
for i in range(n):
    for j in range(i, n):
        k = 2 * j - i
        if k <= n - 1:
            if (s[i] != s[j]) and (s[j] != s[k]) and (s[i] != s[k]):
                sub += 1

print(cnt-sub)
### BUGGY CODE ###

k,s=map(int,input().split())
ans=0
for i in range(k+1):
  for j in range(k+1):
    for h in range(k+1):
      if i+j+h==s:
        ans+=1
print(ans)


### FIXED CODE ###

k,s=map(int,input().split())
ans=0
def als(n):
  if 0<=n<=k:
    return n+1
  elif k+1<=n<=2*k:
    return 2*k+1-n
  else:
    return 0
for i in range(k+1):
  ans+=als(s-i)
print(ans)
### BUGGY CODE ###

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

X = int(input())
di = make_divisors(X)
for i in range(len(di)):
    k = di[i]
    for b in range(-di[-1], di[-1] + 1):
        val = 5 * k * b ** 4 + 10 * k ** 2 * b ** 3 + 10 * k ** 3 * b ** 2 + 5 * k ** 4 * b + k ** 5 - X
        if val == 0:
            a = k + b
            print(a, b)
            exit()


### FIXED CODE ###

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

X = int(input())
di = make_divisors(X)
for i in range(len(di)):
    k = di[i]
    for b in range(-200, 201):
        val = 5 * k * b ** 4 + 10 * k ** 2 * b ** 3 + 10 * k ** 3 * b ** 2 + 5 * k ** 4 * b + k ** 5 - X
        if val == 0:
            a = k + b
            print(a, b)
            exit()
### BUGGY CODE ###

n=int(input())
a=sorted([int(i) for i in input().split()])
cnt=0
while True:
    odd=[i for i in a if i%2==1]
    even=[i for i in a if i%2==0]
    if len(even)==0:
        break
    maxi=even[-1]
    even=[i*3 for i in even[0:-1]]
    even.append(maxi//2)
    a=odd+even
    cnt+=1
print(cnt)

### FIXED CODE ###

n=int(input())
a=[int(i) for i in input().split()]
cnt=0
for i in range(n):
    while a[i]%2==0:
        a[i]=a[i]//2
        cnt+=1
print(cnt)
### BUGGY CODE ###

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

a.sort()

cnt = [0]*(a[-1]+1)
uq = []

for i in a:
    cnt[i] += 1

for i in range(a[-1]+1):
    if cnt[i] == 1:
        uq.append(i)

cnt = [0]*(a[-1]+1)
cnt1 = 0


a = list(set(a))



for i in a:
    for j in range(2, a[-1]+1):
        if i*j <= a[-1]:
            cnt[i*j] = 1


for i in uq:
    if cnt[i] == 0:
        cnt1 += 1

print(cnt1)


### FIXED CODE ###

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

A = max(a)

cnt = [0]*(A+1)
uq = []

for i in a:
    cnt[i] += 1

for i in range(A+1):
    if cnt[i] == 1:
        uq.append(i)

cnt = [0]*((10**6)+1)
cnt1 = 0


a = list(set(a))

# for i in a:
#     for j in range(2,A+1):
#         if i*j<=A+1:
#             cnt[i*j] = 1

for elem in a:
    for m in range(elem * 2, (10 ** 6) + 1, elem):
        cnt[m] = 1

for i in uq:
    if cnt[i] == 0:
        cnt1 += 1

print(cnt1)
### BUGGY CODE ###

def abp(a, b, p):
    if b == 0:
        return 1
    if b % 2 == 0:
        tmp = abp(a, b // 2, p)
        return (tmp * tmp) % p
    if b % 2 == 1:
        return (a * abp(a, b - 1, p)) % p

def nCr(n, r, p):
    total = 1
    for i in range(r):
        total *= (n - i) * abp(r - i, p - 2, p)
        total %= p
    return total

n, a, b = map(int, input().split())
p = 1000000007
ret = abp(2, n, p) - nCr(n, a, p) - nCr(n, b, p) - 1
print(ret % p)


### FIXED CODE ###

def abp(a, b, p):
    if b == 0:
        return 1
    if b % 2 == 0:
        tmp = abp(a, b // 2, p)
        return (tmp * tmp) % p
    if b % 2 == 1:
        return (a * abp(a, b - 1, p)) % p

def nCr(n, r, p):
    total = 1
    for i in range(r):
        total *= (n - i) * abp(r - i, p - 2, p)
        total %= p
    return total

n, a, b = map(int, input().split())
p = 1000000007
ret = abp(2, n, p) - nCr(n, a, p) - nCr(n, b, p) - 1
print(ret % p)
### BUGGY CODE ###

from heapq import heapify, heapreplace

N, M = map(int, input("").split(" "))

A = map(int, input("").split(" "))
A = list(A)
heapify(A)

for i in range(M):
    B, C = map(int, input("").split(" "))

    c = 0
    for j in range(B):
        if A[0] < C:
            heapreplace(A, C)
            c += 1
        else:
            break

c = 0
for a in A:
    c += a

print(c)


### FIXED CODE ###

N, M = map(int, input("").split(" "))

A = map(int, input("").split(" "))
A = list(A)
A.sort()

potentials = []
for i in range(M):
    B, C = map(int, input("").split(" "))

    potentials.append((B, C))

potentials.sort(key=lambda x: x[1], reverse=True)

c = 0
for p in potentials:
    for b in range(p[0]):
        if p[1] > A[c]:
            A[c] = p[1]
            c += 1
            if c >= len(A):
                break
        else:
            break
    if c >= len(A):
        break

print(sum(A))
### BUGGY CODE ###

if __name__=="__main__":
    N, K = map(int, input().split(' '))
    _town_list = input().split(' ')
    town_list = [int(n) for n in _town_list]

    next_town = town_list[0]
    visited_town = [1]
    visited_town.append(next_town)
    counter = 1

    while True:
        counter += 1
        next_town = town_list[next_town-1]
        if counter == K:
            print(next_town)
            break
        if next_town in visited_town:
            repeated_town_idx = visited_town.index(next_town)
            loop_num = counter - repeated_town_idx
            print(visited_town[(K-repeated_town_idx)%loop_num + repeated_town_idx])
            break
        visited_town.append(next_town)

### FIXED CODE ###

if __name__=="__main__":
    N, K = map(int, input().split(' '))
    _town_list = input().split(' ')
    town_list = [int(n) for n in _town_list]

    next_town = town_list[0]
    visited_town = set()
    visited_town.add(1)
    visited_town.add(next_town)
    lst_visited_town = [1]
    lst_visited_town.append(next_town)
    counter = 1

    while True:
        counter += 1
        next_town = town_list[next_town-1]
        if counter == K:
            print(next_town)
            break
        if next_town in visited_town:
            repeated_town_idx = lst_visited_town.index(next_town)
            loop_num = counter - repeated_town_idx
            print(lst_visited_town[(K-repeated_town_idx)%loop_num + repeated_town_idx])
            break
        lst_visited_town.append(next_town)
        visited_town.add(next_town)
### BUGGY CODE ###

N = int(input())
s = []
for _ in range(N):
    s.append(input())

def isAnagram(str1,str2):
    str1 = str1.lower()
    str2 = str2.lower()
    str1 = sorted(str1)
    str2 = sorted(str2)
    return str1 == str2

count = 0

for n in range(N):
    for i in range(n+1, N):
        if isAnagram(s[n], s[i]):
            count += 1

print(count)

### FIXED CODE ###

N = int(input())
s = []
for _ in range(N):
    s.append(''.join(sorted(input().lower())))

l = {}
for n in range(N):
    if s[n] in l:
        l[s[n]] += 1
    else :
        l[s[n]] = 1

print(sum(l[k] * (l[k]-1) // 2 for k in l))
### BUGGY CODE ###

import copy

H,W = map(int,input().split())

A = []

for i in range(H):

    a = input()
    la = list(a)
    A.append(la)

flag = True
cnt = 1

#print (A)

while flag:


    flag = False

    OA = copy.deepcopy(A)

    for i in range(H):

        for j in range(W):


            if OA[i][j] != ".":

                if i-1 >= 0:
                    
                    if OA[i-1][j] == ".":
                        A[i-1][j] = cnt
                        flag = True

                if i+1 < H:
                    
                    if OA[i+1][j] == ".":
                        A[i+1][j] = cnt
                        flag = True

                if j-1 >= 0:
                    
                    if OA[i][j-1] == ".":
                        A[i][j-1] = cnt
                        flag = True

                if j+1 < W:

                    #print (j+1)
                    
                    if OA[i][j+1] == ".":
                        A[i][j+1] = cnt
                        flag = True

    if flag:
        cnt += 1
    #print (OA)
    #print (A)
    #print (cnt)


print (cnt-1)

    

                    


### FIXED CODE ###


"""
メモ型再起？
ダイクストラじゃあきつそう
1sec!?

各点高々1回しか選ばれない工夫が必要
qにいれて少しづつ進めてく？
→各点高々4回しか選択されない
"""


H,W = map(int,input().split())

A = []
q = []

for i in range(H):

    a = list(input())
    A.append(a)

    for j in range(W):
        if a[j] == "#":
            q.append([i,j])

ans = 0
while len(q) > 0:

    #print (q)
    
    nq = []
    flag = False

    for i,j in q:
        if i > 0 and A[i-1][j] == ".":
            A[i-1][j] = "#"
            nq.append([i-1,j])
            flag = True
        if i < H-1 and A[i+1][j] == ".":
            A[i+1][j] = "#"
            nq.append([i+1,j])
            flag = True
        if j > 0 and A[i][j-1] == ".":
            A[i][j-1] = "#"
            nq.append([i,j-1])
            flag = True
        if j < W-1 and A[i][j+1] == ".":
            A[i][j+1] = "#"
            nq.append([i,j+1])
            flag = True
    q = nq
    if flag:
        ans += 1


print (ans)
### BUGGY CODE ###

def main() :
    N = int(input())

    # 式変形していいかんじに下ごしらえして、
    # 2変数分のループで全探索する。O(3500^2)なら間に合うはず。

    for h in range(1,3501) :
        for n in range(1,3501) :
            if ((4*h*n - N*n - N*h) == 0) :
                continue

            omega = (N * h * n * 1.0) / ((4*h*n - N*n - N*h) * 1.0)
            if (omega.is_integer() == True and omega >= 0) :
                print(h,n,int(omega))
                return

main()

### FIXED CODE ###

def main() :
    N = int(input())
    # N = float(input())

    # 式変形していいかんじに下ごしらえして、
    # 2変数分のループで全探索する。O(3500^2)なら間に合うはず。

    # for h in range(1,3501) :
    for h in range(1,3500) :
        # 組み合わせでみればいいので1からじゃなくてよい
        for n in range(h,3501) :
            bo = 4*h*n - N*n - N*h
            if (bo == 0) :
                continue

            omega = (N * h * n) / bo * 1.0
            if (omega > 0 and omega.is_integer() == True) :
                print(h,n,int(omega))
                return

main()
### BUGGY CODE ###

def Exponential(x):

    ans = 0
    if x == 1:
        ans = 1
    else:
        for i in range(1, x + 1):
            for w in range(2, x + 1):
                if i ** w <= x:
                    ans = max(ans, i ** w)

    return ans

def main():
    x = int(input())
    print(Exponential(x))

if __name__ == '__main__':
    main()

### FIXED CODE ###

def Exponential(x):

    ans = 0
    if x == 1:
        ans = 1
    else:
        for i in range(1, x + 1):
            for w in range(2, x + 1):
                if i ** w > x:
                    break
                else:
                    ans = max(ans, i ** w)

    return ans

def main():
    x = int(input())
    print(Exponential(x))

if __name__ == '__main__':
    main()
### BUGGY CODE ###

n=int(input())
p=1
for i in range(1,n+1):
  p=p*i
print(p%1000000007)

### FIXED CODE ###

import math
print(math.factorial(int(input()))%(10**9+7))
### BUGGY CODE ###

N,M = map(int,input().split())
A=[int(n) for n in input().split()]
A.sort()
def insert_sort(arr):
    for i in range(1, len(arr)):
        j = i - 1
        ele = arr[i]
        while arr[j] > ele and j >= 0:
            arr[j + 1] = arr[j]
            j -= 1
        arr[j + 1] = ele
    return arr
        
for _ in range(M):
    A[-1] = A[-1]//2
    A = insert_sort(A)
print(sum(A))

### FIXED CODE ###

import heapq
N,M = map(int,input().split())
H=[]
for i in input().split():
    heapq.heappush(H,-int(i))
for i in range(M):
    a = heapq.heappop(H)
    heapq.heappush(H,-(-a//2))
print(-sum(H))
### BUGGY CODE ###

def calc_lcs(X, Y):
    max_lcs = 0
    m = len(X)
    n = len(Y)
    X = ' ' + X
    Y = ' ' + Y
    c = [[0]*1001 for i in range(1000+1)]
    for i in range(1, m+1):
        for j in range(1, n+1):
            if X[i] == Y[j]:
                c[i][j] = c[i - 1][j - 1] + 1
            elif c[i - 1][j] >= c[i][j - 1]:
                c[i][j] = c[i - 1][j]
            else:
                c[i][j] = c[i][j - 1]
            max_lcs = max(max_lcs, c[i][j])
    return max_lcs


if __name__ == '__main__':
    # ??????????????\???
    num = int(input())
    # X = 'abcbdab'
    # Y = 'bdcaba'

    for _ in range(num):
        X = input()
        Y = input()

        # ???????????????
        result = calc_lcs(X, Y)

        # ???????????¨???
        print(result)

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_10_C

最長共通部分列
"""


c = []
def prep_array(X, Y):
    global c
    """ 値が0の2次元配列を用意する。サイズは入力データの最大値を想定して縦横(1000+1)以上必要。 """
    # from array import array
    # c = [array('I', [0] * (len(X)+1)) for _ in range(len(Y)+1)]  #  arrayで用意
    c = [[0]*(len(Y)+2) for _ in range(len(X)+2)] #  リストで用意
    return c


def check_max(array):
    """ 2次元配列の中の最大の値を返す """
    max_lcs = 0
    for row in array:
        temp_max = max(row)
        if temp_max > max_lcs:
            max_lcs = temp_max
    return max_lcs


def calc_lcs4(X, Y, c):
    """
    Y[j]のアクセス方法を変更
    リストの値を一旦変数に保存するように変更
    最長共通部分長を関数内で計算するように変更
    4/5 のテストデータを使用してプロファイリングすると実効時間は 5.6秒
    """
    X = ' ' + X
    Y = ' ' + Y
    m = len(X)
    n = len(Y)
    max_lcs = 0

    pre_row = c[0]
    for i in range(1, m):
        row = c[i]
        XX = X[i]
        for j, YY in enumerate(Y):
            if XX == YY:
                pr_j1 = pre_row[j - 1]
                row[j] = pr_j1 + 1
                if pr_j1+1 > max_lcs:
                   max_lcs = pr_j1 + 1
            else:
                pr_j = pre_row[j]
                r_j1 = row[j-1]
                if pr_j >= r_j1:
                    row[j] = pr_j
                else:
                    row[j] = r_j1
        pre_row = row
    return max_lcs


if __name__ == '__main__':
    # データの入力
    num = int(input())
    #f = open('input.txt')
    #num = int(f.readline())

    for _ in range(num):
        X = input().strip()
        Y = input().strip()

        # 処理の実行
        result = calc_lcs4(X, Y, prep_array(X, Y))

        # 結果の表示
        print(result)
### BUGGY CODE ###

k,s=map(int,input().split())
l=list(range(k+1))
count=0
for i in l:
    for j in l:
        k=s-i-j
        if l.count(k)==1:
            count+=1
            
print(count)

### FIXED CODE ###

k,s=map(int,input().split())
l=list(range(k+1))
count=0
for i in l:
    for j in l:
        q=s-i-j
        if 0<=q<=k:
            count+=1
            
print(count)
### BUGGY CODE ###

def main():
    S = str(input())
    K = int(input())

    N = len(S)
    lst = []
    lst_append = lst.append
    s = set()
    s_add = s.add
    for i in range(N):
        for j in range(i + 1, N + 1):
            if S[i:j] in s:
                continue
            else:
                s.add(S[i:j])
                lst_append(S[i:j])

    lst.sort()
    print (lst[K - 1])
    # print (lst)

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    S = str(input())
    K = int(input())
    N = len(S)

    tmp = [[] for _ in range(26)]
    for i in range(N):
        tmp[ord(S[i]) - ord('a')].append(i)

    lst = []
    lst_append = lst.append
    s = set()
    s_add = s.add
    for num in tmp:
        for i in num:
            for j in range(i + 1, min(N, i + K) + 1):
                if S[i:j] in s:
                    continue
                else:
                    s_add(S[i:j])
                    lst_append(S[i:j])
        if len(s) >= K:
            lst.sort()
            print (lst[K - 1])
            # print (lst)
            return

if __name__ == '__main__':
    main()
### BUGGY CODE ###

import collections
N = int(input())
A = list(map(int, input().split()))


def prime_factorize(n):
    r = set()
    while n % 2 == 0:
        r.add(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            r.add(f)
            n //= f
        else:
            f += 2
    if n != 1:
        r.add(n)
    return r


d = [0]*10**6
a1 = collections.Counter([])
a2 = collections.Counter(prime_factorize(A[0]))
for a in A:
    tmp = prime_factorize(a)
    aa = collections.Counter(tmp)
    a1 += aa
    a2 &= aa
if a2:
    print('not coprime')

elif a1.most_common()[0][1] >= 2:
    print('setwise coprime')
else:
    print('pairwise coprime')

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))


def prime_factorize(n):
    r = set()
    while n % 2 == 0:
        r.add(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            r.add(f)
            n //= f
        else:
            f += 2
    if n != 1:
        r.add(n)
    return r


j = 0
a1 = set()
a2 = prime_factorize(A[0])
for a in A[1:]:
    tmp = prime_factorize(a)
    if a1 & tmp:
        j = 1
    a1 |= tmp
    a2 &= tmp
if a2:
    print('not coprime')
elif j:
    print('setwise coprime')
else:
    print('pairwise coprime')