module app;

import core.bitop;

import std.algorithm;
import std.array;
import std.bigint;
import std.container.rbtree;
import std.conv;
import std.stdio;
import std.string;
import std.traits;

struct Input
{
	int n;
	int[] a;
}

void parseInput(T)(out Input input, T adapter)
{
	with (input)
	{
		adapter.readf!"%d\n"(n);
		a.length = n;
		for (int i = 0; i < n-1; i++)
		{
			adapter.readf!"%d "(a[i]);
		}
		adapter.readf!"%d "(a[$-1]);
	}
}

struct Output
{
}

auto main2(Input* input)
{
	with (input)
	{
		int currentGcd = a[0];
		for (int i = 1; i < n; i++)
		{
			currentGcd = gcd(currentGcd, a[i]);
		}

		int[1000] primes;
		primes[0] = 2;
		int iNextPrime = 1;

		bool isPrime(int number)
		{
			foreach (p; primes)
			{
				if (p ^^ 2 <= number)
				{
					if (number % p == 0)
						return false;
				}
				else
					break;
			}

			primes[iNextPrime++] = number;

			return true;
		}

		int number = 2;
		while (number ^^ 2 <= 10 ^^ 6)
		{
			if (isPrime(number))
			{
				int warikire = 0;
				foreach (aa; a)
				{
					if (aa % number == 0)
						warikire++;
				}

				if (warikire >= 2)
				{
					if (currentGcd == 1)
						return "setwise coprime";
					else
						return "not coprime";
				}
			}

			if (number == 2)
				number++;
			else
				number += 2;
		}

		return "pairwise coprime";

	}
}

alias retType = ReturnType!main2;
static if (!is(retType == void))
{
	unittest { writeln("begin unittest"); }
	auto _placeholder_ = ReturnType!main2.init;

	unittest // example1
	{
		string example =
`3
3 4 5`;
		if (example.empty) return;
		Input input = void;
		parseExample(input, example);
		auto result = main2(&input);
		printResult(result);
		assert(result == "pairwise coprime");
	}

	unittest // example2
	{
		string example =
`3
6 10 15`;
		if (example.empty) return;
		Input input = void;
		parseExample(input, example);
		auto result = main2(&input);
		printResult(result);
		assert(result == "setwise coprime");
	}

	unittest // example3
	{
		string example =
`3
6 10 16`;
		if (example.empty) return;
		Input input = void;
		parseExample(input, example);
		auto result = main2(&input);
		printResult(result);
		assert(result == "not coprime");
	}

	unittest { writeln("end unittest"); }

	void parseExample(out Input input, string example)
	{
		parseInput(input, new StringAdapter(example));
	}
}

class StdinAdapter
{
	// readf!"%s"は使えない
	// https://issues.dlang.org/show_bug.cgi?id=19820
	uint readf(alias format, A...)(auto ref A args) { return std.stdio.readf!format(args); }
	string readln() { return std.stdio.readln().strip(); }
}

class StringAdapter
{
	import std.format;
	string _s;
	this(string input) { _s = input; }
	uint readf(alias format, A...)(auto ref A args) { return _s.formattedRead!format(args); }
	string readln()
	{
        string ret;
		auto i = _s.countUntil("\n");
		if (i == -1) { ret = _s; _s = ""; }
        else { ret = _s[0..i]; _s = _s[i+1..$]; }
		return ret;
	}
}

void printResult(T)(T result)
{
	static if (isFloatingPoint!T) writefln("%f", result);
	else writeln(result);
}

void main()
{
	Input input = void;
	parseInput(input, new StdinAdapter());
	static if (is(retType == void))
		main2(&input);
	else
	{
		auto result = main2(&input);
		printResult(result);
	}
}

T gcd(T)(T i1, T i2)
{
	T large = i1 < i2 ? i2 : i1;
	T small = i1 < i2 ? i1 : i2;
	while (small != 0)
	{
		T q = large % small;
		large = small;
		small = q;
	}
	return large;
}