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):
from math import gcd, sqrt

def Divisor_Set(n):
    s = set()
    for i in range(1, int(sqrt(n))+2):
        if n%i == 0:
            s.add(i)
            s.add(n//i)
    return s

def main():
    n = int(input())
    a = list(map(int, input().split()))
    f = True
    divset = set()
    for v in a:
        st = Divisor_Set(v)
        st.remove(1)
        for el in st:
            if el in divset:
                f = False
                break
            divset.add(el)
        if not f:
            break
    if f:
        print("pairwise coprime")
    else:
        all_gcd = a[0]
        for i in range(1, n):
            all_gcd = gcd(all_gcd, a[i])
        if all_gcd == 1:
            print("setwise coprime")
        else:
            print("not coprime")

if __name__ == "__main__":
    main()

Solution (Python):
import sys

def gcd(a, b):
      a, b = max(a, b), min(a, b)
      while a % b > 0:
            a, b = b, a % b
      return b

def solve():
      input = sys.stdin.readline
      N = int(input())
      A = [int(a) for a in input().split()]
      L = max(A)
      count = [0] * (L + 1)
      isPrime = [False] * (L + 1)
      gcdA = A[0]
      for a in A[1:]:
            gcdA = gcd(gcdA, a)
            count[a] += 1
      if gcdA > 1:
            print("not coprime")
            return 0
      
      for i in range(2, L + 1):
            if not isPrime[i]:
                  c = 0
                  k = i
                  while k <= L:
                        isPrime[i] = True
                        c += count[k]
                        k += i
                  if c > 1:
                        print("setwise coprime")
                        return 0
      print("pairwise coprime")
      return 0

if __name__ == "__main__":
      solve()

Solution (Python):
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n + 1)]
        self.rank = [0] * (n + 1)
        self.size = [1] * (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
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

import sys
import math
import copy
from heapq import heappush, heappop, heapify
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter



input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = float("inf")
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)


def gcd(a, b):
    while b: a, b = b, a % b
    return a


def isPrimeMR(n):
    d = n - 1
    d = d // (d & -d)
    L = [2]
    for a in L:
        t = d
        y = pow(a, t, n)
        if y == 1: continue
        while y != n - 1:
            y = (y * y) % n
            if y == 1 or t == n - 1: return 0
            t <<= 1
    return 1


def findFactorRho(n):
    m = 1 << n.bit_length() // 8
    for c in range(1, 99):
        f = lambda x: (x * x + c) % n
        y, r, q, g = 2, 1, 1, 1
        while g == 1:
            x = y
            for i in range(r):
                y = f(y)
            k = 0
            while k < r and g == 1:
                ys = y
                for i in range(min(m, r - k)):
                    y = f(y)
                    q = q * abs(x - y) % n
                g = gcd(q, n)
                k += m
            r <<= 1
        if g == n:
            g = 1
            while g == 1:
                ys = f(ys)
                g = gcd(abs(x - ys), n)
        if g < n:
            if isPrimeMR(g):
                return g
            elif isPrimeMR(n // g):
                return n // g
            return findFactorRho(g)


def primeFactor(n):
    i = 2
    ret = {}
    rhoFlg = 0
    while i * i <= n:
        k = 0
        while n % i == 0:
            n //= i
            k += 1
        if k: ret[i] = k
        i += 1 + i % 2
        if i == 101 and n >= 2 ** 20:
            while n > 1:
                if isPrimeMR(n):
                    ret[n], n = 1, 1
                else:
                    rhoFlg = 1
                    j = findFactorRho(n)
                    k = 0
                    while n % j == 0:
                        n //= j
                        k += 1
                    ret[j] = k

    if n > 1: ret[n] = 1
    if rhoFlg: ret = {x: ret[x] for x in sorted(ret)}
    return ret


def solve():
    n = getN()
    nums = getList()
    d = defaultdict(int)
    for num in nums:
        res = primeFactor(num)
        for k in res.keys():
            d[k] += 1

    dup = 0
    over = 0
    for dv in d.values():
        if dv == n:
            over += 1
            break
        if dv > 1:
            dup += 1

    if over:
        print("not coprime")
        return
    if dup:
        print("setwise coprime")
        return

    print("pairwise coprime")
    return
    
def main():
    n = getN()
    for _ in range(n):
        solve()

    return
if __name__ == "__main__":
    
    solve()

Solution (Python):
from math import gcd
from functools import reduce
from collections import Counter
from itertools import chain



def prime_factors(n):
    i = 2
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            while n % i == 0:
                n //= i
            yield i
    if n > 1:
        yield n


def solve(A):
    d = reduce(gcd, A)
    if d != 1:
        return 'not coprime'

    A.sort()

    s = set()
    for a in A:
        for p in prime_factors(a):
            if p in s:
                return 'setwise coprime'
            else:
                s.add(p)

    return 'pairwise coprime'


if __name__ == '__main__':
    N = int(input())
    A = list(map(int,input().split()))

    print(solve(A))

Solution (Python):


import os,sys
from io import BytesIO, IOBase
from collections import Counter

def main():
    n = int(input())
    arr = list(map(int,input().split()))
    x = max(arr)
    sieve = [[] for _ in range(x+1)]
    lst = [0]*(x+1)
    for i in range(2,x+1):
        if lst[i]:
            continue
        lst[i] = 1
        sieve[i].append(i)
        y = 2*i
        while y <= x:
            lst[y] = 1
            sieve[y].append(i)
            y += i
    pr = Counter()
    for i in arr:
        for x in sieve[i]:
            pr[x] += 1
    fl = 0
    fl1 = 0
    for p in pr:
        if pr[p] > 1:
            fl = 1
        if pr[p] == n:
            fl1 = 1
    if not fl:
        print('pairwise coprime')
    elif not fl1:
        print('setwise coprime')
    else:
        print('not coprime')




BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == '__main__':
    main()

Solution (Python):
import sys
input = sys.stdin.readline

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




def gcd(a, b):
    while b: a, b = b, a % b
    return a
def isPrimeMR(n):
    d = n - 1
    d = d // (d & -d)
    L = [2]
    for a in L:
        t = d
        y = pow(a, t, n)
        if y == 1: continue
        while y != n - 1:
            y = (y * y) % n
            if y == 1 or t == n - 1: return 0
            t <<= 1
    return 1
def findFactorRho(n):
    m = 1 << n.bit_length() // 8
    for c in range(1, 99):
        f = lambda x: (x * x + c) % n
        y, r, q, g = 2, 1, 1, 1
        while g == 1:
            x = y
            for i in range(r):
                y = f(y)
            k = 0
            while k < r and g == 1:
                ys = y
                for i in range(min(m, r - k)):
                    y = f(y)
                    q = q * abs(x - y) % n
                g = gcd(q, n)
                k += m
            r <<= 1
        if g == n:
            g = 1
            while g == 1:
                ys = f(ys)
                g = gcd(abs(x - ys), n)
        if g < n:
            if isPrimeMR(g): return g
            elif isPrimeMR(n // g): return n // g
            return findFactorRho(g)
def primeFactor(n):
    i = 2
    ret = {}
    rhoFlg = 0
    while i*i <= n:
        k = 0
        while n % i == 0:
            n //= i
            k += 1
        if k: ret[i] = k
        i += 1 + i % 2
        if i == 101 and n >= 2 ** 20:
            while n > 1:
                if isPrimeMR(n):
                    ret[n], n = 1, 1
                else:
                    rhoFlg = 1
                    j = findFactorRho(n)
                    k = 0
                    while n % j == 0:
                        n //= j
                        k += 1
                    ret[j] = k

    if n > 1: ret[n] = 1
    if rhoFlg: ret = {x: ret[x] for x in sorted(ret)}
    return ret


GCD=A[0]
for a in A:
    GCD=gcd(GCD,a)

if GCD!=1:
    print("not coprime")
    sys.exit()

SET=set()
for a in A:
    S=set(primeFactor(a))
    

    if SET & S !=set():
        print("setwise coprime")
        sys.exit()
    SET|=S

print("pairwise coprime")

Solution (Python):
from math import gcd

n = int(input())


def p(x):
    a = []
    i = 2
    while True:
        if x % i == 0:
            j = 0
            while x % i == 0:
                x //= i
                j += 1
            a.append((i, j))
        if i * i > x:
            break
        i += 1
    if x != 1:
        a.append((x, 1))
    return a


pp = set()
a = [int(i) for i in input().split()]

j = 0
for i in a:
    j = gcd(j, i)
ok1 = j == 1

ok2 = True
for i in a:
    for (j, _) in p(i):
        if j in pp:
            ok2 = False
        else:
            pp.add(j)
    if not ok2:
        break
if ok2:
    print("pairwise coprime")
else:
    if ok1:
        print("setwise coprime")
    else:
        print("not coprime")

Solution (Python):
import collections

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

N = cin()[0]
A = cin()

def gcd_(a, b):
    if a < b:  a, b = b, a
    if b == 0:  return a
    return gcd_(b, a % b)

def gcd(l):
    ans = l[0]
    for i in l:  ans = gcd_(ans, i)
    return ans

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 a

flg = 0

s = [0 for _ in range(10 ** 6 + 5)]
for i in range(N):
    res = collections.Counter(prime_factorize(A[i])) 
    keys = list(res.keys()) 
    length = len(keys)
    
    for i in range(length):
        num = keys[i] 
        if s[num] == 1:
            flg = 1
            break
        s[num] += 1
        
if flg == 0:
    print("pairwise coprime")
else:
    if gcd(A) == 1:  print("setwise coprime")
    else:  print("not coprime")

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
As = list(mapint())
As.sort()

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 a

pairwise = True
s = set()
maxi = As[-1]
for i in range(N):
    a = As[i]
    if a in s:
        pairwise = False
        break
    if a==1:
        continue
    primes = list(set(prime_factorize(a)))
    for p in primes:
        cnt = 1
        while cnt*p<=maxi:
            s.add(cnt*p)
            cnt += 1
else:
    print('pairwise coprime')
    exit()

from math import gcd
g = 0
for a in As:
    g = gcd(g, a)
if g==1:
    print('setwise coprime')
    exit()
else:
    print('not coprime')

Solution (Python):
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7

INF = 10**18
eps = 10**-7


def gcd(a,b):
    while b:
        a,b = b,a%b
    return a


def gcdlist(l):
    a = l[0]
    for i in range(1,len(l)):
        a = gcd(a,l[i])
    return a

def fctr1(n): 
    f = []
    c = 0
    for i in range(2,int(n**0.5)+2):
        while n%i == 0:
            c += 1
            n = n//i
        if c !=0:
            f.append([i,c])
            c = 0
    if n != 1:
        f.append([n,1])
    return f

n = int(readline())
a = list(map(int,readline().split()))
a.sort()
check = [True]*(10**6+5)
p1 = True
for ai in a:
    if not p1:
        break
    dlist = fctr1(ai)
    for d,c in dlist:
        if check[d]:
            check[d] = False
        else:
            p1 = False
            break

if p1:
    print("pairwise coprime")
else:
    p2 = gcdlist(a)
    if p2 == 1:
        print("setwise coprime")
    else:
        print("not coprime")

Solution (Python):
import sys

input = sys.stdin.buffer.readline
n = int(input())
A = list(map(int, input().split()))



def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def isPrimeMR(n):
    d = n - 1
    d = d // (d & -d)
    L = [2]
    for a in L:
        t = d
        y = pow(a, t, n)
        if y == 1:
            continue
        while y != n - 1:
            y = (y * y) % n
            if y == 1 or t == n - 1:
                return 0
            t <<= 1
    return 1


def findFactorRho(n):
    m = 1 << n.bit_length() // 8
    for c in range(1, 99):
        f = lambda x: (x * x + c) % n
        y, r, q, g = 2, 1, 1, 1
        while g == 1:
            x = y
            for i in range(r):
                y = f(y)
            k = 0
            while k < r and g == 1:
                ys = y
                for i in range(min(m, r - k)):
                    y = f(y)
                    q = q * abs(x - y) % n
                g = gcd(q, n)
                k += m
            r <<= 1
        if g == n:
            g = 1
            while g == 1:
                ys = f(ys)
                g = gcd(abs(x - ys), n)
        if g < n:
            if isPrimeMR(g):
                return g
            elif isPrimeMR(n // g):
                return n // g
            return findFactorRho(g)


def primeFactor(n):
    i = 2
    ret = {}
    rhoFlg = 0
    while i * i <= n:
        k = 0
        while n % i == 0:
            n //= i
            k += 1
        if k:
            ret[i] = k
        i += 1 + i % 2
        if i == 101 and n >= 2 ** 20:
            while n > 1:
                if isPrimeMR(n):
                    ret[n], n = 1, 1
                else:
                    rhoFlg = 1
                    j = findFactorRho(n)
                    k = 0
                    while n % j == 0:
                        n //= j
                        k += 1
                    ret[j] = k

    if n > 1:
        ret[n] = 1
    if rhoFlg:
        ret = {x: ret[x] for x in sorted(ret)}
    return ret


scflag = 0
g = A[0]
nums = set()
for i in range(n):
    g = gcd(g, A[i])
    temp = primeFactor(A[i])
    for a in temp.keys():
        
        if a == 1:
            continue
        if a in nums:
            scflag = 1
        else:
            nums.add(a)
if g != 1:
    print("not coprime")
elif scflag:
    print("setwise coprime")
else:
    print("pairwise coprime")

Solution (Python):
from collections import defaultdict
from math import gcd
from functools import reduce
n = int(input())
A = list(map(int, input().split()))
ans = 0

U = 10**6+1
is_prime = [1]*U
is_prime[0] = 0
is_prime[1] = 0
for p in range(2, int(U**.5)+1):
    if is_prime[p]:
        for q in range(2*p, U, p):
            is_prime[q] = 0


def sieve(n):
    n += 1
    res = [i for i in range(n)]
    for p in range(2, int(n**.5)+1):
        if res[p] < p:
            continue
        for q in range(p**2, n, p):
            if res[q] == q:
                res[q] = p
    return res


min_factor = sieve(U)


def prime_factor(n):
    res = defaultdict(int)
    while 1 < n:
        res[min_factor[n]] += 1
        n //= min_factor[n]
    return res


for a in A:
    for k, v in prime_factor(a).items():
        if 1 <= is_prime[k]:
            is_prime[k] = 0
            continue
        ans = 1
        break
    else:
        continue
    break

if ans == 0:
    print('pairwise coprime')
else:
    if reduce(gcd, A) == 1:
        print('setwise coprime')
    else:
        print('not coprime')

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

primes = []
prime_idx = {}
furui = [-1]*(10**6+10)
furui[0] = 0
furui[1] = 1
for i in range(2,10**6 + 10):
    if furui[i] == -1:
        prime_idx[i] = len(primes)
        primes.append(i)
        x = i
        while x < 10**6 + 10:
            furui[x] = i
            x += i

appered = [0]*len(primes)
for a in A:
    x = a
    has = set()
    while x>1:
        has.add(prime_idx[furui[x]])
        x //= furui[x]
    for prime in has:
        appered[prime] += 1
flag = 0
for ap in appered:
    if ap > 1:
        flag = max(flag, 1)
    if ap == n:
        flag = max(flag, 2)
if flag == 2:
    print("not coprime")
elif flag == 1:
    print("setwise coprime")
else:
    print("pairwise coprime")

Solution (Python):
def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

def sieve(n):
    res = [True for _ in range(n + 1)]
    res[0] = False
    res[1] = False
    i = 2
    while i * i <= n:
        if res[i]:
            for j in range(i * 2, n + 1, i):
                res[j] = False
        i += 1
    return res

def factorize(n):
    if n == 1: return []
    res = []
    x, y = n, 2
    while y * y <= x:
        while x % y == 0:
            res.append(y)
            x //= y
        y += 1
    if x > 1:
        res.append(x)
    return res

from collections import Counter, defaultdict

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

S = sieve(10**6 + 1)

flag = True

for i in range(N):
    if S[A[i]]:
        S[A[i]] = 0
    else:
        F = set(factorize(A[i]))
        for f in F:
            if S[f]:
                S[f] = 0
            else:
                flag = False
                break
        else:
            continue
        break

if flag:
    print('pairwise coprime')

else:
    res = 0
    for i in range(N):
        res = gcd(res, A[i])
    if res == 1:
        print('setwise coprime')
    else:
        print('not coprime')

Solution (Python):
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): 
    return list(map(int,input().split()))
def m(): 
    return map(int,input().split())
def onem(): 
    return int(input())
def s(x): 
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): 
    return " ".join(map(str,x))
def max2(x): 
    return max(map(max,x))
def In(x,a): 
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)



def make_primes(n): 
    ass = []
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(i)
    return ass  


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

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

data = make_primes(10**6+1)

ppp = cl.defaultdict(int)

for i in range(len(data)):
    ppp[data[i]] = 1
n = onem()

a = l()

data = gcd_list(a)

if data != 1:
    print("not coprime")

else:
    a.sort()
    for i in range(n):
        po = prime_decomposition(a[i])
        po = s(po)
        fl = 0
        for j in range(len(po)):
            if po[j][0] == 1:
                continue
            if ppp[po[j][0]] == 1:
                ppp[po[j][0]] = 2
            else:
                fl = 1
        if fl:
            print("setwise coprime")
            break
    else:
        print("pairwise coprime")

Solution (Python):
def sieve(n):
  is_prime = [True for _ in range(n+1)]
  is_prime[0] = False
  for i in range(2, n+1):
    if is_prime[i-1]:
      j = 2 * i
      while j <= n:
        is_prime[j-1] = False
        j += i
  table = [i for i in range(1, n+1) if is_prime[i-1]]
  return table

N = int(input())
A = list(map(int, input().split()))
Amax = max(A)
lis = [0]*(Amax+1)
for i in range(N):
  lis[A[i]] += 1
table = sieve(Amax)
setwise = False
for t in table:
  p = t
  cnt = 0
  while p<=Amax:
    cnt += lis[p]
    p += t
  if cnt==N:
    print('not coprime')
    break
  if 2<=cnt<N:
    setwise=True
else:
  if setwise==True:
    print('setwise coprime')
  else:
    print('pairwise coprime')

Solution (Python):
import math as mt 
  
MAXN = 1000001
  


spf = [0 for i in range(MAXN)] 
  



def sieve(): 
    spf[1] = 1
    for i in range(2, MAXN): 
          
        
        
        spf[i] = i 
  
    
    
    for i in range(4, MAXN, 2): 
        spf[i] = 2
  
    for i in range(3, int(mt.ceil(mt.sqrt(MAXN)))): 
          
        
        if (spf[i] == i): 
              
            
            
            for j in range(i * i, MAXN, i):  
                  
                
                
                if (spf[j] == j): 
                    spf[j] = i 
  



def getFactorization(x): 
    d1={}
    while (x != 1): 
        d1[spf[x]]=0
        x = x // spf[x] 
  
    return d1.keys()
def gcd(a,b):
    while b:
        a,b=b,a%b
    return a

  

sieve()
n=int(input())
d={}
flag=1;val=-1
a=[int(i) for i in raw_input().split()]
for i in range(n):
    x=a[i]
    if val==-1:
        val=x
    val=gcd(val,x)
    ret=getFactorization(x)
    for j in ret:
        d[j]=d.get(j,0)+1
for i in d.keys():
    if i!=1 and d[i]>1:
        flag=0
if val!=1:
    print("not coprime")
elif flag:
    print("pairwise coprime")
else:
    print("setwise coprime")

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


def union_gcd(lists):
    if len(lists) == 1:
        return lists[0]
    elif len(lists) > 1:
        num = lists[0]
        for i in range(1, len(lists)):
            num = math.gcd(num, lists[i])
        return num


def prime_to(n):
    prime = {i for i in range(2, n)}
    for i in range(2, n):
        if i in prime:
            for j in range(i*2, n, i):
                if j in prime:
                    prime.remove(j)
    return prime


is_pair_wise = True
is_all_gcd_1 = False

if union_gcd(A) == 1:
    is_all_gcd_1 = True

Num = [0 for i in range(10**6+1)]
for x in A:
    Num[x] += 1

seen = [False for i in range(10**6+1)]
A.sort()
primes = prime_to(10**6)
for num in primes:
    if seen[num] == False:
        seen[num] = True
        cnt = 0
        for i in range(1, 10**6+1):
            if num*i > 10**6:
                break
            else:
                cnt += Num[num*i]
        if cnt > 1:
            is_pair_wise = False
            break
if is_pair_wise:
    print("pairwise coprime")
else:
    if is_all_gcd_1:
        print("setwise coprime")
    else:
        print("not coprime")

Solution (Python):


import collections
import sys
input=sys.stdin.readline

def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)

def judge(n,arr):
    MAX=10**6
    table=[i for i in range(MAX+1)]
    for i in range(2,MAX+1):
        if table[i]<i:
            continue
        for j in range(i,MAX+1,i):
            table[j]=i
    cnt=collections.defaultdict(int)
    for val in arr:
        s=set()
        while val!=1:
            prime=table[val]
            s.add(prime)
            val//=prime
        for tmp in s:
            cnt[tmp]+=1
    for val in cnt.values():
        if val>=2:
            return False
    return True
    
n=int(input())
arr=list(map(int,input().split()))
tmp=arr[0]
for val in arr:
    tmp=gcd(tmp,val)
if tmp==1:
    is_setwise=True
else:
    is_setwise=False
is_pairwise=judge(n,arr)
if is_pairwise==True:
    print('pairwise coprime')
elif is_setwise==True:
    print('setwise coprime')
else:
    print('not coprime')