import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

alias Point = Tuple !(int, q{x}, int, q{y});

auto vp (const ref Point a, const ref Point b,
    const ref Point c, const ref Point d)
{
	return (b.x - a.x) * 1L * (d.y - c.y) - (b.y - a.y) * 1L * (d.x - c.x);
}

auto rho2 (const ref Point a, const ref Point b)
{
	return (b.x - a.x) * 1L * (b.x - a.x) + (b.y - a.y) * 1L * (b.y - a.y);
}

void main ()
{
	int n;
	while (readf !(" %s") (n) > 0)
	{
		auto p = new Point [n];
		foreach (ref c; p)
		{
			readf !(" %s %s") (c.x, c.y);
		}
		p ~= p;

		bool ok = true;
		int j = 0;
		foreach (i; 0..n)
		{
			j = max (j, i + 1);
			while (j < i + n &&
			    vp (p[i], p[i + 1], p[j], p[j + 1]) > 0)
			{
				j += 1;
			}
			if (!(j < i + n &&
			    vp (p[i], p[i + 1], p[j], p[j + 1]) == 0 &&
			    rho2 (p[i], p[i + 1]) == rho2 (p[j], p[j + 1])))
			{
				ok = false;
				break;
			}
		}
		writeln (ok ? "YES" : "NO");
	}
}

import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }

void main()
{
	auto n = RD!int;
	auto xy = new int[][](n);
	foreach (i; 0..n)
	{
		xy[i] = [RD!int, RD!int];
	}

	if (n % 2 == 1)
	{
		writeln("NO");
	}
	else
	{
		int[][] vec;
		foreach (i; 1..n/2+1)
		{
			int[] t = xy[i].dup;
			t[] -= xy[i-1][];
			vec ~= t;
		}
		bool ok = true;
		foreach (i; n/2..n)
		{
			int[] t = xy[(i+1)%n].dup;
			t[] -= xy[i][];
			t = [-t[0], -t[1]];
			if ((vec[i-n/2][0] != t[0]) || (vec[i-n/2][1] != t[1]))
			{
				ok = false;
				break;
			}
		}
		writeln(ok ? "YES" : "NO");
	}

	stdout.flush;
	debug readln;
}

import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0;
string rstring(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return rstring.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtypes!real;
T[][] rtypess(T)(int n, int m){ return n.iota.map!(i => rtypes!T(m)).array; } alias rint = rtypess!int, rlong = rtypess!long, rreal = rtypess!real;
T chmin(T)(ref T x, T y){ if(x > y) x = y; return x; } T chmax(T)(ref T x, T y){ if(x < y) x = y; return x; }

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
	int n = rint;
	P[] ps;
	foreach(i; 0 .. n) ps ~= P(rlong, rlong);

	if(n % 2 != 0){
		"NO".writeln;
		return;
	}

	P[] vs;
	foreach(i; 0 .. n - 1) vs ~= P(ps[i].x - ps[i + 1].x, ps[i].y - ps[i + 1].y);
	vs ~= P(ps[n - 1].x - ps[0].x, ps[n - 1].y - ps[0].y);

	foreach(i; 0 .. n / 2){
		P u = vs[i], v = vs[i + n / 2];
		if(u.x + v.x != 0 || u.y + v.y != 0){
			"NO".writeln;
			return;
		}
	}

	"YES".writeln;
	return;

}
struct P{
	long x, y;
}

import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }

void main() {
  try {
    for (; ; ) {
      const N = readInt();
      auto X = new long[N];
      auto Y = new long[N];
      foreach (i; 0 .. N) {
        X[i] = readLong();
        Y[i] = readLong();
      }

      bool ans;
      if (N % 2 == 0) {
        auto dx = new long[N];
        auto dy = new long[N];
        foreach (i; 0 .. N) {
          dx[i] = X[(i + 1) % N] - X[i];
          dy[i] = Y[(i + 1) % N] - Y[i];
        }
        ans = true;
        foreach (i; 0 .. N / 2) {
          ans = ans && (-dx[i] == dx[i + N / 2]);
          ans = ans && (-dy[i] == dy[i + N / 2]);
        }
      }
      writeln(ans ? "YES" : "NO");
    }
  } catch (EOFException e) {
  }
}


import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }
double[] rotate(double[] vec, double rad) { return [cos(rad)*vec[0] - sin(rad)*vec[1], sin(rad)*vec[0] + cos(rad)*vec[1]]; }

//long mod = 10^^9 + 7;
long mod = 998_244_353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }
void modpow(ref long x, long y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(ref long x, long y) { y.modpow(mod - 2); x.modm(y); }

void main()
{
	auto t = RD!int;
	auto ans = new long[][](t);
	foreach (ti; 0..t)
	{
		auto n = RD!int;
		auto a = RDA;

		if (a[n-1] == 0)
		{
			foreach (i; 0..n+1)
				ans[ti] ~= i+1;
			continue;
		}
		if (a[0] == 1)
		{
			ans[ti] ~= n+1;
			foreach (i; 0..n)
				ans[ti] ~= i+1;
			continue;
		}

		int pos = -1;
		foreach (i; 0..n-1)
		{
			if (a[i] == 0 && a[i+1] == 1)
			{
				pos = i;
				break;
			}
		}
		if (pos == -1)
			continue;
		else
		{
			foreach (i; 0..pos+1)
				ans[ti] ~= i+1;
			ans[ti] ~= n+1;
			foreach (i; pos+1..n)
				ans[ti] ~= i+1;
		}
	}

	foreach (e; ans)
	{
		if (e.empty)
			writeln(-1);
		else
			e.map!(to!string).join(" ").writeln;
	}
	stdout.flush;
	debug readln;
}

immutable multi = true;

void solve(int tc)
{
	auto n = readInt!int;
	auto a = ma(n, readInt!int);
	if (a[0] == 1)
	{
		write(n + 1, " ");
		foreach(i; 1 .. n + 1) write(i, " ");
		writeln;
		return;
	}
	foreach(i; 0 .. n)
	{
		if (a[i] == 0)
		{
			if (i+1 >= n || a[i+1] == 1)
			{
				foreach(j; 1 .. i + 2)
				{
					write(j, " ");
				}
				write(n + 1, " ");
				foreach(j; i + 2 .. n + 1)
				{
					write(j, " ");
				}
				writeln;
				return;
			}
		}
	}
	writeln(-1);
	return;
}

// main {{{
void main()
{
	auto t = multi? readInt!int : 1;
	foreach(tc; 0 .. t) solve(tc);
}
// }}}
// input {{{
int currChar;
static this()
{
	currChar = ' ';
}

char topChar()
{
	return cast(char) currChar;
}

void popChar()
{
	import core.stdc.stdio;
	currChar = getchar();
}

auto readInt(T)()
{
	T num = 0;
	int sgn = 0;
	while (topChar.isWhite)
		popChar;
	while (topChar == '-' || topChar == '+')
	{
		sgn ^= (topChar == '-');
		popChar;
	}
	while (topChar.isDigit)
	{
		num *= 10;
		num += (topChar - '0');
		popChar;
	}
	if (sgn)
		return -num;
	return num;
}

string readString()
{
	string res = "";
	while (topChar.isWhite)
		popChar;
	while (!topChar.isWhite)
	{
		res ~= topChar;
		popChar;
	}
	return res;
}
auto ra(V)()
{
	int n = readInt!int;
	return ma(n, readInt!V);
}
auto rt(V)()
{
	int n = readInt!int;
	int m = readInt!int;
	return ma(n, ma(m, readInt!V));
}
auto rbg()
{
	int n = readInt!int;
	int m = readInt!int;
	auto adj = new int[][](n);
	foreach(i; 0 .. m)
	{
		auto u = readInt!int - 1;
		auto v = readInt!int - 1;
		adj[u] ~= v;
		adj[v] ~= u;
	}
	return adj;
}
auto ma(V)(size_t n, lazy V v)
{
	auto arr = new V[](n);
	foreach(ref ai; arr) ai = v;
	return arr;
}
// }}}
// imports {{{
import std.stdio;
import std.algorithm;
import std.typecons;
import std.math;
import std.numeric;
import std.container;
import std.range;
import std.array;
import std.ascii;
// }}}

import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }
double[] rotate(double[] vec, double rad) { return [cos(rad)*vec[0] - sin(rad)*vec[1], sin(rad)*vec[0] + cos(rad)*vec[1]]; }

//long mod = 10^^9 + 7;
long mod = 998_244_353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }
void modpow(ref long x, long y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(ref long x, long y) { y.modpow(mod - 2); x.modm(y); }

void main()
{
	auto t = RD!int;
	auto ans = new long[][](t);
	foreach (ti; 0..t)
	{
		auto n = RD!int;
		auto a = RDA;

		if (a[n-1] == 0)
		{
			foreach (i; 0..n+1)
				ans[ti] ~= i+1;
			continue;
		}

		int pos = -1;
		foreach (i; 0..n-1)
		{
			if (a[i] == 0 && a[i+1] == 1)
			{
				pos = i;
				break;
			}
		}
		if (pos == -1)
			continue;
		else
		{
			foreach (i; 0..pos+1)
				ans[ti] ~= i+1;
			ans[ti] ~= n+1;
			foreach (i; pos+1..n)
				ans[ti] ~= i+1;
		}
	}

	foreach (e; ans)
	{
		if (e.empty)
			writeln(-1);
		else
			e.map!(to!string).join(" ").writeln;
	}
	stdout.flush;
	debug readln;
}

import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }
double[] rotate(double[] vec, double rad) { return [cos(rad)*vec[0] - sin(rad)*vec[1], sin(rad)*vec[0] + cos(rad)*vec[1]]; }

//long mod = 10^^9 + 7;
long mod = 998_244_353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }
void modpow(ref long x, long y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(ref long x, long y) { y.modpow(mod - 2); x.modm(y); }

void main()
{
	auto t = RD!int;
	auto ans = new long[][](t);
	foreach (ti; 0..t)
	{
		auto n = RD!int;
		auto a = RDA;

		if (a[n-1] == 0)
		{
			foreach (i; 0..n+1)
				ans[ti] ~= i+1;
			continue;
		}

		int pos = -1;
		foreach (i; 0..n-1)
		{
			if (a[i] == 0 && a[i+1] == 1)
			{
				pos = i;
				break;
			}
		}
		if (pos == -1)
			continue;
		else
		{
			foreach (i; 0..pos+1)
				ans[ti] ~= i+1;
			ans[ti] ~= n+1;
			foreach (i; pos+1..n)
				ans[ti] ~= i+1;
		}
	}

	foreach (e; ans)
		e.map!(to!string).join(" ").writeln;
	stdout.flush;
	debug readln;
}


import std.stdio, std.math, std.algorithm;

void main()
{
    int n, a;
    readf("%d %d", &n, &a);

    writeln(2, " ", 1, " ", min(n, max(3, 2+round(a*n/180.))));
}

// tested by Hightail - https://github.com/dj3500/hightail
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

immutable inf = 10^^9 + 7;

int n, a;

void main() {
    scan(n, a);

    int dif = inf;
    int mk;

    foreach (k ; 1 .. n - 1) {
        if (dif > abs(a*n - 180*k)) {
            dif = abs(a*n - 180*k);
            mk = k;
        }
    }

    writefln("%s %s %s", 1, 2, n + 1 - mk);
}

void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

import std.stdio, std.math, std.algorithm;

void main()
{
    int n, a;
    readf("%d %d", &n, &a);

    writeln(2, " ", 1, " ", 2+max(1, round(a*n/180.)));
}


module _;
	import std.stdio;
auto gfilter(R)(int a, int b, int exp, R i) {
	debug writeln(i, i[a]*i[b]," ",exp);
	return i[a] * i[b] == exp;
}

void main() {
	import std.algorithm : permutations, map, fold, maxElement, filter;
	import std.array : array;
	auto cand = [4, 8, 16, 15, 23, 42].permutations.map!"a.array".array;
	foreach(it; 0..4) {
		int best = int.max, ba, bb;
		foreach(a; 0..6) {
			foreach(b; a..6) {
				auto res = cand.map!(i => i[a] * i[b]);
				int[int] cnt;
				foreach(r; res){
					cnt[r]++;
				}
				int m = cnt.byValue.maxElement;
				if (m < best) {
					best = m;
					ba = a;
					bb = b;
				}
			}
		}
		writefln("? %s %s", ba+1, bb+1);
		stdout.flush();
		int exp;
		readf(" %s", &exp);
		if (!exp) {
			return;
		}
		cand = cand.filter!(a => gfilter(ba, bb, exp, a)).array;
		debug writeln(cand);
	}
	if (cand.length != 1) {
		assert(false);
	}
	writefln("! %(%s %)", cand[0]);
}

import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

//long mod = 10^^9 + 7;
long mod = 998244353;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	bool[long] numbers = [4:true, 8:true, 15:true, 16:true, 23:true, 42:true];
	long[] ans;
	foreach (i; 0..2)
	{
		writeln("? ", i*3+1, " ", i*3+2);
		stdout.flush();
		auto x1 = RD;
		writeln("? ", i*3+2, " ", i*3+3);
		stdout.flush();
		auto x2 = RD;

		foreach (num; numbers.keys)
		{
			if (x1 % num == 0 && x2 % num == 0)
			{
				auto y1 = x1 / num;
				auto y2 = x2 / num;
				bool ok1, ok2;
				foreach (num2; numbers.keys)
				{
					if (num2 == num) continue;
					if (num2 == y1)
						ok1 = true;
					if (num2 == y2)
						ok2 = true;
				}
				if (ok1 && ok2)
				{
					ans ~= [y1, num, y2];
				}
			}
		}
	}

	write("! ");
	ans.map!(to!string).join(" ").writeln;
	stdout.flush();
	debug readln();
}

import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

void main() {
    auto X = new int[](6);
    foreach (i; 0..4) {
        writeln("? ", i+1, " ", i+2);
        stdout.flush;
        X[i] = readln.chomp.to!int;
    }

    int[] A = [4, 8, 15, 16, 23, 42];
    do {
        bool ok = true;
        foreach (i; 0..4) {
            if (A[i] * A[i+1] != X[i]) {
                ok = false;
                break;
            }
        }
        if (ok) {
            writeln("! ", A.map!(to!string).join(" "));
            return;
        }
    } while (nextPermutation(A));
}

import std.stdio, std.conv, std.string;
import std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

int DEBUG_LEVEL = 0;
void print()(){ writeln(""); }
void print(T, A ...)(T t, lazy A a){ write(t), print(a); }
void print(int level, T, A ...)(T t, lazy A a){ if(level <= DEBUG_LEVEL) print(t, a); }

void main(string[] args){
	if(args.length > 1 && args[1] == "-debug"){
		if(args.length > 2 && args[2].isNumeric) DEBUG_LEVEL = args[2].to!int;
		else DEBUG_LEVEL = 1;
	}

	writeln("? 1 2");
	stdout.flush;
	long a12 = read.to!long;

	writeln("? 1 3");
	stdout.flush;
	long a13 = read.to!long;

	writeln("? 1 4");
	stdout.flush;
	long a14 = read.to!long;

	writeln("? 1 5");
	stdout.flush;
	long a15 = read.to!long;

	long a1 = -1, a2 = -1, a3 = -1, a4 = -1, a5 = -1, a6 = -1;

	if(a12 % 23 == 0){
		if(a13 % 23 == 0) a1 = 23;
		else a2 = 23;
	}
	else if(a13 % 23 == 0) a3 = 23;
	else if(a14 % 23 == 0) a4 = 23;
	else if(a15 % 23 == 0) a5 = 23;
	else a6 = 23;

	if(a12 % 5 == 0){
		if(a13 % 5 == 0) a1 = 15;
		else a2 = 15;
	}
	else if(a13 % 5 == 0) a3 = 15;
	else if(a14 % 5 == 0) a4 = 15;
	else if(a15 % 5 == 0) a5 = 15;
	else a6 = 15;

	if(a2 > 0) a1 = a12 / a2;
	if(a3 > 0) a1 = a13 / a3;
	if(a4 > 0) a1 = a14 / a4;
	if(a5 > 0) a1 = a15 / a5;

	if(a2 < 0) a2 = a12 / a1;
	if(a3 < 0) a3 = a13 / a1;
	if(a4 < 0) a4 = a14 / a1;
	if(a5 < 0) a5 = a15 / a1;
	a6 = (4 + 8 + 15 + 16 + 23 + 42) - (a1 + a2 + a3 + a4 + a5);

	writeln("! ", a1, " ", a2, " ", a3, " ", a4, " ", a5, " ", a6);
}

import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

//long mod = 10^^9 + 7;
long mod = 998244353;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	bool[long] numbers = [4:true, 8:true, 15:true, 16:true, 23:true, 42:true];
	long[] ans;
	foreach (i; 0..2)
	{
		writeln("? ", i*3+1, " ", i*3+2);
		stdout.flush();
		auto x1 = RD;
		writeln("? ", i*3+2, " ", i*3+3);
		stdout.flush();
		auto x2 = RD;
		long[2] pair;
		(){
		foreach (num; numbers.keys)
		{
			if (x1 % num == 0)
			{
				auto y = x1 / num;
				foreach (num2; numbers.keys)
				{
					if (num2 == y)
					{
						pair = [num, num2];
						return;
					}
				}
			}
		}}();

		if (x2 % pair[0] == 0 && numbers.get(x2/pair[0], false))
		{
			ans ~= [pair[1], pair[0], x2/pair[0]];
		}
		else
		{
			ans ~= [pair[0], pair[1], x2/pair[1]];
		}
	}

	write("! ");
	ans.map!(to!string).join(" ").writeln;
	stdout.flush();
	debug readln();
}

import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

//long mod = 10^^9 + 7;
long mod = 998244353;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	bool[long] numbers = [4:true, 8:true, 15:true, 16:true, 23:true, 42:true];
	long[] ans;
	foreach (i; 0..2)
	{
		writeln("? ", i*3+1, " ", i*3+2);
		stdout.flush();
		auto x1 = RD;
		writeln("? ", i*3+2, " ", i*3+3);
		stdout.flush();
		auto x2 = RD;

		foreach (num; numbers.keys)
		{
			if (x1 % num == 0 && x2 % num == 0)
			{
				auto y1 = x1 / num;
				auto y2 = x2 / num;
				bool ok1, ok2;
				foreach (num2; numbers.keys)
				{
					if (num2 == y1)
						ok1 = true;
					if (num2 == y2)
						ok2 = true;
				}
				if (ok1 && ok2)
				{
					ans ~= [y1, num, y2];
				}
			}
		}
	}

	write("! ");
	ans.map!(to!string).join(" ").writeln;
	stdout.flush();
	debug readln();
}

import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

//long mod = 10^^9 + 7;
long mod = 998244353;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	long[] numbers = [4, 8, 15, 16, 23, 42];
	long[] ans;
	foreach (i; 0..2)
	{
		writeln("? ", i*3+1, " ", i*3+2);
		stdout.flush();
		auto x1 = RD;
		writeln("? ", i*3+2, " ", i*3+3);
		stdout.flush();
		auto x2 = RD;
		long[2] pair;
		(){
		foreach (num; numbers)
		{
			if (x1 % num == 0)
			{
				auto y = x1 / num;
				foreach (num2; numbers)
				{
					if (num2 == y)
					{
						pair = [num, num2];
						return;
					}
				}
			}
		}}();

		if (x2 % pair[0] == 0)
		{
			ans ~= [pair[1], pair[0], x2/pair[0]];
		}
		else
		{
			ans ~= [pair[0], pair[1], x2/pair[1]];
		}
	}

	write("! ");
	ans.map!(to!string).join(" ").writeln;
	stdout.flush();
	debug readln();
}


import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main ()
{
	int n, m;
	while (readf !(" %s %s") (n, m) > 0)
	{
		auto adj = new int [] [n];
		foreach (j; 0..m)
		{
			int u, v;
			readf !(" %s %s") (u, v);
			u -= 1;
			v -= 1;
			adj[u] ~= v;
			adj[v] ~= u;
		}
		readln;
		auto t = readln.splitter.map !(to !(int)).array;

		auto p = n.iota.array;
		p.schwartzSort !(x => t[x]);

		bool ok = true;
		foreach (i, v; p)
		{
			bool [int] used;
			foreach (u; adj[v])
			{
				if (t[u] == t[v])
				{
					ok = false;
				}
				else if (t[u] < t[v])
				{
					used[t[u]] = true;
				}
			}
			ok &= (used.length == t[v] - 1);
		}

		if (ok)
		{
			writefln !("%(%s %)") (p.map !(q{a + 1}));
		}
		else
		{
			writeln (-1);
		}
	}
}

import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional, std.meta;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.ascii, std.typecons;

void main()
{
    int n, m;
    readf("%s %s", &n, &m);
    readln;

    auto g = new int[][] (n+1);

    foreach (_; m.iota) {
        int u, v;
        readf("%s %s", &u, &v);
        readln;

        --u, --v;

        g[u] ~= v;
        g[v] ~= u;
    }

    auto arr = readln.chomp.split.map!(to!int).array;

    auto groups = new int[][] (n+1);

    foreach (i, e; arr) { groups[e] ~= i.to!int; }

    int[] ans;
    int[] need;
    foreach (gridx, gr; groups.dropOne.enumerate(1)) {
        foreach (e; gr) {
            auto connected = g[e]
                .map!(v => arr[v]).filter!(v => v <= gridx).array
                .sort.uniq.array;

            bool isOk = connected == need;

            if (!isOk) {
                debug { writeln(gridx, ' ', e, ' ', ' ', g[e], ' ', connected); }
                writeln(-1);
                return;
            }

            ans ~= e;
        }

        need ~= gridx;
    }

    ans.map!(x => x+1).map!(to!string).join(" ").writeln;
}

import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional, std.meta;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.ascii, std.typecons;

void main()
{
    int n, m;
    readf("%s %s", &n, &m);
    readln;

    auto g = new int[][] (n+1);

    foreach (_; m.iota) {
        int u, v;
        readf("%s %s", &u, &v);
        readln;

        --u, --v;

        g[u] ~= v;
        g[v] ~= u;
    }

    auto arr = readln.chomp.split.map!(to!int).array;

    auto groups = new int[][] (n+1);

    foreach (i, e; arr) { groups[e] ~= i.to!int; }

    int[] ans;
    foreach (gridx, gr; groups.dropOne.enumerate(1)) {
        foreach (e; gr) {
            bool isOk = true;

            auto vals = g[e].map!(v => arr[v]).array;
            auto connected = make!(RedBlackTree!int)(vals);

            isOk &= (gridx.to!int !in connected);

            foreach (i; 1 .. gridx) { isOk &= i.to!int in connected; }

            if (!isOk) {
                debug { writeln(gridx, ' ', e, ' ', ' ', g[e], ' ', connected); }
                writeln(-1);
                return;
            }

            ans ~= e;
        }
    }

    ans.map!(x => x+1).map!(to!string).join(" ").writeln;
}

import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional, std.meta;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.ascii, std.typecons;

void main()
{
    int n, m;
    readf("%s %s", &n, &m);
    readln;

    auto g = new int[][] (n+1);

    foreach (_; m.iota) {
        int u, v;
        readf("%s %s", &u, &v);
        readln;

        --u, --v;

        g[u] ~= v;
        g[v] ~= u;
    }

    auto arr = readln.chomp.split.map!(to!int).array;

    auto groups = new int[][] (n+1);

    foreach (i, e; arr) { groups[e] ~= i.to!int; }

    int[] ans;
    foreach (gridx, gr; groups.dropOne.enumerate(1)) {
        foreach (e; gr) {
            auto vals = g[e].map!(v => arr[v]).filter!(v => v <= gridx).array;
            auto connected = make!(RedBlackTree!int)(vals);

            bool isOk = connected[].array == gridx.iota.dropOne.array;

            if (!isOk) {
                debug { writeln(gridx, ' ', e, ' ', ' ', g[e], ' ', connected); }
                writeln(-1);
                return;
            }

            ans ~= e;
        }
    }

    ans.map!(x => x+1).map!(to!string).join(" ").writeln;
}

import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional, std.meta;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.ascii, std.typecons;

void main()
{
    int n, m;
    readf("%s %s", &n, &m);
    readln;

    auto g = new int[][] (n+1);

    foreach (_; m.iota) {
        int u, v;
        readf("%s %s", &u, &v);
        readln;

        --u, --v;

        g[u] ~= v;
        g[v] ~= u;
    }

    auto arr = readln.chomp.split.map!(to!int).array;

    auto groups = new int[][] (n+1);

    foreach (i, e; arr) { groups[e] ~= i.to!int; }

    int[] ans;
    foreach (gridx, gr; groups.dropOne.enumerate(1)) {
        foreach (e; gr) {
            auto connected = g[e]
                .map!(v => arr[v]).filter!(v => v <= gridx).array
                .sort.uniq.array;

            bool isOk = connected == gridx.iota.dropOne.array;

            if (!isOk) {
                debug { writeln(gridx, ' ', e, ' ', ' ', g[e], ' ', connected); }
                writeln(-1);
                return;
            }

            ans ~= e;
        }
    }

    ans.map!(x => x+1).map!(to!string).join(" ").writeln;
}

import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

//long mod = 10^^9 + 7;
long mod = 998_244_353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { y.modpow(mod - 2); x.modm(y); }

void main()
{
	auto n = RD!int;
	auto m = RD!int;
	auto edges = new int[][](n);
	foreach (i; 0..m)
	{
		auto a = RD!int-1;
		auto b = RD!int-1;
		edges[a] ~= b;
		edges[b] ~= a;
	}
	auto p = RDA!int;

	auto ans = new int[](n);
	auto index = p.MAKE_IDX();
	foreach (ii, i; index)
	{
		auto num = p[i];
		auto used = new bool[](num);
		foreach (to; edges[i])
		{
			auto num2 = p[to];
			if (num2 > num) continue;
			used[num2-1] = true;
		}
		bool ok = used[$-1] == false;
		if (ok)
		{
			foreach (j; 0..num-1)
			{
				if (!used[j])
				{
					ok = false;
					break;
				}
			}
		}
		if (ok)
		{
			ans[ii] = cast(int)(i+1);
		}
		else
		{
			ans.length = 0;
			break;
		}
	}

	if (ans.empty)
		writeln(-1);
	else
		ans.map!(to!string).join(" ").writeln;
	stdout.flush;
	debug readln;
}

import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional, std.meta;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.ascii, std.typecons;

void main()
{
    int n, m;
    readf("%s %s", &n, &m);
    readln;

    auto g = new int[][] (n+1);

    foreach (_; m.iota) {
        int u, v;
        readf("%s %s", &u, &v);
        readln;

        --u, --v;

        g[u] ~= v;
        g[v] ~= u;
    }

    auto arr = readln.chomp.split.map!(to!int).array;

    auto groups = new int[][] (n+1);

    foreach (i, e; arr) { groups[e] ~= i.to!int; }

    int[] ans;
    foreach (gridx, gr; groups.dropOne.enumerate(1)) {
        foreach (e; gr) {
            bool isOk = true;

            auto vals = g[e].map!(v => arr[v]).array;
            auto connected = make!(RedBlackTree!int)(vals);

            foreach (i, c; connected[].enumerate(1)) {
                if (c == gridx + 1) { break; }

                if (i != c) { isOk = false; }
                if (c == gridx) { isOk = false; }
            }

            if (!isOk) {
                debug { writeln(gridx, ' ', e, ' ', ' ', g[e], ' ', connected); }
                writeln(-1);
                return;
            }

            ans ~= e;
        }
    }

    ans.map!(x => x+1).map!(to!string).join(" ").writeln;
}

import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional, std.meta;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.ascii, std.typecons;

void main()
{
    int n, m;
    readf("%s %s", &n, &m);
    readln;

    auto g = new int[][] (n+1);

    foreach (_; m.iota) {
        int u, v;
        readf("%s %s", &u, &v);
        readln;

        --u, --v;

        g[u] ~= v;
        g[v] ~= u;
    }

    auto arr = readln.chomp.split.map!(to!int).array;

    auto groups = new int[][] (n+1);

    foreach (i, e; arr) { groups[e] ~= i.to!int; }

    int[] ans;
    foreach (gridx, gr; groups.dropOne.enumerate(1)) {
        foreach (e; gr) {
            bool isOk = true;

            auto vals = g[e].map!(v => arr[v]).filter!(v => v <= gridx).array;
            auto connected = make!(RedBlackTree!int)(vals);

            foreach (i, c; connected[].enumerate(1)) {
                if (i != c) { isOk = false; }
                if (c == gridx) { isOk = false; }
            }

            if (!isOk) {
                debug { writeln(gridx, ' ', e, ' ', ' ', g[e], ' ', connected); }
                writeln(-1);
                return;
            }

            ans ~= e;
        }
    }

    ans.map!(x => x+1).map!(to!string).join(" ").writeln;
}


import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0;
string rstring(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return rstring.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtypes!real;
T[][] rtypess(T)(int n, int m){ return n.iota.map!(i => rtypes!T(m)).array; } alias rint = rtypess!int, rlong = rtypess!long, rreal = rtypess!real;
T chmin(T)(ref T x, T y){ if(x > y) x = y; return x; } T chmax(T)(ref T x, T y){ if(x < y) x = y; return x; }

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
	int n = rint, k = rint;

	int[int] cnt;
	long[int] vm;
	foreach(i; 0 .. k + 1){
		int[] js;
		foreach(j; 0 .. k + 1) if(j != i) js ~= j;
		S s = ask(js);
		vm[s.pos] = s.value;
		if(s.pos !in cnt) cnt[s.pos] = 0;
		cnt[s.pos] += 1;
	}

	int[] ks = cnt.keys;
	int a = ks[0], b = ks[1];
	if(vm[a] < vm[b]) answer(cnt[b]);
	else answer(cnt[a]);

}
struct S{
	int pos;
	long value;
}
S ask(int[] js){
	writeln("? ", js.map!(x => (x + 1).to!string).array.join(" "));
	stdout.flush;
	return S(rint, rlong);
}
void answer(int ans){
	writeln("! ", ans);
}

import std.stdio;
import std.array;
import std.range : iota;

void main() {
  int n, k;
  readf!"%d %d\n"(n, k);

  auto a = iota(1, k+2).array;

  auto b1 = -1, b2 = -1;
  auto c1 = 0, c2 = 0;

  // make k+1 queries, omitting i in each
  foreach (i; 0..k+1) {
    auto x = a[0..i] ~ a[i+1..$];

    // write query string
    write("? ");
    foreach (e; x) {
      writef("%d ", e);
    }
    writeln;
    stdout.flush;

    // read response
    int pos, b;
    readf!"%d %d\n"(pos, b);

    if (b1 == -1) {
      b1 = b;
    } else if (b2 == -1 && b1 != b) {
      b2 = b;
    }

    if (b1 == b) {
      c1++;
    } else {
      c2++;
    }
  }

  // there'll be m occurrences of the larger element
  // and k + 1 - m of the smaller
  writefln("! %d\n", b1 > b2 ? c1 : c2);
}


import std.stdio, std.string;
import std.random, std.algorithm;
import std.numeric, std.math;
import std.range, std.array;
import std.typecons, std.conv;

int[] solve(int[] a)
{
    auto n = to!int(a.length);
    const int m = 512;
    auto pdp = new bool[m];
    auto ndp = new bool[m];
    auto mi = new int[m];
    fill(mi, int.max);
    mi[0] = 0;
    pdp[0] = true;
    foreach (i; 0 .. n)
    {
        fill(ndp, false);
        foreach (j; 0 .. m) if (pdp[j])
        {
            ndp[j] = true;
            if (mi[j] < a[i])
            {
                ndp[j ^ a[i]] = true;
                mi[j ^ a[i]] = min(mi[j ^ a[i]], a[i]);
            }
        }
        ndp.copy(pdp);
    }
    int[] res;
    foreach (i; 0 .. m) if (pdp[i]) res ~= i;
    return res;
}

int main(string[] args)
{
    readln;
    auto a = map!(to!int)(readln.strip.split(" ")).array;
    auto ret = solve(a);
    writeln(ret.length);
    writeln(join(map!(to!string)(ret), " "));
    return 0;
}

import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }
double[] rotate(double[] vec, double rad) { return [cos(rad)*vec[0] - sin(rad)*vec[1], sin(rad)*vec[0] + cos(rad)*vec[1]]; }

//long mod = 10^^9 + 7;
long mod = 998_244_353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }
void modpow(ref long x, long y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(ref long x, long y) { y.modpow(mod - 2); x.modm(y); }

void main()
{
	auto n = RD!int;
	auto a = RDA!int;

	auto dp = new long[](2^^9);
	dp[] = long.max;
	dp[0] = 0;
	foreach (i; 0..n)
	{
		auto ndp = dp.dup;
		foreach (j; 0..2^^9)
		{
			if (dp[j] >= a[i]) continue;
			auto nj = j ^ a[i];
			ndp[nj].chmin(a[i]);
			debug writeln("j:", j, " nj:", nj);
		}
		dp = ndp;
		debug
		{
			foreach (j; 0..20)
			{
				if (dp[j])
					write(" ", j);
			}
			writeln;
		}
	}

	long[] ans;
	foreach (i; 0..2^^9)
	{
		if (dp[i] != long.max)
			ans ~= i;
	}

	writeln(ans.length);
	ans.map!(to!string).join(" ").writeln;
	stdout.flush;
	debug readln;
}

import std.stdio, std.string;
import std.random, std.algorithm;
import std.numeric, std.math;
import std.range, std.array;
import std.typecons, std.conv;

int[] solve(int[] a)
{
    auto n = to!int(a.length);
    const int m = 512;
    auto pdp = new bool[m];
    auto ndp = new bool[m];
    auto mi = new int[m];
    fill(mi, int.max);
    mi[0] = 0;
    pdp[0] = true;
    foreach (i; 0 .. n)
    {
        fill(ndp, false);
        foreach (j; 0 .. m) if (pdp[j])
        {
            ndp[j] = true;
            if (mi[j] < a[i])
            {
                ndp[j ^ a[i]] = true;
                mi[j ^ a[i]] = min(mi[j ^ a[i]], a[i]);
            }
        }
        ndp.copy(pdp);
    }
    int[] res;
    foreach (i; 0 .. m) if (pdp[i]) res ~= i;
    return res;
}

int main(string[] args)
{
    readln;
    auto a = map!(to!int)(readln.strip.split(" ")).array;
    auto ret = solve(a);
    writeln(join(map!(to!string)(ret), " "));
    return 0;
}


import std.stdio;
import std.algorithm;
import std.conv;
import std.range;
import std.string;
import std.regex;

void main() {
  readln;

  int ans = 0;

  foreach (string line; stdin.lines) {
    if (!match(line, regex(`\+\+`)).empty) {
      ans++;
    } else {
      ans--;
    }
  }

  ans.writeln;
}

//ahmat
import core.stdc.stdio:scanf,printf,puts;
import core.bitop;
import std.stdio;
import std.string;
import std.algorithm;
import std.functional;
import std.array;
import std.container;
import std.conv;
import std.container;
import std.typecons;
import std.math;
import std.numeric;
pragma(inline,true);

void main(){
    int x=0;
    int n=readln.chomp.to!int;
    string s;
    while(n--){
        s=readln.strip;
        if(s[0]=='+'||s[2]=='+')
            x++;
        else x--;
    }
    writeln(x);
}

module Solution;
import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;

void main() {
  immutable n = readln.chomp.to!int;
  immutable p = stdin.byLine.take(n).count! (s => s[1] == '+').to!int;
  writeln (p - (n - p));
}

import std.stdio;
import std.conv:to;
import std.string:chomp, countchars;

void main() {
    int num = to!int(chomp(stdin.readln()));
    int res;
    foreach (a; 0..num) {
        string buf = chomp(stdin.readln());
        res += buf.countchars("+");
    }
    writeln(res-num);
}

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;

void main(){
  int X;
  int n = readln.chomp.to!int;
  foreach(i; 0..n){
    if(readln.chomp.find("+").length) X++;
    else X--;
  }
  X.writeln;
}

import std.stdio;
import std.algorithm;

void main()
{
    readln;
    int x;
    foreach(line; stdin.byLine)
    {
        if(line.any!(a => a=='-')) --x;
        else ++x;
    }

    x.writeln;
}

import std.stdio;

void main() {
    int n;
    readf("%d\n", &n);

    int result = 0;
    for (int i = 0; i < n; ++i) {
        string s = readln();

        if (s[0] == '+' || s[1] == '+') {
            result++;
        } else {
            result--;
        }
    }

    writefln("%d", result);
}

import std.stdio, std.string;

void main()
{
    int n, x = 0;

    readf("%s\n", &n);

    while(--n >= 0) {
        string str;
        readf("%s\n", &str);
        if(str.indexOf("+") != -1){ ++x; } else { --x; }
    }

    writeln(x);
}

import std.stdio;
import std.algorithm;

void main() {
	int count;
	int x;
	readf("%s",&count);
	readln();

	string[] ops;
	for (int i=0; i<count; i++){
		ops ~= readln();
	}

	for (int i=0; i<count; i++){
		if (ops[i].canFind("++")) {
			x++;
		}
		if (ops[i].canFind("--")) {
			x--;
		}
	}

	/* for (int i=0; i<count; i++){ */
	/* 	writeln("$$" ~ ops[i]); */
	/* } */
	writeln(x);
}

import std.stdio;
import std.conv;
import core.stdc.stdio;
import std.string;

int main(string[] argv)
{
	int n;
	string line;
	int x = 0;
	scanf("%d", &n);
	line = std.stdio.stdin.readln();
	for (int i = 0; i < n; i++)
	{
		line = std.stdio.stdin.readln();
		if (indexOf(line, "++") != -1)
		{
			x++;
		} else
		if (indexOf(line, "--") != -1)
		{
			x--;
		}
	}
	printf("%d", x);
	return 0;
}

// https://codeforces.com/problemset/problem/282/A
import std.algorithm;
import std.stdio;

void main() {
    readln;
    int answer = 0;
    foreach(line; stdin.byLine)
        if(canFind(line,"++"))
            answer++;
        else
            answer--;
    answer.writeln;
}

module Solution;
import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;

void main() {
  immutable n = readln.chomp.to!int;
  immutable p = stdin.byLine.take(n).count! (s => s[1] == '+');
  writeln (p - (n - p));
}

import std.stdio, std.string;

void main()
{
    int n, x = 0;

    readf("%s", &n);

    while(--n >= 0) {
        string str;
        readf("%s\n", &str);
        if(str.indexOf("+") != -1){ ++x; } else { --x; }
    }

    writeln(x);
}

import std.stdio, std.string;

void main()
{
    int n, x = 0;

    stdin.readf("%s", &n);

    while(n > 0) {
        string str;
        readf("%s", &str);
        if(str.indexOf("+") != -1){ ++x; } else { --x; }
        --n;
    }

    write("", x);
}

import std.stdio;
import std.conv;
import core.stdc.stdio;
import std.string;

int main(string[] argv)
{
	int n;
	string line;
	int x = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		line = readln();
		if (indexOf(line, "++") != -1)
		{
			x++;
		} else
		if (indexOf(line, "--") != -1)
		{
			x--;
		}
	}
	printf("%d", x);
	return 0;
}

// https://codeforces.com/problemset/problem/282/A
import std.algorithm;
import std.stdio;

void main() {
    readln;
    int answer = 0;
    foreach(line; stdin.byLine)
        if(!canFind(line,"++"))
            answer++;
        else
            answer--;
    answer.writeln;
}


import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main ()
{
	auto tests = readln.strip.to !(int);
	foreach (test; 0..tests)
	{
		auto a = readln.splitter.map !(to !(int)).array;
		int res = a[0] + a[2];
		if (max (a[0], a[2]) <= min (a[1], a[3]))
		{
			res = min (res, max (a[0], a[2]));
		}
		writeln (res);
	}
}

void main() { runSolver(); }

void problem() {
  auto QN = scan!int;

  auto solve() {
    auto subSolve() {
      auto L1 = scan!int;
      auto R1 = scan!int;
      auto L2 = scan!int;
      auto R2 = scan!int;

      if (R1 >= L2 && L2 >= L1) {
        return L2;
      }
      if (R2 >= L1 && L1 >= L2) {
        return L1;
      }

      return L1 + L2;
    }

    foreach(i; 0..QN) {
      subSolve().writeln;
    }
  }

  outputForAtCoder(&solve);
}

// ----------------------------------------------

import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons, std.numeric, std.traits, std.functional, std.bigint, std.datetime.stopwatch, core.time, core.bitop;
T[][] combinations(T)(T[] s, in long m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; }
T[] scan(T)(long n){ return n.iota.map!(i => scan!T()).array; }
void deb(T ...)(T t){ debug writeln(t); }
alias Point = Tuple!(long, "x", long, "y");
Point invert(Point p) { return Point(p.y, p.x); }
long[] divisors(long n) { long[] ret; for (long i = 1; i * i <= n; i++) { if (n % i == 0) { ret ~= i; if (i * i != n) ret ~= n / i; } } return ret.sort.array; }
bool chmin(T)(ref T a, T b) { if (b < a) { a = b; return true; } else return false; }
bool chmax(T)(ref T a, T b) { if (b > a) { a = b; return true; } else return false; }
string charSort(alias S = "a < b")(string s) { return (cast(char[])((cast(byte[])s).sort!S.array)).to!string; }
ulong comb(ulong a, ulong b) { if (b == 0) {return 1;}else{return comb(a - 1, b - 1) * a / b;}}
T[] compress(T)(T[] arr, T origin = T.init) { T[T] indecies; arr.dup.sort.uniq.enumerate(origin).each!((i, t) => indecies[t] = i); return arr.map!(t => indecies[t]).array; }
string toAnswerString(R)(R r) { return r.map!"a.to!string".joiner(" ").array.to!string; }
struct ModInt(uint MD) if (MD < int.max) {ulong v;this(string v) {this(v.to!long);}this(int v) {this(long(v));}this(long v) {this.v = (v%MD+MD)%MD;}void opAssign(long t) {v = (t%MD+MD)%MD;}static auto normS(ulong x) {return (x<MD)?x:x-MD;}static auto make(ulong x) {ModInt m; m.v = x; return m;}auto opBinary(string op:"+")(ModInt r) const {return make(normS(v+r.v));}auto opBinary(string op:"-")(ModInt r) const {return make(normS(v+MD-r.v));}auto opBinary(string op:"*")(ModInt r) const {return make((ulong(v)*r.v%MD).to!ulong);}auto opBinary(string op:"^^", T)(T r) const {long x=v;long y=1;while(r){if(r%2==1)y=(y*x)%MD;x=x^^2%MD;r/=2;} return make(y);}auto opBinary(string op:"/")(ModInt r) const {return this*memoize!inv(r);}static ModInt inv(ModInt x) {return x^^(MD-2);}string toString() const {return v.to!string;}auto opOpAssign(string op)(ModInt r) {return mixin ("this=this"~op~"r");}}
alias MInt1 = ModInt!(10^^9 + 7);
alias MInt9 = ModInt!(998_244_353);
void outputForAtCoder(T)(T delegate() fn) {
  static if (is(T == float) || is(T == double) || is(T == real)) "%.16f".writefln(fn());
  else static if (is(T == void)) fn();
  else static if (is(T == string)) fn().writeln;
  else static if (isInputRange!T) {
    static if (!is(string == ElementType!T) && isInputRange!(ElementType!T)) foreach(r; fn()) r.toAnswerString.writeln;
    else foreach(r; fn()) r.writeln;
  }
  else fn().writeln;
}
void runSolver() {
  enum BORDER = "==================================";
  debug { BORDER.writeln; while(!stdin.eof) { "<<< Process time: %s >>>".writefln(benchmark!problem(1)); BORDER.writeln; } }
  else problem();
}
enum YESNO = [true: "Yes", false: "No"];

// -----------------------------------------------


import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;

void main ()
{
	auto tests = readln.strip.to !(int);
	foreach (test; 0..tests)
	{
		int u, v;
		readf !(" %s %s") (u, v);
		int cur = 0;
		bool ok = (u <= v);
		foreach (d; 0..30)
		{
			auto x = (u >> d) & 1;
			auto y = (v >> d) & 1;
			cur += x - y;
			ok &= (cur >= 0);
		}
		writeln (ok ? "YES" : "NO");
	}
}

import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }

bool solve(const(long) A, const(long) B) {
  if (!(A <= B)) {
    return false;
  }
  int[] xs, ys;
  foreach (e; 0 .. bsr(A)) if ((A >> e) & 1) xs ~= e;
  foreach (e; 0 .. bsr(B)) if ((B >> e) & 1) ys ~= e;
  const xsLen = cast(int)(xs.length);
  const ysLen = cast(int)(ys.length);
  if (!(xsLen >= ysLen)) {
    return false;
  }
  foreach (i; 0 .. ysLen) {
    if (!(xs[i] <= ys[i])) {
      return false;
    }
  }
  return true;
}

void main() {
  debug {
    enum V = 1 << 8;
    auto d = new bool[][](V, V);
    foreach (u; 1 .. V) {
      d[u][u] = true;
    }
    foreach (u; 1 .. V) {
      foreach (v; 1 .. V - u) {
        if ((u & v) == v) {
          d[u][u + v] = true;
        }
      }
    }
    foreach (w; 1 .. V) foreach (u; 1 .. V) if (d[u][w]) foreach (v; 1 .. V) if (d[w][v]) {
      d[u][v] = true;
    }
    foreach (u; 1 .. V) foreach (v; 1 .. V) {
      const res = solve(u, v);
      assert(d[u][v] == res, format("%s %s: %s %s", u, v, d[u][v], res));
    }
  }

  try {
    for (; ; ) {
      const numCases = readInt();
      foreach (caseId; 0 .. numCases) {
        const A = readLong();
        const B = readLong();
        const ans = solve(A, B);
        writeln(ans ? "YES" : "NO");
      }
    }
  } catch (EOFException e) {
  }
}

import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

//long mod = 10^^9 + 7;
long mod = 998_244_353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }
void modpow(ref long x, long y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(ref long x, long y) { y.modpow(mod - 2); x.modm(y); }

void main()
{
	auto q = RD!int;
	auto ans = new long[](q);
	foreach (qi; 0..q)
	{
		auto u = RD;
		auto v = RD;

		auto uc = popcnt(u);
		auto vc = popcnt(v);
		if (v >= u && vc <= uc)
		{
			int c1, c2;
			bool ok = true;
			foreach (i; 0..32)
			{
				auto bit = 1L << i;
				if (u & bit)
					++c1;
				if (v & bit)
					++c2;
				if (c2 > c1)
					ok = false;
			}
			ans[qi] = ok;
		}
	}

	foreach (e; ans)
		writeln(e ? "YES" : "NO");
	stdout.flush;
	debug readln;
}

import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

//long mod = 10^^9 + 7;
long mod = 998_244_353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }
void modpow(ref long x, long y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(ref long x, long y) { y.modpow(mod - 2); x.modm(y); }

void main()
{
	auto q = RD!int;
	auto ans = new long[](q);
	foreach (qi; 0..q)
	{
		auto u = RD!int;
		auto v = RD!int;

		auto uc = popcnt(u);
		auto vc = popcnt(v);
		if (v >= u && vc <= uc)
			ans[qi] = true;
	}

	foreach (e; ans)
		writeln(e ? "YES" : "NO");
	stdout.flush;
	debug readln;
}


import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { x.modm(y.modpow(mod - 2)); }

void main()
{
	auto n = RD!int;
	auto s = RD!string;
	int l, cnt, ans;
	foreach (i; 0..n)
	{
		if (s[i] == ')')
			--cnt;
		else
		{
			if (cnt == -1)
			{
				ans += i - l + 1;
			}
			++cnt;
		}
		if (cnt == 0)
		{
			l = i+1;
		}
	}
	if (cnt != 0)
		writeln(-1);
	else
		writeln(ans);
	stdout.flush;
	debug readln;
}

import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main ()
{
	int n;
	while (readf !(" %s") (n) > 0)
	{
		readln;
		auto s = readln.strip;
		if (s.count ('(') != s.count (')'))
		{
			writeln (-1);
			continue;
		}

		int balance = 0;
		int res = 0;
		foreach (c; s)
		{
			bool ok = (balance >= 0);
			balance += (c == '(') ? +1 : -1;
			ok &= (balance >= 0);
			res += !ok;
		}
		writeln (res);
	}
}


import std.algorithm, std.conv, std.range, std.stdio, std.string;
void main () {
	foreach (test; 0..readln.strip.to !(int)) {
		auto n = readln.strip.to !(int);
		auto a = readln.splitter.map !(to !(int)).array;
		auto b = readln.splitter.map !(to !(int)).array;
		auto ar = a.retro, br = b.retro;
		int [int [2]] x, y;
		foreach (i; 0..n) {
			x[[a[i], ar[i]]] += 1;
			y[[b[i], br[i]]] += 1;
		}
		writeln (x == y ? "Yes" : "No");
	}
}

import std.algorithm, std.conv, std.range, std.stdio, std.string;
alias i = () => readln.strip.to!int, z = () => readln.split.map!(to!int).array;
void main() {
	foreach (t; 0..i()) {
		auto n = i(), a = z(), b = z(), p = a.retro, q = b.retro;
		int [int [2]] x, y;
		foreach (i; 0..n) x[[a[i], p[i]]]++, y[[b[i], q[i]]]++;
		writeln (x == y ? "Yes" : "No");
	}
}

import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main ()
{
	foreach (test; 0..readln.strip.to !(int))
	{
		auto n = readln.strip.to !(int);
		auto a = readln.splitter.map !(to !(int)).array;
		auto b = readln.splitter.map !(to !(int)).array;
		auto ar = a.retro;
		auto br = b.retro;
		int [int [2]] x;
		int [int [2]] y;
		foreach (i; 0..n)
		{
			x[[min (a[i], ar[i]), max (a[i], ar[i])]] += 1;
			y[[min (b[i], br[i]), max (b[i], br[i])]] += 1;
		}
		writeln (x == y ? "Yes" : "No");
	}
}


import std;

enum operation:bool { add, map };
union data_t {
    int a;
    struct {
        int x, y;
    }
}

struct query {
    operation t;
    data_t data;
}

int[500_010] ans;

void main () {
    int q;
    readf("%s\n", q);

    query[] vec = new query[q];

    foreach (ref e; vec) {
        char t;
        readf("%s ", t);
        if (t == '1') {
            readf("%s\n", e.data.a);
            e.t = operation.add;
        } else if (t == '2') {
            readf("%s %s\n", e.data.x, e.data.y);
            e.t = operation.map;
        } else
            assert(0);
    }

    foreach (int i, _; ans)
        ans[i] = i;

    int[] ret;
    ret.reserve(q);
    for (int i = q - 1; i > -1; -- i) {
        if (vec[i].t == operation.add)
            ret ~= ans[vec[i].data.a];
        else
            ans[vec[i].data.x] = ans[vec[i].data.y];
    }

    writefln("%(%s %)", ret.retro);
}

// ""

import std.stdio;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.conv;
import std.array;
import std.string;
import std.range;
import std.algorithm;
import core.bitop;
import core.stdc.stdio : scanf;

T read(T)() { return readln.chomp.to!T; }
T[] readarray(T)() { return readln.chomp.split(" ").map!(to!T).array; }
void chmin(T)(ref T a, in T b) { a = min(a, b); }
void chmax(T)(ref T a, in T b) { a = max(a, b); }

enum int MAX = 500_000;

class Node(T) {
    Node prev, next;
    T value;
    this(T x) {
        this.value = x;
        this.prev = null;
        this.next = null;
    }
}
struct List(T) {
    Node!T first = null, last = null;
    int len = 0;
    void insert(Node!T n) {
        if (len == 0) {
            first = n;
            last = n;
            n.prev = null;
            n.next = null;
        } else {
            last.next = n;
            n.prev = last;
            last = n;
        }
        len++;
    }
    void insert(List rhs) {
        if (rhs.len == 0) return;
        if (len == 0) {
            first = rhs.first;
            last = rhs.last;
            len = rhs.len;
        } else {
            last.next = rhs.first;
            rhs.first.prev = last;
            last = rhs.last;
            len += rhs.len;
        }
    }
}

void main() {
    int Q; readf("%d\n", &Q);
    auto es = new int[3][Q];
    foreach (q; 0 .. Q) {
        readf("%d", &es[q][0]);
        if (es[q][0] == 1) {
            readf(" %d\n", &es[q][1]);
        } else {
            readf(" %d %d\n", &es[q][1], &es[q][2]);
        }
    }

    auto I = new List!int[MAX+1];
    int k = 0;
    for (int q = 0; q < Q; q++) {
        auto e = es[q];
        if (e[0] == 1) {
            int x = e[1];
            I[x].insert(new Node!int(k++));
        } else {
            int x = e[1];
            int y = e[2];
            if (x == y) continue;
            I[y].insert(I[x]);
            I[x] = List!int();
        }
    }
    int[] A = new int[k];
    for (int x = 0; x <= MAX; x++) {
        auto n = I[x].first;
        while (n !is null) {
            int i = n.value;
            A[i] = x;
            n = n.next;
        }
    }
    writefln("%(%s %)", A);
}

import std.algorithm, std.array, std.container, std.conv, std.math, std.numeric, std.random, std.range, std.stdio, std.string, std.typecons, core.bitop;

void main()
{
  int q;
  readf!" %d "(q);
  int[] a;
  int[][] qlist;
  int[int] subst;
  while (q--) {
    qlist ~= readln.splitter.map!(to!int).array;
  }
  foreach_reverse (req ; qlist) {
    if (req[0] == 1) {
      int val = req[1];
      if (val in subst)
        val = subst[val];
      a ~= val;
    }
    else if (req[0] == 2) {
      if (req[2] in subst)
        req[2] = subst[req[2]];
      subst[req[1]] = req[2];
    }
  }
  writeln(a.retro.map!text.joiner(" "));
}

import std;

enum operation:bool { add, map };
union data_t {
    int a;
    struct {
        int x, y;
    }
}

struct query {
    operation t;
    data_t data;
}

int[500_010] jumpback;
int[500_010] ans;

int
root (in int value) {
    if (jumpback[value] != value)
        jumpback[value] = root(jumpback[value]);
    return jumpback[value];
}

void
map (int what, int to) {
    jumpback[what] = ans[what] = root(to);
}

void main () {
    int q;
    readf("%s\n", q);

    query[] vec = new query[q];

    foreach (ref e; vec) {
        char t;
        readf("%s ", t);
        if (t == '1') {
            readf("%s\n", e.data.a);
            e.t = operation.add;
        } else if (t == '2') {
            readf("%s %s\n", e.data.x, e.data.y);
            e.t = operation.map;
        } else
            assert(0);
    }

    foreach (int i, _; jumpback)
        ans[i] = jumpback[i] = i;

    int[] ret;
    ret.reserve(q);
    for (int i = q - 1; i > -1; -- i) {
        if (vec[i].t == operation.add)
            ret ~= ans[vec[i].data.a];
        else
            map(vec[i].data.x, vec[i].data.y);
    }

    writefln("%(%s %)", ret.retro);
}

// ""

import std;

enum operation:bool { add, map };
union data_t {
    int a;
    struct {
        int x, y;
    }
}

struct query {
    operation t;
    data_t data;
}

int[500_010] jumpback;

int
root (in int value) {
    if (jumpback[value] != value)
        jumpback[value] = root(jumpback[value]);
    return jumpback[value];
}

void
map (int what, int to) {
    jumpback[what] = root(to);
}

void main () {
    int q;
    readf("%s\n", q);

    query[] vec = new query[q];

    foreach (ref e; vec) {
        char t;
        readf("%s ", t);
        if (t == '1') {
            readf("%s\n", e.data.a);
            e.t = operation.add;
        } else if (t == '2') {
            readf("%s %s\n", e.data.x, e.data.y);
            e.t = operation.map;
        } else
            assert(0);
    }

    foreach (int i, _; jumpback)
        jumpback[i] = i;

    int[] ret;
    ret.reserve(q);
    for (int i = q - 1; i > -1; -- i) {
        if (vec[i].t == operation.add)
            ret ~= root(vec[i].data.a);
        else
            map(vec[i].data.x, vec[i].data.y);
    }

    writefln("%(%s %)", ret.retro);
}

// ""


import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }

void main() {
  try {
    for (; ; ) {
      const N = readInt();
      const KA = readLong();
      const KB = readLong();
      auto A = new long[N];
      foreach (i; 0 .. N) {
        A[i] = readLong();
      }
      auto B = new long[N];
      foreach (i; 0 .. N) {
        B[i] = readLong();
      }

      auto ds = new long[N];
      foreach (i; 0 .. N) {
        ds[i] = abs(B[i] - A[i]);
      }
      const dsSum = ds.sum;
      long ans;
      if (KA + KB >= dsSum) {
        ans = (KA + KB - dsSum) % 2;
      } else {
        foreach (k; 0 .. KA + KB) {
          const im = ds.maxIndex;
          --ds[im];
        }
        foreach (i; 0 .. N) {
          ans += ds[i]^^2;
        }
      }
      writeln(ans);
    }
  } catch (EOFException e) {
  }
}

/+ dub.sdl:
    name "B"
    dependency "dunkelheit" version=">=0.9.0"
+/

import std.stdio, std.algorithm, std.range, std.conv, std.math;
// import dkh.foundation, dkh.scanner;

int main() {
    Scanner sc = new Scanner(stdin);
    scope(exit) assert(!sc.hasNext);

    int n, k1, k2;
    sc.read(n, k1, k2);
    long[] a, b;
    sc.read(a, b);
    foreach (i; 0..n) a[i] = abs(a[i]-b[i]);

    foreach (ph; 0..k1+k2) {
        int i = a.maxIndex.to!int;
        a[i] = abs(a[i]-1);
    }

    writeln(a.map!"a*a".sum);
    return 0;
}
/* IMPORT /home/yosupo/Program/dunkelheit/source/dkh/container/stackpayload.d */
// module dkh.container.stackpayload;

struct StackPayload(T, size_t MINCAP = 4) if (MINCAP >= 1) {
    import core.exception : RangeError;

    private T* _data;
    private uint len, cap;

    @property bool empty() const { return len == 0; }
    @property size_t length() const { return len; }
    alias opDollar = length;

    inout(T)[] data() inout { return (_data) ? _data[0..len] : null; }

    ref inout(T) opIndex(size_t i) inout {
        version(assert) if (len <= i) throw new RangeError();
        return _data[i];
    }
    ref inout(T) front() inout { return this[0]; }
    ref inout(T) back() inout { return this[$-1]; }

    void reserve(size_t newCap) {
        import core.memory : GC;
        import core.stdc.string : memcpy;
        import std.conv : to;
        if (newCap <= cap) return;
        void* newData = GC.malloc(newCap * T.sizeof);
        cap = newCap.to!uint;
        if (len) memcpy(newData, _data, len * T.sizeof);
        _data = cast(T*)(newData);
    }
    void free() {
        import core.memory : GC;
        GC.free(_data);
    }

    void clear() {
        len = 0;
    }

    void insertBack(T item) {
        import std.algorithm : max;
        if (len == cap) reserve(max(cap * 2, MINCAP));
        _data[len++] = item;
    }
    alias opOpAssign(string op : "~") = insertBack;
    void removeBack() {
        assert(!empty, "StackPayload.removeBack: Stack is empty");
        len--;
    }
}

/* IMPORT /home/yosupo/Program/dunkelheit/source/dkh/foundation.d */

// module dkh.foundation;

static if (__VERSION__ <= 2070) {
    /*
    Copied by https://github.com/dlang/phobos/blob/master/std/algorithm/iteration.d
    Copyright: Andrei Alexandrescu 2008-.
    License: $(HTTP boost.org/LICENSE_1_0.txt, Boost License 1.0).
    */
    template fold(fun...) if (fun.length >= 1) {
        auto fold(R, S...)(R r, S seed) {
            import std.algorithm : reduce;
            static if (S.length < 2) {
                return reduce!fun(seed, r);
            } else {
                import std.typecons : tuple;
                return reduce!fun(tuple(seed), r);
            }
        }
    }

}
/* IMPORT /home/yosupo/Program/dunkelheit/source/dkh/scanner.d */
// module dkh.scanner;

// import dkh.container.stackpayload;

class Scanner {
    import std.stdio : File;
    import std.conv : to;
    import std.range : front, popFront, array, ElementType;
    import std.array : split;
    import std.traits : isSomeChar, isStaticArray, isArray;
    import std.algorithm : map;
    File f;
    this(File f) {
        this.f = f;
    }
    char[512] lineBuf;
    char[] line;
    private bool succW() {
        import std.range.primitives : empty, front, popFront;
        import std.ascii : isWhite;
        while (!line.empty && line.front.isWhite) {
            line.popFront;
        }
        return !line.empty;
    }
    private bool succ() {
        import std.range.primitives : empty, front, popFront;
        import std.ascii : isWhite;
        while (true) {
            while (!line.empty && line.front.isWhite) {
                line.popFront;
            }
            if (!line.empty) break;
            line = lineBuf[];
            f.readln(line);
            if (!line.length) return false;
        }
        return true;
    }

    private bool readSingle(T)(ref T x) {
        import std.algorithm : findSplitBefore;
        import std.string : strip;
        import std.conv : parse;
        if (!succ()) return false;
        static if (isArray!T) {
            alias E = ElementType!T;
            static if (isSomeChar!E) {

                auto r = line.findSplitBefore(" ");
                x = r[0].strip.dup;
                line = r[1];
            } else static if (isStaticArray!T) {
                foreach (i; 0..T.length) {
                    bool f = succW();
                    assert(f);
                    x[i] = line.parse!E;
                }
            } else {
                StackPayload!E buf;
                while (succW()) {
                    buf ~= line.parse!E;
                }
                x = buf.data;
            }
        } else {
            x = line.parse!T;
        }
        return true;
    }

    int unsafeRead(T, Args...)(ref T x, auto ref Args args) {
        if (!readSingle(x)) return 0;
        static if (args.length == 0) {
            return 1;
        } else {
            return 1 + read(args);
        }
    }
    void read(Args...)(auto ref Args args) {
        import std.exception;
        static if (args.length != 0) {
            enforce(readSingle(args[0]));
            read(args[1..$]);
        }
    }
    bool hasNext() {
        return succ();
    }
}

/*
This source code generated by dunkelheit and include dunkelheit's source code.
dunkelheit's Copyright: Copyright (c) 2016- Kohei Morita. (https://github.com/yosupo06/dunkelheit)
dunkelheit's License: MIT License(https://github.com/yosupo06/dunkelheit/blob/master/LICENSE.txt)
*/

import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readA(T)(size_t n,ref T[]t){t=new T[](n);auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int n, k1, k2; readV(n, k1, k2);
  int[] a; readA(n, a);
  int[] b; readA(n, b);

  auto c = new int[](n);
  foreach (i; 0..n) c[i] = (a[i]-b[i]).abs;
  auto h = c.heapify;

  foreach (_; 0..k1+k2) {
    auto hi = h.front;
    h.replaceFront((hi-1).abs);
  }

  auto ans = 0L;
  foreach (hi; h)
    ans += hi.to!long ^^ 2;

  writeln(ans);
}

/+ dub.sdl:
    name "B"
    dependency "dunkelheit" version=">=0.9.0"
+/

import std.stdio, std.algorithm, std.range, std.conv, std.math;
// import dkh.foundation, dkh.scanner;

int main() {
    Scanner sc = new Scanner(stdin);
    scope(exit) assert(!sc.hasNext);

    int n, k1, k2;
    sc.read(n, k1, k2);
    int[] a, b;
    sc.read(a, b);
    foreach (i; 0..n) a[i] = abs(a[i]-b[i]);

    foreach (ph; 0..k1+k2) {
        int i = a.maxIndex.to!int;
        a[i] = abs(a[i]-1);
    }

    writeln(a.map!"a*a".sum);
    return 0;
}
/* IMPORT /home/yosupo/Program/dunkelheit/source/dkh/container/stackpayload.d */
// module dkh.container.stackpayload;

struct StackPayload(T, size_t MINCAP = 4) if (MINCAP >= 1) {
    import core.exception : RangeError;

    private T* _data;
    private uint len, cap;

    @property bool empty() const { return len == 0; }
    @property size_t length() const { return len; }
    alias opDollar = length;

    inout(T)[] data() inout { return (_data) ? _data[0..len] : null; }

    ref inout(T) opIndex(size_t i) inout {
        version(assert) if (len <= i) throw new RangeError();
        return _data[i];
    }
    ref inout(T) front() inout { return this[0]; }
    ref inout(T) back() inout { return this[$-1]; }

    void reserve(size_t newCap) {
        import core.memory : GC;
        import core.stdc.string : memcpy;
        import std.conv : to;
        if (newCap <= cap) return;
        void* newData = GC.malloc(newCap * T.sizeof);
        cap = newCap.to!uint;
        if (len) memcpy(newData, _data, len * T.sizeof);
        _data = cast(T*)(newData);
    }
    void free() {
        import core.memory : GC;
        GC.free(_data);
    }

    void clear() {
        len = 0;
    }

    void insertBack(T item) {
        import std.algorithm : max;
        if (len == cap) reserve(max(cap * 2, MINCAP));
        _data[len++] = item;
    }
    alias opOpAssign(string op : "~") = insertBack;
    void removeBack() {
        assert(!empty, "StackPayload.removeBack: Stack is empty");
        len--;
    }
}

/* IMPORT /home/yosupo/Program/dunkelheit/source/dkh/foundation.d */

// module dkh.foundation;

static if (__VERSION__ <= 2070) {
    /*
    Copied by https://github.com/dlang/phobos/blob/master/std/algorithm/iteration.d
    Copyright: Andrei Alexandrescu 2008-.
    License: $(HTTP boost.org/LICENSE_1_0.txt, Boost License 1.0).
    */
    template fold(fun...) if (fun.length >= 1) {
        auto fold(R, S...)(R r, S seed) {
            import std.algorithm : reduce;
            static if (S.length < 2) {
                return reduce!fun(seed, r);
            } else {
                import std.typecons : tuple;
                return reduce!fun(tuple(seed), r);
            }
        }
    }

}
/* IMPORT /home/yosupo/Program/dunkelheit/source/dkh/scanner.d */
// module dkh.scanner;

// import dkh.container.stackpayload;

class Scanner {
    import std.stdio : File;
    import std.conv : to;
    import std.range : front, popFront, array, ElementType;
    import std.array : split;
    import std.traits : isSomeChar, isStaticArray, isArray;
    import std.algorithm : map;
    File f;
    this(File f) {
        this.f = f;
    }
    char[512] lineBuf;
    char[] line;
    private bool succW() {
        import std.range.primitives : empty, front, popFront;
        import std.ascii : isWhite;
        while (!line.empty && line.front.isWhite) {
            line.popFront;
        }
        return !line.empty;
    }
    private bool succ() {
        import std.range.primitives : empty, front, popFront;
        import std.ascii : isWhite;
        while (true) {
            while (!line.empty && line.front.isWhite) {
                line.popFront;
            }
            if (!line.empty) break;
            line = lineBuf[];
            f.readln(line);
            if (!line.length) return false;
        }
        return true;
    }

    private bool readSingle(T)(ref T x) {
        import std.algorithm : findSplitBefore;
        import std.string : strip;
        import std.conv : parse;
        if (!succ()) return false;
        static if (isArray!T) {
            alias E = ElementType!T;
            static if (isSomeChar!E) {

                auto r = line.findSplitBefore(" ");
                x = r[0].strip.dup;
                line = r[1];
            } else static if (isStaticArray!T) {
                foreach (i; 0..T.length) {
                    bool f = succW();
                    assert(f);
                    x[i] = line.parse!E;
                }
            } else {
                StackPayload!E buf;
                while (succW()) {
                    buf ~= line.parse!E;
                }
                x = buf.data;
            }
        } else {
            x = line.parse!T;
        }
        return true;
    }

    int unsafeRead(T, Args...)(ref T x, auto ref Args args) {
        if (!readSingle(x)) return 0;
        static if (args.length == 0) {
            return 1;
        } else {
            return 1 + read(args);
        }
    }
    void read(Args...)(auto ref Args args) {
        import std.exception;
        static if (args.length != 0) {
            enforce(readSingle(args[0]));
            read(args[1..$]);
        }
    }
    bool hasNext() {
        return succ();
    }
}

/*
This source code generated by dunkelheit and include dunkelheit's source code.
dunkelheit's Copyright: Copyright (c) 2016- Kohei Morita. (https://github.com/yosupo06/dunkelheit)
dunkelheit's License: MIT License(https://github.com/yosupo06/dunkelheit/blob/master/LICENSE.txt)
*/


import std.container;
import std.algorithm;
import std.range;
import std.array;
import std.stdio;
import std.utf;

DList!string _words;

void read(T...)(ref T t)
{
  void singleRead(W)(ref W w)
  {
    import std.stdio: readln;
    while(_words.empty)
      {
        import std.array: split;
        foreach(word; readln.split)
          {
            _words.insertBack(word);
          }
      }
    import std.conv: to;
    string word = _words.front;
    _words.removeFront;
    w = to!W(word);
  }
  static foreach(i; 0 .. T.length)
    {
      static if (is(typeof({foreach(ref e; t[i]){}})) && !is(T[i] == string))
        {
          foreach(ref element; t[i])
            read(element);
        }
      else
        {
          singleRead(t[i]);
        }
    }
}

auto next(T)()
{
  T t;
  read(t);
  return t;
}

size_t ind(T)(T t)
{
  return cast(size_t)t;
}

ref auto at(R, I)(ref R r, I i)
{
  return r[cast(size_t)i];
}

void set(R, I, V)(ref R r, I i, V v)
{
  r[cast(size_t)i] = v;
}

import std.conv;
import std.traits;
import std.meta;
int _loglevel = -1;
void _log(string functionName, argSeq...)()
{
  foreach(i; 0 .. _loglevel * 4)
    write(' ');
  write(functionName);
  static foreach(arg; argSeq)
    {
      write(" ", arg.stringof, " = ", arg);
    }
  writeln;
}
enum logCall =
  q{
    debug
    {
     {
     _loglevel++;
     alias _parameterTuple = ParameterIdentifierTuple!(mixin(split(__FUNCTION__, ".").back));
     static if (_parameterTuple.length > 0)
       mixin(`_log!(__FUNCTION__, `, [_parameterTuple].joiner(", ").array, `);`);
     else
       _log!(__FUNCTION__);
      }
     foreach(i; 0 .. _loglevel * 4) write(' ');
     writeln('{');
     scope(exit)
       {
         foreach(i; 0 .. _loglevel * 4) write(' ');
         writeln('}');
         _loglevel--;
       }
    }
};

void logSym(S...)(int line = __LINE__, string file = __FUNCTION__)
{
  debug
    {
      foreach(i; 0 .. _loglevel * 4) write(' ');
      write(file, "(", line, "):");
      static foreach(s; S)
        write(" ", s.stringof, " = ", s);
      writeln;

    }
}

Array!E makeArray(E, S)(S size, lazy E value = E.init)
{
  auto a = Array!E();
  a.length = cast(size_t) size;
  foreach(ref ai; a)
    ai = value();
  return a;
}
Array!E makeArray(E, S)(S size)
{
  auto a = Array!E();
  a.length = cast(size_t) size;
  return a;
}

class TreeNode
{
  TreeNode[2] children = [null, null];
  int noChildren()
  {
    return (children[0] !is null) + (children[1] !is null);
  }
  void insert(string str)
  {
    if (str.length == 0) return;
    size_t i = str[0] == '0'? 0 : 1;
    if (children[i] is null)
      children[i] = new TreeNode();
    children[i].insert(str[1 .. $]);
  }
}

int minans = int.max;
void dfs(TreeNode treeNode, int digit, int accans)
{
  int noChildren = treeNode.noChildren;
  if (noChildren == 0)
    {
      minans = min(accans, minans);
    }
  else if (noChildren == 1)
    {
      if (treeNode.children[0] !is null)
        dfs(treeNode.children[0], digit - 1, accans);
      else
        dfs(treeNode.children[1], digit - 1, accans);
    }
  else
    {
      dfs(treeNode.children[0], digit - 1, accans | (1 << digit));
      dfs(treeNode.children[1], digit - 1, accans | (1 << digit));
    }
}

void main()
{
  int n;
  read(n);
  string toString(int n)
  {
    char[] res = new char[30];
    foreach(i; 0 .. 30)
      {
        res[i] = ((n & (1 << (29 - i))) == 0)? '0' : '1';
      }
    return res.idup;
  }
  auto a = makeArray!string(n, toString(next!int));
  TreeNode root = new TreeNode();
  foreach(ai; a)
    root.insert(ai);
  dfs(root, 29, 0);
  writeln(minans);
}

//prewritten code: https://github.com/antma/algo
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.traits;

final class InputReader {
  private:
  ubyte[] p, buffer;
  bool eof;
  bool rawRead () {
    if (eof) {
      return false;
    }
    p = stdin.rawRead (buffer);
    if (p.empty) {
      eof = true;
      return false;
    }
    return true;
  }
  ubyte nextByte(bool check) () {
    static if (check) {
      if (p.empty) {
        if (!rawRead ()) {
          return 0;
        }
      }
    }
    auto r = p.front;
    p.popFront ();
    return r;
  }
  public:
  this () {
    buffer = uninitializedArray!(ubyte[])(16<<20);
  }
  bool seekByte (in ubyte lo) {
    while (true) {
      p = p.find! (c => c >= lo);
      if (!p.empty) {
        return false;
      }
      if (!rawRead ()) {
        return true;
      }
    }
  }
  template next(T) if (isSigned!T) {
    T next ()  {
      if (seekByte (45)) {
        return 0;
      }
      T res;
      ubyte b = nextByte!false ();
      if (b == 45) {
        while (true) {
          b = nextByte!true ();
          if (b < 48 || b >= 58) {
            return res;
          }
          res = res * 10 - (b - 48);
        }
      } else {
        res = b - 48;
        while (true) {
          b = nextByte!true ();
          if (b < 48 || b >= 58) {
            return res;
          }
          res = res * 10 + (b - 48);
        }
      }
    }
  }
  template next(T) if (isUnsigned!T) {
    T next () {
      if (seekByte (48)) {
        return 0;
      }
      T res = nextByte!false () - 48;
      while (true) {
        ubyte b = nextByte!true ();
        if (b < 48 || b >= 58) {
          break;
        }
        res = res * 10 + (b - 48);
      }
      return res;
    }
  }
  T[] nextA(T) (in int n) {
    auto a = uninitializedArray!(T[]) (n);
    foreach (i; 0 .. n) {
      a[i] = next!T;
    }
    return a;
  }
}

void main() {
  auto rd = new InputReader ();
  immutable n = rd.next!uint ();
  auto a = rd.nextA!uint (n);
  sort (a);
  a.length -= a.uniq.copy (a).length;
  immutable m = a.length.to!int;
  uint f (int l, int r, int k, uint start) {
    if (k < 0) return 0;
    debug stderr.writefln ("f %d %d %d %d",l, r, k, start);
    immutable uint mask = 1 << k;
    auto e = assumeSorted (a[l .. r]);
    immutable int mid = l + e.lowerBound (start + mask).length.to!int;
    debug stderr.writeln ("mid = ", mid);
    if (l < mid && mid < r) {
      return mask + min (f (l, mid, k - 1, start), f (mid, r, k - 1, start + mask));
    }
    return f (l, r, k - 1, (r == mid) ? start : (start + mask));
  }
  writeln (f (0, m, 29, 0U));
}

import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }
void modpow(ref long x, long y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }

void main()
{
	auto n = RD!int;
	auto a = RDA;

	bool[long][32] set;

	foreach (i; 0..32)
	{
		foreach (j; 0..n)
		{
			auto x = a[j] >> (31 - i);
			set[i][x] = true;
		}
	}

	long ans = long.max;
	foreach (i; 0..n)
	{
		long tmp;
		foreach (j; 0..32)
		{
			auto x = a[i] >> (31 - j);
			x ^= 1;
			if (set[j].get(x, false))
			{
				tmp += 1L << (31 - j);
			}
		}
		debug writeln(tmp);
		ans.chmin(tmp);
	}

	writeln(ans);
	stdout.flush;
	debug readln;
}

import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional, std.meta;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.typecons;

void main()
{
    int n;
    readf("%s", &n);
    readln;

    auto arr = readln.chomp.split.map!(to!int).array;

    auto tr = new int[int][] (1);
    int sz = 0;

    void add(int x) {
        debug { tr[0].writeln; }
        int nd = 0;
        foreach_reverse (b; 0 .. 30) {
            int dir = (x & (1 << b)) ? 1 : 0;
            if (dir !in tr[nd]) {
                int[int] dict;
                tr ~= dict;
                tr[nd][dir] = ++sz;
            }

            nd = tr[nd][dir];
        }
    }

    foreach (e; arr) {
        add(e);
    }

    debug { tr.writeln; }

    int dfs(int v, int lvl) {
        if (tr[v].empty()) { return 0; }

        if (tr[v].length == 1) {
            auto k = tr[v].keys[0];
            return dfs(tr[v][k], lvl-1);
        }

        return (1 << lvl)
            + min(dfs(tr[v][0], lvl-1), dfs(tr[v][1], lvl-1));
    }

    auto ans = dfs(0, 29);

    ans.writeln;
}

//prewritten code: https://github.com/antma/algo
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.traits;

final class InputReader {
  private:
  ubyte[] p, buffer;
  bool eof;
  bool rawRead () {
    if (eof) {
      return false;
    }
    p = stdin.rawRead (buffer);
    if (p.empty) {
      eof = true;
      return false;
    }
    return true;
  }
  ubyte nextByte(bool check) () {
    static if (check) {
      if (p.empty) {
        if (!rawRead ()) {
          return 0;
        }
      }
    }
    auto r = p.front;
    p.popFront ();
    return r;
  }
  public:
  this () {
    buffer = uninitializedArray!(ubyte[])(16<<20);
  }
  bool seekByte (in ubyte lo) {
    while (true) {
      p = p.find! (c => c >= lo);
      if (!p.empty) {
        return false;
      }
      if (!rawRead ()) {
        return true;
      }
    }
  }
  template next(T) if (isSigned!T) {
    T next ()  {
      if (seekByte (45)) {
        return 0;
      }
      T res;
      ubyte b = nextByte!false ();
      if (b == 45) {
        while (true) {
          b = nextByte!true ();
          if (b < 48 || b >= 58) {
            return res;
          }
          res = res * 10 - (b - 48);
        }
      } else {
        res = b - 48;
        while (true) {
          b = nextByte!true ();
          if (b < 48 || b >= 58) {
            return res;
          }
          res = res * 10 + (b - 48);
        }
      }
    }
  }
  template next(T) if (isUnsigned!T) {
    T next () {
      if (seekByte (48)) {
        return 0;
      }
      T res = nextByte!false () - 48;
      while (true) {
        ubyte b = nextByte!true ();
        if (b < 48 || b >= 58) {
          break;
        }
        res = res * 10 + (b - 48);
      }
      return res;
    }
  }
  T[] nextA(T) (in int n) {
    auto a = uninitializedArray!(T[]) (n);
    foreach (i; 0 .. n) {
      a[i] = next!T;
    }
    return a;
  }
}

void main() {
  auto rd = new InputReader ();
  immutable n = rd.next!uint ();
  auto a = rd.nextA!uint (n);
  sort (a);
  a.length -= a.uniq.copy (a).length;
  immutable m = a.length.to!int;
  uint f (int l, int r, int k, uint start) {
    if (k == 0) return 0;
    debug stderr.writefln ("f %d %d %d %d",l, r, k, start);
    immutable uint mask = 1 << k;
    auto e = assumeSorted (a[l .. r]);
    immutable int mid = l + e.lowerBound (start + mask).length.to!int;
    debug stderr.writeln ("mid = ", mid);
    if (l < mid && mid < r) {
      return mask + min (f (l, mid, k - 1, start), f (mid, r, k - 1, start + mask));
    }
    return f (l, r, k - 1, (r == mid) ? start : (start + mask));
  }
  writeln (f (0, m, 29, 0U));
}