Problem:
 Score : 500 points    Problem Statement We have N integers. The i -th number is A_i .  \{A_i\} is said to be pairwise coprime when GCD(A_i,A_j)=1 holds for every pair (i, j) such that 1\leq i < j \leq N .  \{A_i\} is said to be setwise coprime when \{A_i\} is not pairwise coprime but GCD(A_1,\ldots,A_N)=1 .  Determine if \{A_i\} is pairwise coprime, setwise coprime, or neither.  Here, GCD(\ldots) denotes greatest common divisor.      Constraints  2 \leq N \leq 10^6  1 \leq A_i\leq 10^6         Input Input is given from Standard Input in the following format:  N  A_1  \ldots  A_N       Output If \{A_i\} is pairwise coprime, print pairwise coprime ; if \{A_i\} is setwise coprime, print setwise coprime ; if neither, print not coprime .        Sample Input 1 3
3 4 5      Sample Output 1 pairwise coprime  GCD(3,4)=GCD(3,5)=GCD(4,5)=1 , so they are pairwise coprime.       Sample Input 2 3
6 10 15      Sample Output 2 setwise coprime  Since GCD(6,10)=2 , they are not pairwise coprime. However, since GCD(6,10,15)=1 , they are setwise coprime.       Sample Input 3 3
6 10 16      Sample Output 3 not coprime  GCD(6,10,16)=2 , so they are neither pairwise coprime nor setwise coprime.

Solution (Python):
import math
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)
    return divisors
N = int(input())
arr = list(map(int, input().split()))
M = max(arr)
arr.sort()
check = [0]*(M+1)
flg = True
for i in arr:
    for k in make_divisors(i):
        if check[k] != 0 and k != 1:
            flg = False
            break
        else:
            check[k] = 1
    if not flg:
        break
if flg:
    print('pairwise coprime')
    exit()
first = arr[0]
for i in range(1,N):
    first = math.gcd(first,arr[i])
if first == 1:
    print('setwise coprime')
else:
    print('not coprime')

Solution (Python):
from math import gcd

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

g = a[0]
for i in range(1, n):
    g = gcd(g, a[i])
    if g == 1:
        break
else:
    print('not coprime')
    exit()

ind = [-1] * (10**6)

prime = [2, 3, 5, 7]
for i in range(11, 10 ** 6, 2):
    j = 0
    flag = True
    while prime[j] * prime[j] <= i:
        if i % prime[j] == 0:
            flag = False
            break
        else:
            j += 1
    if flag:
        prime.append(i)

for i in range(len(prime)):
    ind[prime[i]] = i



tf = [False] * len(prime)

for i in a:
    for j in range(len(prime)):
        if i == 1:
            break
        if prime[j] * prime[j] > i:
            if tf[ind[i]]:
                print('setwise coprime')
                exit()
            tf[ind[i]] = True
            break

        if i % prime[j] == 0:
            if tf[j]:
                print('setwise coprime')
                exit()
            tf[j] = True
            while i % prime[j] == 0:
                i //= prime[j]

print('pairwise coprime')

Solution (Python):
from functools import reduce
from itertools import combinations
from math import gcd


def func(A):
    n = len(A) - len(set(A))
    if n > 0 and n+1 != A.count(1):
        return False
    is_A = [False] * (10**6+1)
    for a in A:
        is_A[a] = True
    n = 0
    for i in range(2, 10**6+1, 2):
        if is_A[i]:
            n += 1
    if n > 1:
        return False
    for i in range(3, 10**6+1, 2):
        n = 0
        for j in range(i, 10**6+1, i):
            if is_A[j]:
                n += 1
        if n > 1:
            return False
    return True


def solve():
    N = int(input())
    A = list(map(int, input().split()))
    if func(A):
        
        
        print('pairwise coprime')
    elif reduce(gcd, A) == 1:
        print('setwise coprime')
    else:
        print('not coprime')
    

if __name__ == '__main__':
    solve()

Solution (Python):
import math
n = int(input())
a = list(map(int, input().split()))


sosu = [1 for _ in range(10**6+1)]
sosu[0] = 0
sosu[1] = 1
i = 2
while i < len(sosu):
    j = i*2
    if sosu[i] == 0:
        i += 1
        continue
    while j < len(sosu):
        sosu[j] = 0
        j += i
    i += 1

sosus = []
for i in range(2, len(sosu)):
    if sosu[i]:
        sosus.append(i)

sosuset = set()
flag = 0
GCD = a[0]
for i in range(n-1, -1, -1):
    J = 0
    j = sosus[J]
    GCD = math.gcd(GCD, a[i])

    while j*j <= a[i]:
        if a[i]%j == 0 and j in sosuset:
            flag = 1
            break
        while a[i]%j == 0:
            a[i]//=j
            sosuset.add(j)
        J += 1
        j = sosus[J]
    if a[i] in sosuset:
        flag = 1
    if a[i] != 1:
        sosuset.add(a[i])


if GCD == 1 and flag == 0:
    print("pairwise coprime")
elif GCD == 1 and flag == 1:
    print("setwise coprime")
else:
    print("not coprime")

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = 10**6
mod = 10 ** 9 + 7 





N = INT()
A = LIST()
lim = 10**6+1
g = [[] for _ in range(lim+1)]
g[1].append(1)
for i in range(2, lim+1):
	if g[i] == []:
		for j in range(1, lim//i + 1):
			g[i*j].append(i)

num = [0]*(lim+1)

for a in A:
	if a == 1:
		continue
	for x in g[a]:
		if num[x]:
			break
		num[x] = 1

	else:
		continue
	break
else:
	print("pairwise coprime")
	exit()



def factorization(n):
	arr = []
	tmp = n
	for i in range(2, int(-(-n**0.5//1))+1):
		if tmp%i == 0:
			cnt = 0
			while tmp%i == 0:
				cnt += 1
				tmp //= i
			arr.append([i, cnt])
	if tmp != 1:
		arr.append([tmp, 1])
	if arr == []:
		arr.append([n, 1])
	return arr
	
dic = defaultdict(int)
for x, y in factorization(A[0]):
	dic[x]=y

for a in A[1:]:
	for x, y in dic.items():
		if a%x:
			dic[x] = 0
		else:
			dic[x] = min(y, a//x)

for x, y in dic.items():
	if x != 1 and y != 0:
		print("not coprime")
		break
else:
	print("setwise coprime")

Solution (Python):
from math import *
import fractions
import sys
import collections
import itertools
import pprint
from collections import deque
from heapq import *
import copy
input=sys.stdin.readline
N=int(input())
A=list(map(int,input().split()))
n = 10**6
d={}
pairflag=1
setflag=0
primes = set(range(2, n+1))
for i in range(2, int(n**0.5+1)):
    primes.difference_update(range(i*2, n+1, i))
primes=list(primes)

buf=[0]*(max(A)+10)
seen=[0]*(max(A)+10)
for i in range(N):
    if d.get(A[i])==None:
        d[A[i]]=1
    else:
        d[A[i]]=d[A[i]]+1

def ggcd(a,b):
    if(b==0):
        return a
    return ggcd(b,a%b)
for i in primes:
    cnt=0
    for j in range(i,10**6+1,i):
        if d.get(j)!=None:
            cnt=cnt+d[j]
    if cnt>1:
        pairflag=0
        break

num=A[0]
for i in range(1,N):
    num=ggcd(num,A[i])
if num==1:
    setflag=1
else:
    setflag=0

if pairflag==1:
    print("pairwise coprime")
elif setflag==1:
    print("setwise coprime")
else:
    print("not coprime")

"""
x=list(set(A))
for i in x:
    for j in range(2*i,10**6+1,i):
        if d.get(j)!=None:
            pairflag=0
            break
    if pairflag==0:
        break
print(pairflag)

"""

Solution (Python):
import math
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr


N=int(input())
A=list(map(int,input().split()))
count=0
for i in range(N):
    if A[i]==1:
        count+=1
a=A[0]
for i in range(1,N):
    a=math.gcd(a,A[i])
if N>=78500+count and a==1:
    print("setwise coprime")
elif N>=78500+count and a>1:
    print("not coprime")
else:
    flag=True
    num_list=[0 for i in range(10000000)]
    for i in range(N):
        if A[i]>1:
            list_=factorization(A[i])
            for b,d in list_:
                if num_list[b]!=0:
                    flag=False
                else:
                    num_list[b]+=1
    if flag==True and a==1:
        print("pairwise coprime")
    elif flag==False and a==1:
        print("setwise coprime")
    else:
        print("not coprime")

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

import math 

ans = a[0]
for i in range(1, n):
    ans = math .gcd(ans, a[i])

if ans!=1:
    
    print("not coprime")
    exit()
else:
    checked=[0]*(int(max(a))+1)
    
    for item in a:
        for j in range(1,int(item**0.5)+1):
            if item%j==0 and j*j<=item:
                if checked[j]==0:
                    if j!=1:
                        checked[j]+=1
                    
                    if j*j!=item:
                        if checked[item//j]==0:
                            checked[item//j]+=1
                        else:
                            
                            print("setwise coprime")
                            exit() 
                else:
                    
                    print("setwise coprime")
                    exit()
print("pairwise coprime")

Solution (Python):
import sys
import itertools

import time
import math
import heapq
from collections import defaultdict
from collections import Counter
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 10 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines



N = int(input())
A = list(map(int, input().split()))
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


MAX = 10 ** 6 + 2
is_prime = [True] * (MAX + 1)
is_prime[0] = False
is_prime[1] = False
i = 2
primes = []
cnt_a = Counter(A)
if cnt_a[1] == N:
    print('pairwise coprime')
    exit()
cnt_facts = defaultdict(int)
while i < MAX:
    if is_prime[i]:
        if cnt_a[i]:
            cnt_facts[i] += cnt_a[i]
        for j in range(i+i, MAX, i):
            is_prime[j] = False
            if cnt_a[j]:
                cnt_facts[i] += cnt_a[j]
        primes.append(i)
    i += 1
if cnt_facts and max(cnt_facts.values()) <= 1:
    print('pairwise coprime')
    exit()
setwise = False
g = A[0]
for a in A:
    g = gcd(g, a)
if g == 1:
    setwise = True

if setwise:
    print('setwise coprime')
if not setwise:
    print('not coprime')

Solution (Python):
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
input = sys.stdin.readline
INF = float("inf")


def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n = n // i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table



def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()

    P = [True]*1000010
    pairwise = True
    for a in A:
        if P[a] == False:
            pairwise = False
            break
        
        table = prime_decomposition(a)
        for p in table:
            n = 1
            while p*n <= len(P)-1:
                P[p*n] = False
                n += 1

    setwise = True
    if reduce(math.gcd, A) != 1:
        setwise = False

    if pairwise:
        print("pairwise coprime")
    elif setwise:
        print("setwise coprime")
    else:
        print("not coprime")



if __name__ == '__main__':
    main()

Solution (Python):
import math
NOTCOM = "not coprime"
SETWISE = "setwise coprime"
PAIRWISE = "pairwise coprime"

def calc_prime(N):
    prime, i = set(), 1
    while i * i <= N:
        if N % i == 0:
            yield i
            if i != N//i: yield N//i
        i += 1

def main():
    N = int(input())
    A = list(map(int, input().split()))
    A = list(set(A))
    cnt2 = 0
    cnt3 = 0
    allgcd = A[0]
    for a in A:
        allgcd = math.gcd(allgcd, a)
        if a % 2 == 0:
            cnt2 += 1
        if a % 3 == 0:
            cnt3 += 1
    if allgcd != 1:
        return NOTCOM
    
    if cnt2 >= 2 or cnt3 >= 2:
        return SETWISE

    allprime = set()
    for a in A:
        for t in calc_prime(a):
            if t in allprime and t != 1:
                return SETWISE
            allprime.add(t)
    return PAIRWISE

print(main())

Solution (Python):
import math
n = int(input())
a = list(map(int, input().split()))
v = 0
for x in a:
    v = math.gcd(x, v)
if v > 1:
    print("not coprime")
else:
    
    primes = []
    primer = [True for i in range(10**6+1)]
    for p in range(2, 10**6+1):
        if primer[p] == True:
            primes.append(p)
            for i in range(2, 10**6+1):
                if p*i > 10**6:
                    break
                else:
                    primer[p*i] = False
    counter = [0 for i in range(10**6+1)]
    for num in a:
        counter[num] += 1
    pair = True
    for p in primes:
        res = 0
        for j in range(1, 10**6+1):
            if p*j > 10**6:
                break
            else:
                res += counter[p*j]
        if res > 1:
            pair = False
            break
    if pair:
        print("pairwise coprime")
    else:
        print("setwise coprime")

Solution (Python):
import math
n = int(input())
a = [int(i) for i in input().split()]

chk = [0]*(10**6+1)

for i in range(n):
    
    
    
    chk[a[i]] += 1

flag = True

for i in range(2,10**6+1):
    
    kake = 1
    num = 0
    
    while i * kake <= 10**6:
        if chk[i*kake] >= 2:
            flag = False
            break
        
        if chk[i*kake] == 1:
            if num == 1:
                flag = False
                break
            num = 1
            
        kake += 1
gcd_num = math.gcd(a[0],a[1])
        
for i in range(n-2):
    gcd_num = math.gcd(gcd_num,a[i+2])
    
if flag == True:
    print("pairwise coprime")
elif gcd_num == 1:
    print("setwise coprime")
else:
    print("not coprime")

Solution (Python):
from math import gcd
import sys
sys.setrecursionlimit(1000000)

def main():
    N = int(input())
    A = list(map(int, input().split()))
    tmp = gcd(A[0],A[1])
    set_A = set(A)
    for i in range(2,N):
        tmp = gcd(tmp, A[i])

    if tmp != 1:
        print('not coprime')
        exit()
    max_A = max(A)
    ans = [False] * (max_A + 1)
    flag = True
    def divisor(n):
        ass = []
        for i in range(1,int(n**0.5)+1):
            if n%i == 0:
                ass.append(i)
                if ans[i]:
                    return False
                if i != 1:
                    ans[i] = True
                if i**2 == n:
                    continue
                if ans[n//i]:
                    return False
                ans[n//i] = True
                ass.append(n//i)
        if n != 1:
            ans[n] = True
        return True 
    for a in A:
        if not divisor(a):
            flag = False
            break

    if flag:
        print('pairwise coprime')
    else:
        print('setwise coprime')
    






if __name__ == "__main__":
    main()

Solution (Python):
import math

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr





N = int(input())
A_old = [int(hoge) for hoge in input().split()]
A = [a for a in A_old if a != 1]
Pairwise = False
Setwise = False
SOSUU = [0 for _ in range(10**6+10)]
A.sort()
Fail = False
G = A_old[0]
for a in A_old:
    G = math.gcd(G,a)
if G != 1:
    print("not coprime")
    exit()

if len(A) <= 80000:
    for a in A:
        Fact = factorization(a)
        for f in Fact:
            if f[0]==1:continue
            if SOSUU[f[0]] > 0:
                Fail = True
                break
            else:
                SOSUU[f[0]] += 1
        if Fail:
            break
    if not Fail:
        Pairwise = True

if Pairwise:
    print("pairwise coprime")
else:
    print("setwise coprime")

Solution (Python):
import math
def prime_numbers(x):
    if x < 2:
        return []
    prime_numbers = [i for i in range(x)]
    prime_numbers[1] = 0
    for prime_number in prime_numbers:
        if prime_number > math.sqrt(x):
            break
        if prime_number == 0:
            continue
        for composite_number in range(2 * prime_number, x, prime_number):
            prime_numbers[composite_number] = 0
    return [prime_number for prime_number in prime_numbers if prime_number != 0]
def soinnsuu(x):
    s = set()
    for i in primes:
        if i > int(math.sqrt(x)):
            break
        elif x % i == 0:
            while x % i == 0:
                x //= i
            s.add(i)
    if not x == 1:
        s.add(x)
    return s
from math import gcd
n = int(input())
a = list(map(int, input().split()))
g = 0
for i in range(n):
    g = gcd(g, a[i])
primes = prime_numbers(2000000)
cur = soinnsuu(a[0])
f = False
for i in range(1, n):
    s2 = soinnsuu(a[i])
    if len(cur & s2) >= 1:
        f = True
        break
    cur |= s2
if not f:
    print("pairwise coprime")
elif g == 1:
    print("setwise coprime")
else:
    print("not coprime")

Solution (Python):
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")

def max_gcd_pair(S):
    
    

    s = set(S)
    m = max(S)

    res = 0
    i = m

    while(i > 0):
        a = i
        cnt = 0
        while (a<=m): 
            if a in s:   
               cnt += 1
            a += i

        if cnt >= 2:  
            res = i
            break

        i = i -1 

    return res

n = int(input())
a = [int(x) for x in input().split()]

from collections import Counter

c = Counter(a)
flag = 1
for i in a:
    if c[i] > 1 and i != 1:
        flag = 0
if flag:
    if max_gcd_pair(a) <= 1:
        print('pairwise coprime')
        sys.exit()

import math
from functools import reduce

def gcd(*numbers):
    return abs(reduce(math.gcd, numbers))

if gcd(*a) == 1:
    print('setwise coprime')
    sys.exit()

else:
    print('not coprime')

Solution (Python):
import math
def makePrimes(x):
    if x < 2: return []

    primes = [i for i in range(x)]
    primes[1] = 0 

    
    for prime in primes:
        if prime > math.sqrt(x): break
        if prime == 0: continue
        for non_prime in range(2 * prime, x, prime): primes[non_prime] = 0

    return [prime for prime in primes if prime != 0]

primes = makePrimes(10**6)
prime_set = set()
def prime_factorization(n):
    tmp = n
    ret = True
    m = int(-(-n**0.5//1))+1
    for p in primes:
        if m < p:
            break
        if tmp%p==0:
            if p in prime_set:
                ret = False
            while tmp%p==0:
                tmp//=p
            prime_set.add(p)
    if tmp!=1:
        if tmp in prime_set:
                ret = False
        prime_set.add(tmp)
    return ret

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

pairwize = prime_factorization(A[0])
gcd = A[0]
for i in range(1,N):
    gcd = math.gcd(gcd,A[i])
    pairwize = pairwize and prime_factorization(A[i])

if pairwize:
    print("pairwise coprime")
elif gcd == 1:
    print("setwise coprime")
else:
    print("not coprime")

Solution (Python):


import re
import math
from collections import defaultdict,deque,Counter
from fractions import Fraction
import bisect
import itertools
from itertools import accumulate
from copy import deepcopy

import heapq
import random
import time
import os
import sys
from functools import lru_cache,reduce
readline=sys.stdin.readline
sys.setrecursionlimit(100000)
alp="abcdefghijklmnopqrstuvwxyz"
numbers="0123456789"
mod=int(10**9+7)
inf=int(10**19)
class Set():
    def __init__(self,A=[]):
        self.heap=[]
        self.dic=defaultdict(bool)
        self.size=0
        for a in A:self.add(a)
    
    def __str__(self):
        return str(self.heap)
    
    def add(self,x):
        if not self.find(x):
            heapq.heappush(self.heap,x)
            self.dic[x]=True
            self.size+=1

    def remove(self,x):
        if self.find(x):
            self.dic[x]=False
            self.size-=1

    def find(self,x):
        return self.dic[x]
    
    def top(self):
        while self.heap and self.dic[self.heap[0]]==False:
            heapq.heappop(self.heap)
        if self.heap:return self.heap[0]
        else:return None

    def pop(self):
        ret=None
        if self.heap:
            ret=self.top()
            self.remove(ret)
        return ret
class multiset():
    def __init__(self,A=[]):
        self.heap=[]
        self.dic=defaultdict(int)
        self.size=0
        for a in A:self.add(a)
    
    def __str__(self):
        return str(self.heap)
    
    def add(self,x):
        heapq.heappush(self.heap,x)
        self.dic[x]+=1
        self.size+=1

    def remove(self,x):
        if self.dic[x]>0:
            self.dic[x]-=1
            self.size-=1
    
    def count(self,x):
        return self.dic[x]

    def find(self,x):
        return self.dic[x]>0
    
    def top(self):
        while self.heap and self.dic[self.heap[0]]==0:
            heapq.heappop(self.heap)
        if self.heap:return self.heap[0]
        else:return None

    def pop(self):
        ret=None
        if self.heap:
            ret=self.top()
            self.remove(ret)
        return ret
class Edge():
    def __init__(self,x,y,val=1):
        self.x=x
        self.y=y
        self.val=val
class Point():
    def __init__(self,y,x):
        self.x=x
        self.y=y
class unionfind():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(n)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):
            self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def yn(b):print("yes" if b else "no")
def Yn(b):print("Yes" if b else "No")
def YN(b):print("YES" if b else "NO")
def ispow(a,b):
    now=b
    while now<a:
        now*=b
    return now==a
def getbin(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def getfacs(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod_>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def nextcomb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:return num
def getprimes(n):
    if n==0:return []
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    ret=[]
    for a in range(n+1):
        if(A[a]):ret.append(a)
    return ret
def isprime(num):
    if(num<=1):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def ifelse(b,t,f):return t if b else f
def factorize(n):
    b = 2
    ret=defaultdict(int)
    while b * b <= n:
        while n % b == 0:
            n //= b
            ret[b]+=1
        b+=1
    if n > 1:ret[n]+=1
    return ret
def inputintlist(row=1): 
    if row==1:
        ret=list(map(int,input().split()))
    else:
        ret=[None]*row
        for a in range(row):
            ret[a]=int(input())
    return ret
def inputfloatlist(row=1): 
    if row==1:
        ret=list(map(float,input().split()))
    else:
        ret=[None]*row
        for a in range(row):
            ret[a]=float(input())
    return ret
def istanchouzouka(A):
    f=True
    prev=min(A)-1
    for a in A:
        if prev>=a:
            f=False
        prev=a
    return f
def istanchouhigensyou(A):
    f=True
    prev=min(A)-1
    for a in A:
        if prev>a:
            f=False
        prev=a
    return f
def getallsum(A):
    s=sum(A)
    dp=defaultdict(int)
    dp[0]=1
    for a in range(0,len(A)):
        for b in range(s,-1,-1):
            if b-A[a]>=0:
                dp[b]+=dp[b-A[a]]
    return dp
def yuukoutomukou(edges):
    ret=deepcopy(edges)
    for edge in edges:
        if not edge.x==edge.y:
            ret.append(Edge(edge.y,edge.x,edge.val))
    return ret
def dijkstra(edges,V,start):
    from queue import PriorityQueue
    mincost=[inf]*V
    G=[[] for a in range(V)]
    for edge in edges:
        G[edge.x].append([edge.val,edge.y])
    Q=PriorityQueue()
    Q.put([0,start])
    while not Q.empty():
        nowcost,nowx=Q.get()
        if mincost[nowx]==inf:
            mincost[nowx]=nowcost
            for cost,y in G[nowx]:
                newcost=nowcost+cost
                Q.put([newcost,y])
    return mincost
def warshallfloyd(edges,V):
    mincost=[[inf for b in range(V)] for a in range(V)]
    for a in range(V):mincost[a][a]=0
    for edge in edges:
        mincost[edge.x][edge.y]=min(mincost[edge.x][edge.y],edge.val)
    for k in range(V):
        for s in range(V):
            for t in range(V):
                if mincost[s][k]==inf or mincost[k][t]==inf:continue
                mincost[s][t]=min(mincost[s][t],mincost[s][k]+mincost[k][t])
    return mincost
def bellemanford(edges,V,start):
    mincost=[inf]*V
    mincost[start]=0
    for _ in range(V):
        for edge in edges:
            if mincost[edge.x]==inf:continue
            mincost[edge.y]=min(mincost[edge.y],mincost[edge.x]+edge.val)
    return mincost
def getmd(x1,y1,x2,y2):return abs(x1-x2)+abs(y1-y2)
def geted(x1,y1,x2,y2):return math.sqrt((x1-x2)**2+(y1-y2)**2)
class fordfulkerson():
    def __init__(self,edges,V,s,t):
        self.V=V
        self.used=[False]*V
        self.G=[[] for a in range(V)]
        self.s=s
        self.t=t
        for edge in edges:
            self.G[edge.x].append({"x":edge.x,"y":edge.y,"cap":edge.val,"rev":len(self.G[edge.y])})
            self.G[edge.y].append({"x":edge.y,"y":edge.x,"cap":0,"rev":len(self.G[edge.x])-1})
    def dfs(self,v,t,f=inf):
        if v==t:return f
        self.used[v]=True
        for a in range(len(self.G[v])):
            x=self.G[v][a]["x"]
            y=self.G[v][a]["y"]
            cap=self.G[v][a]["cap"]
            rev=self.G[y][self.G[x][a]["rev"]]
            if self.used[y] or cap==0:continue
            f2=self.dfs(y,t,min(f,cap))
            if f2>0:
                self.G[v][a]["cap"]-=f2
                rev["cap"]+=f2
                return f2
        return 0
    def maxflow(self):
        flow=0
        while True:
            self.used=[False]*V
            zouka=self.dfs(self.s,self.t)
            if zouka==0:break
            flow+=zouka
        return flow
def zipsort(*args):
    ziplist=sorted(zip(*args))
    for a in range(len(args)):
        for b in range(len(ziplist)):
            args[a][b]=ziplist[b][a]
def zipreverse(*args):
    ziplist=list(zip(*args))
    rev=[]
    for a in range(len(ziplist)-1,-1,-1):
        rev.append(ziplist[a])
    for a in range(len(args)):
        for b in range(len(rev)):
            args[a][b]=rev[b][a]

def to10(A):
    ret=0
    for a in range(len(A)-1,-1,-1):
        ret+=X[a]*2**(N-1-a)
    return ret

N=int(input())
A=inputintlist()
s=defaultdict(bool)
f=True

for a in A:
    for b in factorize(a):
        if s[b]:
            f=False
        else:
            s[b]=True
    if not f:break
if f:
    print("pairwise coprime")
else:
    G=A[0]
    for a in A:
        G=math.gcd(a,G)
    if G==1:
        print("setwise coprime")
    else:
        print("not coprime")

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

from math import gcd
import sys

divisors = [False]*10**6
def make_divisors(n):
    i = 1
    while i*i <= n:
        if n % i == 0:
            if not divisors[i-1]:
                divisors[i-1] = True
            elif i != 1:
                return -1
            if i != n // i:
                if not divisors[n//i-1]:
                    divisors[n//i-1] = True
                else:
                    return -1
        i += 1
    return 1

GCD = A[0]
for i in range(1,N):
    GCD = gcd(A[i], GCD)
if GCD != 1:
    print("not coprime")
else:
    for a in A:
        if make_divisors(a) < 0:
            print("setwise coprime")
            sys.exit()
    print("pairwise coprime")

Solution (Python):

from math import gcd
from functools import reduce


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

lim = 10 ** 6 + 10
is_prime = [True] * (lim + 1)
is_prime[0] = False
is_prime[1] = False
min_factor = list(range(lim + 1))

for i in range(2, lim + 1):
    if is_prime[i]:
        for j in range(2 * i, lim + 1, i):
            is_prime[j] = False
            min_factor[j] = i

pairwise = True
appeared = set()
for v in X:
    while v > 1:
        div = min_factor[v]
        if div in appeared:
            pairwise = False
            break

        appeared.add(div)
        while v % div == 0:
            v //= div

if pairwise:
    print("pairwise coprime")
elif reduce(gcd, X) == 1:
    print("setwise coprime")
else:
    print("not coprime")

Solution (Python):
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return set(a)

import math
mod = 10 ** 9 + 7

n = int(input())
a = [int(i) for i in input().split()]
tmp = a[0]
set_v = a[0]
pairwise = True
prime_list = set([])
for i in range(1, n):
    prime = prime_factorize(a[i])
    set_v = math.gcd(set_v, a[i])
    for p in prime:
        if p in prime_list:
            pairwise = False
        prime_list.add(p)
if pairwise == True:
    ans = 'pairwise coprime'
elif set_v == 1:
    ans = 'setwise coprime'
else:
    ans = 'not coprime'
print(ans)