QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#449962#8359. traveldefinieren51 260ms198600kbC++147.6kb2024-06-21 21:12:272024-06-21 21:12:28

Judging History

你现在查看的是最新测评结果

  • [2024-06-21 21:12:28]
  • 评测
  • 测评结果:51
  • 用时:260ms
  • 内存:198600kb
  • [2024-06-21 21:12:27]
  • 提交

answer

#include <bits/stdc++.h>

#define fir first
#define sec second
#ifdef LOCAL
#define dbg(x) cerr << "In Line " << __LINE__ << " the " << #x << " = " << x << '\n';
#define dpi(x, y) cerr << "In Line " << __LINE__ << " the " << #x << " = " << x << " ; " << "the " << #y << " = " << y << '\n';
#define dbgf(fmt, args...) fprintf(stderr, fmt, ##args);
#else
#define dbg(x) void();
#define dpi(x, y) void();
#define dbgf(fmt, args...) void();
#endif

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i128 = __int128_t;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using vi = vector<int>;
using vpii = vector<pii>;

bool Mbe;
constexpr int MOD = 998244353;
template<typename T> T add(T a, T b, T p = MOD) { return (a + b >= p) ? (a + b - p) : (a + b); }
template<typename T> T del(T a, T b, T p = MOD) { return (a - b < 0) ? (a - b + p) : (a - b); }
template<typename T> T mul(T a, T b, T p = MOD) { return 1ll * a * b % p; }
template<typename T> T cadd(T &a, T b, T p = MOD) { return a = add(a, b, p); }
template<typename T> T cdel(T &a, T b, T p = MOD) { return a = del(a, b, p); }
template<typename T> T cmul(T &a, T b, T p = MOD) { return a = mul(a, b, p); }
template<typename T> bool cmax(T &a, T b) { return a < b ? a = b, true : false; }
template<typename T> bool cmin(T &a, T b) { return a > b ? a = b, true : false; }

namespace FastIO {
	constexpr int LEN = 1 << 20;
	char in[LEN + 1], out[LEN + 1];
	char *pin = in, *pout = out, *ein = in, *eout = out + LEN;

	char gc() { return pin == ein && (ein = (pin = in) + fread(in, 1, LEN, stdin), ein == in) ? EOF : *pin ++; }
	void pc(char c) { pout == eout && (fwrite(out, 1, LEN, stdout), pout = out); (*pout ++) = c; return; }
	void Flush() { fwrite(out, 1, pout - out, stdout); pout = out; }

	template<typename T> T Read() {
		T x = 0; int f = 1; char ch = gc();
		while (ch < '0' || ch > '9') f = (ch == '-' ? (~f + 1) : f), ch = gc();
		while (ch >= '0' && ch <= '9') x = (x << 1) + (x << 3) + (ch ^ 48), ch = gc();
		return x * f;
	}
	template<typename T> void Write(T x, char c) {
		static char stk[40]; int tp = 0;
		if (x < 0) pc('-'), x = ~x + 1;
		do stk[tp++] = x % 10 + 48, x /= 10; while (x);
		while (tp --) pc(stk[tp]); pc(c); return;
	}
	void Read(char *s) {
		char ch = gc();
		while (!((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') ||
			(ch >= '0' && ch <= '9'))) ch = gc();
		while ((ch != EOF) && ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') ||
			(ch >= '0' && ch <= '9'))) *s = ch, s ++, ch = gc();
		*s = '\0'; return;
	}
	void Write(char *s) {
		while (*s != '\0') pc(*s), s ++; return;
	}
	void Puts(char *s) {
		Write(s), pc('\n'); return;
	}
}

#define getchar FastIO::gc
#define putchar FastIO::pc
#define Flush FastIO::Flush
#define Read FastIO::Read
#define Write FastIO::Write
#define Puts FastIO::Puts

constexpr int N = 5e5 + 5, LG = 19;
int n, op; ll k;

namespace Solve2 {
int rt, sz[N], mxp[N], dfn[N], ord[N], dfc, dep[N], bel[N];
pair<int, int> st[LG][N];
priority_queue<pair<int, int>> Q;
multiset<pair<int, int>> s;
vector<int> son, G[N];
vector<pair<int, int>> dis[N], rng[N];
bool mrk[N];

void Get_Root(int u, int fa) {
	sz[u] = 1, mxp[u] = 0;
	for (auto v : G[u]) if (v ^ fa)
		Get_Root(v, u), sz[u] += sz[v], cmax(mxp[u], sz[v]);
	cmax(mxp[u], n - sz[u]), rt = mxp[u] < mxp[rt] ? u : rt;
	return;
}
void Dfs1(int u, int fa, int anc) {
	sz[ord[dfn[u] = ++ dfc] = u] = 1, bel[u] = anc;
	st[0][dfn[u]] = make_pair(dep[u] = dep[fa] + 1, fa);
	for (auto v : G[u]) if (v ^ fa) Dfs1(v, u, anc), sz[u] += sz[v];
	return;
}
pair<int, int> ST_Query(int l, int r) {
	int k = __lg(r - l + 1);
	return min(st[k][l], st[k][r - (1 << k) + 1]);
}
int Get_Lca(int u, int v) {
	if (u == v) return u;
	if ((u = dfn[u]) > (v = dfn[v])) swap(u, v);
	return ST_Query(u + 1, v).sec;
}

void Main() {
	for (int i = 1; i < n; i ++) {
		int u = Read<int>(), v = Read<int>();
		G[u].emplace_back(v), G[v].emplace_back(u);
	}
	mxp[0] = n + 1, Get_Root(1, rt = 0);
	sz[rt] = dep[rt] = 0, dfn[rt] = dfc = 1, bel[rt] = rt, ord[1] = rt;
	for (auto u : G[rt]) son.emplace_back(u), Dfs1(u, rt, u), sz[rt] += sz[u];
	for (int i = 1; i < LG; i ++)
		for (int j = 1; j + (1 << i) - 1 <= n; j ++)
			st[i][j] = min(st[i - 1][j], st[i - 1][j + (1 << i - 1)]);
	{
		ll L = 2 * (n - 1), R = 0;
		for (int u = 1; u <= n; u ++) R += dep[u]; R <<= 1;
//		cout << L << ' ' << R << endl;
		if ((k & 1) || k < L || k > R) { Puts("-1"); return; }
		k = (R - k) >> 1;
	};
	for (int i = 1; i <= n; i ++) {
		if (bel[ord[i]] != bel[ord[i + 1]]) continue;
		dis[bel[ord[i]]].emplace_back(dep[Get_Lca(ord[i], ord[i + 1])], ord[i]);
	}
	for (auto u : son) if (dis[u].size())
		sort(dis[u].begin(), dis[u].end()), Q.emplace(make_pair(dis[u].size(), u));
//	for (auto u : son) {
//		cout << u << ": ";
//		for (auto dist : dis[u]) cout << dist.fir << ' ';
//		cout << endl;
//	}
	if (k) {
		while (Q.size()) {
			int u = Q.top().sec; Q.pop();
			int dist, v; tie(dist, v) = dis[u].back();
			if (dist < k) k -= dist, dis[u].pop_back(), mrk[v] = true;
			else {
				while (dis[u].back().fir > k) dis[u].pop_back();
				mrk[dis[u].back().sec] = true, k = 0; break;
			}
			if (dis[u].size()) Q.emplace(dis[u].size(), u);
		}
	}
	for (int l = 1, r; l <= n; l = r + 1) {
		r = l;
		while (bel[ord[r + 1]] == bel[ord[l]] && mrk[ord[r]]) r ++;
		rng[bel[ord[l]]].emplace_back(l, r);
	}
	{
		Write(rt, ' ');
//		for (int i = 1; i <= n; i ++) cout << ord[i] << ' '; cout << endl;
//		for (auto u : son) for (auto _ : rng[u])
//			cout << u << ": " << '[' << _.fir << ',' << _.sec << ']' << endl;
//		cout << endl;
		for (auto u : son) s.insert({rng[u].size(), u});
		while (s.size() > 1) {
			int u = (*-- s.end()).sec; s.erase(-- s.end());
			int v = (*-- s.end()).sec; s.erase(-- s.end());
			int l, r; tie(l, r) = rng[u].back(); rng[u].pop_back();
			for (int i = l; i <= r; i ++) Write(ord[i], ' ');
			tie(l, r) = rng[v].back(); rng[v].pop_back();
			for (int i = l; i <= r; i ++) Write(ord[i], ' ');
			if (rng[u].size()) s.insert({rng[u].size(), u});
			if (rng[v].size()) s.insert({rng[v].size(), v});
		}
		if (s.size()) {
			int u = (*s.begin()).sec, l, r;
			assert(rng[u].size() == 1);
			tie(l, r) = rng[u].back(); rng[u].pop_back();
			assert(rng[u].empty());
			for (int i = l; i <= r; i ++) Write(ord[i], ' ');
		}
		Puts("");
	};
	return;
}
void Clear() {
	rt = dfc = 0; while (Q.size()) Q.pop();
	son.clear(), s.clear();
	for (int i = 1; i <= n; i ++) {
		G[i].clear(), sz[i] = mxp[i] = dfn[i] = ord[i] = dep[i] = 0;
		bel[i] = 0, mrk[i] = false, dis[i].clear(), rng[i].clear();
		for (int j = 0; j < LG; j ++) st[j][i] = {0, 0};
	}
	return;
}
}

namespace Solve1 {
vector<int> G[N];

void Main() {
	for (int i = 1; i < n; i ++) {
		int u = Read<int>(), v = Read<int>();
//		G[u].emplace_back(v), G[v].emplace_back(u);
	}
	Puts("-1");
	return;
}
void Clear() {
	
	return;
}
}

void slv() {
	n = Read<int>(), k = Read<ll>(), op = Read<int>();
	if (n == 1) { k ? Puts("-1") : Puts("1"); return; }
	if (n == 2) { Read<int>(), Read<int>(), k == op ? Puts("1 2") : Puts("-1"); return; }
	return op == 1 ? (Solve1::Main(), Solve1::Clear()) : (Solve2::Main(), Solve2::Clear());
}
void clr() {

	return;
}

bool Med;
int main() {
#ifdef LOCAL
	freopen("!in.in", "r", stdin);
	freopen("!out.out", "w", stdout);
	fprintf(stderr, "%.3lf Mb\n", fabs((&Mbe - &Med) / 1048576.0));
#endif
//	int T = 1;
	int T = Read<int>();
	while (T --) slv(), clr();
	Flush();
#ifdef LOCAL
	fprintf(stderr, "%d ms\n", (int)clock());
#endif
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 2
Accepted

Test #1:

score: 2
Accepted
time: 12ms
memory: 54488kb

input:

0

output:


result:

ok Accepted.

Subtask #2:

score: 2
Acceptable Answer

Test #2:

score: 2
Acceptable Answer
time: 8ms
memory: 92032kb

input:

5
9 28 2
8 6
6 3
3 2
9 5
4 1
1 5
5 2
2 7
9 16 2
1 3
7 8
4 2
2 9
9 8
8 6
6 3
3 5
9 12 1
7 5
5 9
9 2
2 8
6 1
1 8
8 4
4 3
9 22 1
8 5
2 4
4 1
1 6
6 9
7 9
9 5
5 3
9 27 1
2 6
4 8
8 1
5 9
9 1
1 7
7 6
6 3

output:

2 4 8 9 1 6 7 5 3 
8 9 2 4 7 6 3 1 5 
-1
-1
-1

result:

points 0.50 Partially Correct | type = 2

Test #3:

score: 2
Acceptable Answer
time: 7ms
memory: 90840kb

input:

5
9 16 2
4 3
3 1
7 6
2 8
8 6
6 1
1 5
9 5
9 12 1
6 7
5 4
4 1
1 3
3 2
2 7
8 7
7 9
9 14 1
1 2
2 3
6 4
8 9
9 3
3 4
5 4
4 7
9 12 1
9 4
4 1
1 5
3 2
2 6
6 5
8 5
5 7
9 9 1
8 7
7 3
3 2
2 9
4 9
9 1
1 6
6 5

output:

1 6 7 8 2 5 9 3 4 
-1
-1
-1
-1

result:

points 0.50 Partially Correct | type = 2

Test #4:

score: 2
Acceptable Answer
time: 3ms
memory: 72180kb

input:

5
9 13 1
4 7
7 8
8 5
1 9
2 5
3 5
5 9
9 6
9 16 2
7 3
1 5
5 8
8 9
2 3
4 9
9 3
3 6
9 26 1
1 3
3 8
8 9
7 4
2 6
6 9
9 4
4 5
9 25 1
5 3
7 2
2 4
4 9
6 1
1 9
9 3
3 8
9 14 1
3 8
8 5
5 4
7 6
6 4
4 2
2 9
9 1

output:

-1
9 8 5 1 4 3 7 2 6 
-1
-1
-1

result:

points 0.50 Partially Correct | type = 2

Test #5:

score: 2
Acceptable Answer
time: 8ms
memory: 80780kb

input:

5
9 27 1
8 2
6 9
9 1
4 5
5 1
1 2
2 7
7 3
9 16 2
2 6
6 9
7 8
8 4
1 4
5 4
4 9
9 3
9 30 1
6 7
9 4
4 2
2 5
1 5
5 3
3 7
7 8
9 12 1
4 1
8 6
6 3
2 5
5 1
1 3
3 7
7 9
9 22 1
2 3
7 8
8 1
1 9
9 5
5 3
3 4
6 4

output:

-1
4 9 6 2 3 8 7 5 1 
-1
-1
-1

result:

points 0.50 Partially Correct | type = 2

Test #6:

score: 2
Acceptable Answer
time: 12ms
memory: 60688kb

input:

5
9 18 2
7 3
3 8
8 4
4 9
9 1
1 5
2 6
5 6
9 26 2
8 3
3 9
9 5
4 2
2 5
6 7
7 5
5 1
9 25 1
1 5
5 9
9 6
2 4
7 6
6 8
8 4
4 3
9 26 2
1 9
9 4
4 6
5 7
3 7
7 6
6 2
2 8
9 26 2
1 4
4 6
6 8
3 9
9 2
5 8
8 7
7 2

output:

9 5 6 2 4 8 3 7 1 
5 8 6 3 4 9 7 2 1 
-1
6 1 3 9 8 7 5 4 2 
8 1 9 3 4 7 2 6 5 

result:

points 0.50 Partially Correct | type = 2

Test #7:

score: 2
Acceptable Answer
time: 7ms
memory: 81348kb

input:

5
9 13 1
2 4
5 8
8 1
6 9
9 7
7 1
1 4
4 3
9 29 2
3 2
1 8
8 4
4 6
6 7
5 2
2 9
9 7
9 15 2
1 3
3 7
7 2
2 9
4 5
5 9
9 6
6 8
9 31 1
2 9
9 8
8 6
6 5
5 4
7 4
4 1
1 3
9 21 2
7 2
2 5
1 4
3 6
6 5
9 4
4 5
5 8

output:

-1
-1
-1
-1
-1

result:

points 0.50 Partially Correct | type = 2

Test #8:

score: 4
Accepted
time: 4ms
memory: 54616kb

input:

5
1 0 1
1 0 2
1 0 2
1 0 1
1 0 2

output:

1
1
1
1
1

result:

ok Accepted.

Subtask #3:

score: 4
Acceptable Answer

Dependency #2:

50%
Acceptable Answer

Test #9:

score: 4
Acceptable Answer
time: 8ms
memory: 82800kb

input:

5
13 37 1
3 12
12 7
4 13
13 11
11 8
8 6
1 2
10 9
9 7
7 5
5 6
6 2
13 42 1
2 4
4 13
13 5
5 7
7 12
8 6
6 9
1 10
10 11
3 9
9 12
12 11
13 15 1
9 2
2 11
12 4
4 5
5 6
6 3
3 11
8 13
13 1
7 11
11 10
10 1
13 48 1
11 3
3 4
12 1
7 5
5 8
8 2
2 1
10 1
1 4
4 6
13 9
9 6
13 68 2
13 4
6 5
2 1
1 9
9 11
11 12
12 7
7 5
...

output:

-1
-1
-1
-1
5 10 2 3 1 13 9 4 11 8 7 12 6 

result:

points 0.50 Partially Correct | type = 2

Test #10:

score: 4
Acceptable Answer
time: 7ms
memory: 92816kb

input:

5
13 34 2
2 7
5 11
13 1
1 3
8 9
9 6
6 11
11 3
3 7
7 12
12 4
4 10
13 17 1
2 7
7 11
11 9
10 12
12 4
6 13
13 4
4 8
8 3
3 1
1 9
9 5
13 33 1
7 6
6 1
1 10
10 13
9 4
11 12
12 13
8 13
2 4
4 13
13 3
5 3
13 17 1
8 11
11 13
13 3
3 5
10 2
2 1
1 6
12 7
6 5
5 4
4 9
9 7
13 15 1
5 1
8 3
2 13
13 11
11 6
6 7
7 9
9 1
...

output:

3 6 9 8 12 4 10 5 2 13 11 7 1 
-1
-1
-1
-1

result:

points 0.50 Partially Correct | type = 2

Test #11:

score: 8
Accepted
time: 4ms
memory: 81512kb

input:

5
13 24 2
1 5
11 12
12 2
2 10
4 9
9 3
6 13
13 8
8 5
5 10
10 3
3 7
13 28 2
13 5
5 7
7 3
9 6
4 10
8 12
1 12
12 6
6 3
3 2
2 10
10 11
13 50 2
4 13
13 8
8 10
10 1
3 5
12 7
7 1
1 9
9 5
5 2
6 2
11 2
13 64 2
10 3
3 9
9 7
7 11
11 5
5 13
6 2
2 8
4 8
1 13
13 8
8 12
13 52 2
13 12
12 8
8 10
5 6
6 11
9 2
7 2
1 10...

output:

10 5 1 8 13 6 3 9 4 7 2 12 11 
3 9 12 8 1 10 4 11 7 5 13 6 2 
1 4 6 11 13 2 8 5 3 12 10 9 7 
13 10 12 3 4 9 6 7 2 11 8 5 1 
2 3 13 1 5 12 6 8 11 10 9 7 4 

result:

ok Accepted.

Test #12:

score: 4
Acceptable Answer
time: 8ms
memory: 80264kb

input:

5
13 34 1
8 11
11 2
2 10
9 6
3 1
4 13
13 7
7 6
6 12
12 1
1 10
10 5
13 31 1
11 1
1 9
9 5
6 7
7 2
13 4
4 2
2 10
10 12
12 8
8 5
5 3
13 28 2
2 8
8 9
9 6
6 7
4 13
13 11
11 7
7 5
5 1
12 1
1 3
3 10
13 49 1
11 4
4 1
1 8
8 12
12 3
3 7
6 2
13 7
7 5
2 10
10 9
9 5
13 62 1
12 9
9 5
5 6
6 1
1 4
4 2
2 3
8 11
7 10
...

output:

-1
-1
7 9 8 2 1 12 3 10 11 13 4 6 5 
-1
-1

result:

points 0.50 Partially Correct | type = 2

Test #13:

score: 4
Acceptable Answer
time: 3ms
memory: 79656kb

input:

5
13 59 1
10 9
3 8
8 7
7 6
6 12
4 1
13 5
5 12
12 2
2 9
9 1
1 11
13 30 2
9 5
2 1
1 3
3 12
12 8
8 7
7 6
11 10
10 5
5 6
4 6
13 6
13 54 1
11 13
13 12
12 10
9 3
3 5
4 2
6 10
10 7
7 5
5 2
1 2
2 8
13 24 2
2 11
5 12
12 4
8 3
3 6
6 7
7 1
10 9
9 4
4 1
1 11
11 13
13 56 2
3 2
2 8
4 9
9 1
1 5
7 10
10 5
5 11
11 8...

output:

-1
6 10 11 8 12 3 1 2 9 13 7 5 4 
-1
1 11 2 13 7 6 3 8 4 12 5 9 10 
11 7 13 10 12 4 6 9 3 1 8 2 5 

result:

points 0.50 Partially Correct | type = 2

Test #14:

score: 4
Acceptable Answer
time: 8ms
memory: 63612kb

input:

5
13 21 2
1 11
11 10
12 6
6 8
8 2
2 4
4 7
9 5
5 3
13 10
10 3
3 7
13 34 1
11 4
4 12
2 13
13 8
8 5
10 6
7 1
3 6
6 12
12 9
1 5
5 9
13 137 2
7 9
13 12
12 4
4 5
5 10
10 11
11 9
9 8
2 1
8 3
3 1
6 1
13 13 1
13 12
12 2
2 8
8 9
9 3
3 10
1 10
10 6
7 5
5 6
6 11
11 4
13 25 2
6 9
4 12
12 5
5 1
1 3
7 13
13 9
9 8
...

output:

-1
-1
-1
-1
-1

result:

points 0.50 Partially Correct | type = 2

Test #15:

score: 8
Accepted
time: 4ms
memory: 54196kb

input:

5
1 0 1
1 0 2
1 0 2
1 0 1
1 0 2

output:

1
1
1
1
1

result:

ok Accepted.

Subtask #4:

score: 7
Acceptable Answer

Test #16:

score: 7
Acceptable Answer
time: 3ms
memory: 67392kb

input:

200
9 38 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 26 2
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
10 30 2
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
9 30 2
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
10 28 2
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 41 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 44 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10...

output:

-1
5 2 1 8 9 3 6 7 4 
6 9 10 3 2 1 8 4 7 5 
5 8 9 1 7 3 2 6 4 
6 3 2 1 9 10 4 7 8 5 
-1
-1
6 4 3 2 1 7 8 9 10 5 
-1
-1
-1
-1
6 10 2 1 9 3 8 4 7 5 
5 1 9 2 7 8 3 6 4 
6 2 1 10 3 9 4 7 8 5 
5 7 8 9 2 1 6 4 3 
-1
5 2 1 8 9 3 6 7 4 
6 10 1 9 3 2 8 4 7 5 
-1
-1
-1
6 2 1 9 10 3 8 4 7 5 
-1
6 7 8 9 10 5 4 ...

result:

points 0.50 Partially Correct | type = 2

Test #17:

score: 7
Acceptable Answer
time: 7ms
memory: 65752kb

input:

200
9 8 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 17 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 8 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
10 45 2
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
9 29 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
10 51 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
9 39 2
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 16 2
1 2
2 ...

output:

-1
-1
-1
-1
-1
-1
-1
5 6 7 8 9 4 3 2 1 
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
6 7 8 9 10 5 4 3 2 1 
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
5 6 7 8 9 4 3 2 1 
-1
-1
-1
-1
-1
-1
-1
-1
-1
5 6 7 8 9...

result:

points 0.50 Partially Correct | type = 2

Test #18:

score: 14
Accepted
time: 3ms
memory: 54728kb

input:

2000
1 0 2
1 0 1
1 0 1
1 0 2
1 0 2
1 0 1
1 0 2
1 0 1
1 0 1
1 0 2
1 0 1
1 0 1
1 0 1
1 0 2
1 0 2
1 0 1
1 0 2
1 0 2
1 0 1
1 0 1
1 0 2
1 0 1
1 0 2
1 0 2
1 0 1
1 0 2
1 0 2
1 0 1
1 0 2
1 0 1
1 0 1
1 0 1
1 0 1
1 0 2
1 0 2
1 0 2
1 0 1
1 0 1
1 0 1
1 0 2
1 0 2
1 0 1
1 0 2
1 0 2
1 0 1
1 0 1
1 0 2
1 0 2
1 0 1
1...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok Accepted.

Test #19:

score: 7
Acceptable Answer
time: 18ms
memory: 70656kb

input:

50
37 420 2
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 57 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17...

output:

19 5 4 3 2 1 33 34 35 36 37 6 32 7 31 8 30 9 29 10 27 28 11 26 12 25 13 24 14 23 15 22 16 21 17 20 18 
-1
-1
-1
21 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 23 19 18 22 20 
19 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 15 14 13 12 11 10 9 8 7 6...

result:

points 0.50 Partially Correct | type = 2

Test #20:

score: 7
Acceptable Answer
time: 0ms
memory: 64872kb

input:

20
90 206 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52...

output:

-1
49 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 41 57 42 56 43 55 44 54 45 53 46 52 47 50 51 48 
-1
47 45 44 43 42...

result:

points 0.50 Partially Correct | type = 2

Test #21:

score: 7
Acceptable Answer
time: 4ms
memory: 65092kb

input:

5
384 396 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52...

output:

-1
187 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 2...

result:

points 0.50 Partially Correct | type = 2

Test #22:

score: 7
Acceptable Answer
time: 9ms
memory: 63488kb

input:

5
378 26744 2
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 ...

output:

190 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 ...

result:

points 0.50 Partially Correct | type = 2

Test #23:

score: 7
Acceptable Answer
time: 12ms
memory: 54492kb

input:

1
1934 290581 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
5...

output:

-1

result:

points 0.50 Partially Correct | type = 2

Test #24:

score: 14
Accepted
time: 3ms
memory: 70436kb

input:

1
1919 3856 2
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 ...

output:

960 956 955 954 953 952 951 950 949 948 947 946 945 944 943 942 941 940 939 938 937 936 935 934 933 932 931 930 929 928 927 926 925 924 923 922 921 920 919 918 917 916 915 914 913 912 911 910 909 908 907 906 905 904 903 902 901 900 899 898 897 896 895 894 893 892 891 890 889 888 887 886 885 884 883 ...

result:

ok Accepted.

Test #25:

score: 7
Acceptable Answer
time: 7ms
memory: 53440kb

input:

1
1835 1628390 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
...

output:

-1

result:

points 0.50 Partially Correct | type = 2

Test #26:

score: 14
Accepted
time: 4ms
memory: 66592kb

input:

1
1854 642226 2
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
5...

output:

928 362 361 360 359 358 357 356 355 354 353 352 351 350 349 348 347 346 345 344 343 342 341 340 339 338 337 336 335 334 333 332 331 330 329 328 327 326 325 324 323 322 321 320 319 318 317 316 315 314 313 312 311 310 309 308 307 306 305 304 303 302 301 300 299 298 297 296 295 294 293 292 291 290 289 ...

result:

ok Accepted.

Subtask #5:

score: 5
Acceptable Answer

Dependency #4:

50%
Acceptable Answer

Test #27:

score: 10
Accepted
time: 16ms
memory: 55068kb

input:

500000
1 0 1
1 0 2
1 0 2
1 0 1
1 0 2
1 0 2
1 0 2
1 0 2
1 0 2
1 0 2
1 0 2
1 0 2
1 0 1
1 0 1
1 0 1
1 0 1
1 0 2
1 0 2
1 0 2
1 0 1
1 0 2
1 0 2
1 0 1
1 0 1
1 0 2
1 0 1
1 0 2
1 0 2
1 0 2
1 0 1
1 0 1
1 0 2
1 0 2
1 0 2
1 0 2
1 0 2
1 0 2
1 0 2
1 0 2
1 0 2
1 0 1
1 0 1
1 0 2
1 0 2
1 0 2
1 0 2
1 0 1
1 0 1
1 0 2...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok Accepted.

Test #28:

score: 5
Acceptable Answer
time: 73ms
memory: 95328kb

input:

5
93044 1765038246 2
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50...

output:

46523 76229 76230 76231 76232 76233 76234 76235 76236 76237 76238 76239 76240 76241 76242 76243 76244 76245 76246 76247 76248 76249 76250 76251 76252 76253 76254 76255 76256 76257 76258 76259 76260 76261 76262 76263 76264 76265 76266 76267 76268 76269 76270 76271 76272 76273 76274 76275 76276 76277 ...

result:

points 0.50 Partially Correct | type = 2

Test #29:

score: 10
Accepted
time: 91ms
memory: 193876kb

input:

1
481849 965190 2
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51...

output:

240925 240897 240896 240895 240894 240893 240892 240891 240890 240889 240888 240887 240886 240885 240884 240883 240882 240881 240880 240879 240878 240877 240876 240875 240874 240873 240872 240871 240870 240869 240868 240867 240866 240865 240864 240863 240862 240861 240860 240859 240858 240857 240856...

result:

ok Accepted.

Test #30:

score: 10
Accepted
time: 95ms
memory: 198600kb

input:

1
494761 38887392602 2
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
...

output:

247381 386820 386821 386822 386823 386824 386825 386826 386827 386828 386829 386830 386831 386832 386833 386834 386835 386836 386837 386838 386839 386840 386841 386842 386843 386844 386845 386846 386847 386848 386849 386850 386851 386852 386853 386854 386855 386856 386857 386858 386859 386860 386861...

result:

ok Accepted.

Test #31:

score: 5
Acceptable Answer
time: 21ms
memory: 54960kb

input:

1
490645 44453587331 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
...

output:

-1

result:

points 0.50 Partially Correct | type = 2

Test #32:

score: 5
Acceptable Answer
time: 21ms
memory: 54972kb

input:

1
456012 71620971179 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
...

output:

-1

result:

points 0.50 Partially Correct | type = 2

Test #33:

score: 5
Acceptable Answer
time: 20ms
memory: 104132kb

input:

5000
98 194 2
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 ...

output:

50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 
-1
-1
-1
-1
-1...

result:

points 0.50 Partially Correct | type = 2

Test #34:

score: 5
Acceptable Answer
time: 23ms
memory: 101756kb

input:

20000
23 84 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
24 216 2
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
23 154 2
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
...

output:

-1
13 3 2 1 23 24 4 22 5 21 6 20 7 18 19 8 17 9 16 10 15 11 14 12 
12 4 3 2 1 20 21 22 23 5 19 6 18 7 17 8 16 9 15 10 13 14 11 
-1
-1
12 23 1 22 2 21 3 20 4 19 5 18 6 17 7 16 8 15 9 14 10 13 11 
-1
-1
13 4 3 2 1 22 23 24 5 21 6 20 7 19 8 18 9 17 10 16 11 14 15 12 
-1
-1
-1
-1
-1
13 17 18 19 20 21 22...

result:

points 0.50 Partially Correct | type = 2

Test #35:

score: 5
Acceptable Answer
time: 32ms
memory: 102024kb

input:

2000
231 5063 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
5...

output:

-1
114 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 ...

result:

points 0.50 Partially Correct | type = 2

Test #36:

score: 5
Acceptable Answer
time: 35ms
memory: 104208kb

input:

200
2422 1517004 2
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 5...

output:

1212 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 ...

result:

points 0.50 Partially Correct | type = 2

Test #37:

score: 5
Acceptable Answer
time: 36ms
memory: 103672kb

input:

50
9167 6418302 2
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51...

output:

4584 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 ...

result:

points 0.50 Partially Correct | type = 2

Test #38:

score: 5
Acceptable Answer
time: 34ms
memory: 112756kb

input:

20
24105 203761007 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50...

output:

-1
-1
11798 21600 21601 21602 21603 21604 21605 21606 21607 21608 21609 21610 21611 21612 21613 21614 21615 21616 21617 21618 21619 21620 21621 21622 21623 21624 21625 21626 21627 21628 21629 21630 21631 21632 21633 21634 21635 21636 21637 21638 21639 21640 21641 21642 21643 21644 21645 21646 21647 ...

result:

points 0.50 Partially Correct | type = 2

Test #39:

score: 5
Acceptable Answer
time: 50ms
memory: 119804kb

input:

10
48337 97528 2
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
...

output:

24169 24190 24191 24192 24193 24194 24195 24196 24197 24198 24199 24200 24201 24202 24203 24204 24205 24206 24207 24208 24209 24210 24211 24212 24213 24214 24215 24216 24217 24218 24219 24220 24221 24222 24223 24224 24225 24226 24227 24228 24229 24230 24231 24232 24233 24234 24235 24236 24237 24238 ...

result:

points 0.50 Partially Correct | type = 2

Test #40:

score: 5
Acceptable Answer
time: 44ms
memory: 116300kb

input:

10
48412 869174248 2
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50...

output:

24207 45053 45054 45055 45056 45057 45058 45059 45060 45061 45062 45063 45064 45065 45066 45067 45068 45069 45070 45071 45072 45073 45074 45075 45076 45077 45078 45079 45080 45081 45082 45083 45084 45085 45086 45087 45088 45089 45090 45091 45092 45093 45094 45095 45096 45097 45098 45099 45100 45101 ...

result:

points 0.50 Partially Correct | type = 2

Test #41:

score: 5
Acceptable Answer
time: 55ms
memory: 120048kb

input:

5
91193 4099928074 2
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50...

output:

45597 90873 90874 90875 90876 90877 90878 90879 90880 90881 90882 90883 90884 90885 90886 90887 90888 90889 90890 90891 90892 90893 90894 90895 90896 90897 90898 90899 90900 90901 90902 90903 90904 90905 90906 90907 90908 90909 90910 90911 90912 90913 90914 90915 90916 90917 90918 90919 90920 90921 ...

result:

points 0.50 Partially Correct | type = 2

Subtask #6:

score: 6
Acceptable Answer

Dependency #3:

50%
Acceptable Answer

Test #42:

score: 6
Acceptable Answer
time: 7ms
memory: 53472kb

input:

5
28 65 1
11 9
9 16
16 22
22 21
21 12
14 5
5 27
7 4
4 28
28 20
20 24
8 1
1 25
13 3
3 6
6 2
2 15
17 18
18 19
19 12
12 23
15 24
24 25
25 10
10 27
27 23
23 26
30 74 1
24 2
21 25
4 26
26 15
15 6
6 18
5 20
20 19
19 12
12 8
17 3
3 13
13 29
29 9
27 7
7 14
11 1
1 8
8 16
16 30
30 28
22 2
10 28
28 14
14 18
18...

output:

-1
-1
-1
-1
-1

result:

points 0.50 Partially Correct | type = 2

Test #43:

score: 12
Accepted
time: 4ms
memory: 100168kb

input:

5
27 286 2
22 12
25 2
2 15
15 3
20 16
13 26
27 10
10 21
21 1
1 23
19 24
24 4
4 7
7 26
26 6
6 3
3 18
18 23
11 8
8 9
9 14
14 17
17 12
12 16
16 23
23 5
27 51 2
11 18
18 19
12 10
10 2
4 3
3 5
15 23
23 6
6 9
22 7
26 24
24 13
13 14
14 2
25 7
16 20
20 19
19 17
17 8
1 7
8 2
2 9
9 7
7 5
5 27
27 21
29 56 2
29...

output:

-1
-1
5 21 14 20 28 26 1 19 25 7 8 10 9 24 12 16 23 27 4 29 3 15 18 13 6 22 11 17 2 
-1
-1

result:

ok Accepted.

Test #44:

score: 12
Accepted
time: 11ms
memory: 54816kb

input:

5
1 0 1
1 0 1
1 0 2
1 0 1
1 0 2

output:

1
1
1
1
1

result:

ok Accepted.

Test #45:

score: 6
Acceptable Answer
time: 4ms
memory: 103340kb

input:

5
27 172 1
17 8
8 13
13 7
7 22
22 3
3 18
15 20
2 25
27 9
9 10
14 6
21 4
4 26
26 10
10 25
25 12
16 19
24 19
12 19
19 1
11 23
23 20
20 6
6 1
5 18
18 1
29 209 1
9 7
7 16
16 12
12 4
4 24
19 25
28 17
17 6
6 1
1 11
11 13
29 15
15 21
5 22
22 27
14 13
13 20
8 24
24 21
21 2
2 25
25 27
27 26
26 23
23 20
20 3
...

output:

-1
-1
-1
23 26 13 5 11 4 21 16 14 24 15 1 8 20 25 2 3 9 7 6 19 17 12 27 22 18 10 
-1

result:

points 0.50 Partially Correct | type = 2

Test #46:

score: 6
Acceptable Answer
time: 8ms
memory: 103140kb

input:

5
27 136 1
1 11
11 10
10 8
2 26
24 20
25 27
27 22
22 15
16 9
18 21
21 7
7 5
5 14
14 3
3 9
9 8
8 6
17 26
26 6
13 15
15 23
23 6
6 20
20 12
12 19
4 19
27 196 2
1 12
12 4
4 27
27 14
19 15
15 8
18 7
7 10
10 16
9 2
23 13
26 17
5 25
22 2
6 16
16 25
25 8
8 14
14 21
21 17
17 13
13 24
24 11
11 3
3 2
2 20
28 1...

output:

-1
14 20 6 22 18 9 7 2 10 3 16 24 11 5 23 1 13 25 12 26 19 4 17 15 27 21 8 
-1
17 25 27 20 21 12 22 26 15 7 19 16 8 3 28 5 10 11 2 9 23 18 6 24 14 13 1 4 
-1

result:

points 0.50 Partially Correct | type = 2

Test #47:

score: 6
Acceptable Answer
time: 7ms
memory: 102812kb

input:

5
30 66 1
20 19
19 8
8 18
18 24
28 17
3 15
23 16
12 29
29 1
1 11
11 25
25 21
21 2
4 5
5 9
9 14
7 10
10 2
2 13
6 15
15 17
17 13
13 27
22 27
26 27
27 14
30 24
24 16
16 14
29 172 2
20 7
7 27
27 11
26 14
14 17
22 8
29 1
1 21
5 9
24 16
12 18
4 19
19 3
3 25
25 21
23 28
2 8
28 8
8 15
10 18
18 21
21 16
6 9
...

output:

-1
9 13 23 10 28 12 2 18 22 19 4 8 3 15 25 26 29 14 1 20 17 21 7 24 27 16 11 6 5 
-1
-1
-1

result:

points 0.50 Partially Correct | type = 2

Test #48:

score: 6
Acceptable Answer
time: 4ms
memory: 103772kb

input:

5
28 164 1
24 18
18 25
25 7
23 11
11 3
10 16
16 2
2 27
27 21
22 9
9 6
1 28
28 19
19 17
17 7
7 12
20 21
21 3
3 6
6 13
8 4
4 12
15 12
12 13
14 13
13 5
26 5
28 153 1
18 4
13 2
25 24
24 7
27 12
10 19
19 9
9 8
15 11
11 6
6 16
16 20
20 1
1 23
23 2
5 8
8 4
4 17
28 21
26 21
21 14
14 3
3 12
12 7
7 2
2 17
17 ...

output:

-1
-1
-1
-1
12 18 23 11 14 25 22 19 29 27 15 1 20 28 24 9 10 3 16 21 7 26 6 8 17 2 13 5 4 

result:

points 0.50 Partially Correct | type = 2

Test #49:

score: 6
Acceptable Answer
time: 8ms
memory: 100360kb

input:

5
28 90 2
28 3
8 6
26 11
11 15
15 16
5 12
1 27
27 13
21 9
9 22
14 20
4 2
10 18
18 19
19 16
23 6
6 13
13 12
17 16
25 20
20 12
12 3
3 2
2 24
24 22
22 16
16 7
28 92 1
1 11
11 24
14 3
4 10
10 23
23 2
2 26
22 5
15 17
17 18
18 20
20 19
19 28
28 16
12 3
3 9
25 5
6 21
21 16
16 7
9 24
24 13
7 26
26 8
13 27
2...

output:

2 20 14 25 17 7 13 27 1 6 8 23 16 15 11 26 19 18 10 5 21 12 9 28 24 22 4 3 
-1
6 19 10 21 4 5 8 15 9 7 24 22 23 16 26 17 18 25 14 1 2 11 13 3 27 20 12 
22 2 25 26 19 9 28 13 14 15 5 21 27 8 16 4 23 20 6 10 18 11 3 17 29 24 12 7 1 
-1

result:

points 0.50 Partially Correct | type = 2

Test #50:

score: 6
Acceptable Answer
time: 10ms
memory: 104188kb

input:

5
27 256 2
1 14
14 12
12 24
24 17
17 21
21 22
22 4
19 10
10 15
25 9
2 11
5 20
20 7
18 15
15 27
27 23
8 4
6 4
4 13
13 9
9 11
11 16
16 26
26 3
3 7
7 23
27 174 2
18 23
23 14
27 4
4 3
9 8
8 16
16 15
22 24
24 11
11 17
25 1
1 2
2 6
6 10
12 19
19 13
13 15
15 5
21 5
26 3
3 14
14 20
20 17
17 7
7 5
5 10
27 17...

output:

11 18 6 19 8 10 1 15 14 27 12 23 24 5 17 20 21 7 22 3 13 4 26 25 16 9 2 
5 27 26 12 4 19 3 13 18 25 23 9 14 1 20 8 22 2 24 16 11 6 17 21 15 10 7 
13 6 26 2 4 16 21 10 7 18 11 22 14 27 9 25 12 1 20 8 23 15 3 5 24 19 17 
-1
-1

result:

points 0.50 Partially Correct | type = 2

Test #51:

score: 6
Acceptable Answer
time: 4ms
memory: 100472kb

input:

5
27 75 1
19 4
22 14
15 23
23 1
1 26
26 9
9 13
6 18
18 7
7 16
20 27
25 10
10 21
17 27
12 13
3 11
11 5
8 14
24 4
4 16
16 5
5 14
14 13
13 27
27 21
21 2
29 156 2
12 21
21 29
29 7
7 22
22 27
20 10
10 1
1 24
24 25
25 26
26 23
5 6
6 14
9 17
19 4
11 4
3 14
16 8
28 15
15 8
8 17
17 14
14 23
23 4
18 27
13 27
...

output:

-1
23 2 28 13 15 18 16 29 21 12 20 8 7 10 9 22 1 17 27 24 3 11 25 5 19 26 14 6 4 
-1
29 20 4 16 6 26 23 3 17 18 8 12 25 24 13 11 22 5 1 28 9 19 2 27 7 15 21 14 10 
9 30 22 21 11 25 8 27 20 3 16 14 23 24 4 19 28 2 10 15 29 13 12 1 6 7 26 18 17 5 

result:

points 0.50 Partially Correct | type = 2

Test #52:

score: 6
Acceptable Answer
time: 4ms
memory: 103696kb

input:

5
27 151 1
27 26
26 17
4 8
10 16
22 12
12 9
3 23
23 15
15 11
11 20
20 24
19 25
14 21
21 17
17 1
1 24
13 2
7 16
6 16
16 5
5 25
25 9
9 24
24 8
8 2
2 18
30 212 2
16 30
30 22
22 28
28 14
14 2
2 15
19 4
4 29
17 9
9 5
7 12
11 1
13 25
18 26
26 27
24 5
5 21
8 20
20 25
25 29
29 23
10 12
6 15
15 23
23 12
12 2...

output:

-1
23 24 6 17 8 9 16 5 20 21 30 11 13 1 22 3 25 18 28 26 19 14 27 4 2 10 29 15 12 7 
5 9 18 30 21 13 22 7 14 26 24 17 16 12 4 1 25 15 27 28 2 6 8 29 23 3 11 20 19 10 
-1
-1

result:

points 0.50 Partially Correct | type = 2

Subtask #7:

score: 9
Acceptable Answer

Dependency #4:

50%
Acceptable Answer

Dependency #6:

50%
Acceptable Answer

Test #53:

score: 18
Accepted
time: 7ms
memory: 54144kb

input:

2000
1 0 2
1 0 1
1 0 2
1 0 2
1 0 1
1 0 1
1 0 2
1 0 2
1 0 1
1 0 2
1 0 2
1 0 2
1 0 1
1 0 2
1 0 2
1 0 2
1 0 1
1 0 2
1 0 2
1 0 2
1 0 2
1 0 1
1 0 2
1 0 1
1 0 1
1 0 1
1 0 2
1 0 2
1 0 2
1 0 2
1 0 2
1 0 2
1 0 2
1 0 1
1 0 1
1 0 2
1 0 1
1 0 2
1 0 1
1 0 2
1 0 1
1 0 2
1 0 1
1 0 1
1 0 1
1 0 1
1 0 1
1 0 2
1 0 1
1...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok Accepted.

Test #54:

score: 9
Acceptable Answer
time: 8ms
memory: 103428kb

input:

5
369 9452 2
107 345
345 96
96 194
194 277
277 313
313 126
126 116
338 97
97 40
40 253
199 341
341 140
140 155
92 37
37 307
307 32
32 145
161 275
64 133
18 43
113 73
73 322
322 85
85 328
328 159
159 1
364 299
299 235
235 2
2 274
347 335
335 367
104 108
108 153
76 174
246 154
154 203
203 93
93 284
28...

output:

24 168 80 316 349 329 59 38 319 300 136 263 200 293 321 57 369 46 177 213 28 127 97 338 195 152 22 227 40 286 253 18 208 43 164 99 354 249 325 366 137 284 93 203 154 246 101 183 236 92 53 37 289 307 310 32 207 145 229 55 36 191 258 333 60 327 131 82 95 180 113 304 73 334 322 10 85 4 328 238 159 54 1...

result:

points 0.50 Partially Correct | type = 2

Test #55:

score: 9
Acceptable Answer
time: 15ms
memory: 55012kb

input:

1
1981 59778 1
581 1357
1357 1114
1319 822
822 1185
1143 365
619 708
708 1424
1424 1489
1489 1936
1936 1740
1789 1497
1497 387
387 1272
1272 485
1448 418
418 893
1011 1305
1305 176
1593 915
915 1594
1594 1432
1432 1794
1794 837
17 704
704 1542
1270 802
802 1879
1427 608
608 1723
1723 1288
1288 779
7...

output:

-1

result:

points 0.50 Partially Correct | type = 2

Test #56:

score: 9
Acceptable Answer
time: 7ms
memory: 54500kb

input:

1
1998 29319 1
93 1888
1888 701
701 643
643 1166
294 975
975 574
574 19
19 1224
1435 1480
72 1942
1707 613
613 1451
1272 769
1683 1050
1372 1242
1242 901
191 230
1702 562
562 883
1086 1964
1964 1852
1852 1955
1955 310
1165 1905
54 557
557 1182
1182 973
973 878
878 1950
1950 551
551 1473
1473 1921
11...

output:

-1

result:

points 0.50 Partially Correct | type = 2

Test #57:

score: 18
Accepted
time: 3ms
memory: 97232kb

input:

1
1916 61288 2
395 1027
1610 1787
1787 357
189 139
139 675
675 1158
1158 1868
1868 1196
719 1579
1131 810
810 227
227 475
475 1060
1092 1602
1298 760
1390 211
211 1839
1839 99
99 618
618 1754
1754 1682
1682 529
529 1460
1555 1589
1589 152
152 1665
1665 1781
1649 1487
1487 870
870 144
144 934
750 162...

output:

179 1300 1246 636 1889 1143 1508 536 453 263 501 1440 1136 205 417 903 907 240 1871 1315 549 765 265 1201 796 834 29 1616 1396 1472 478 46 610 883 474 1049 1610 1196 1868 1158 675 139 189 1352 808 655 519 1787 195 357 1808 1176 781 881 282 1824 1732 825 6 1577 366 1809 639 708 1224 871 1323 3 551 38...

result:

ok Accepted.

Test #58:

score: 9
Acceptable Answer
time: 7ms
memory: 53744kb

input:

1
1835 91921 1
792 896
527 544
544 1461
1461 1426
1426 399
1350 1246
1246 496
496 227
227 799
799 546
945 779
779 418
1712 108
944 949
949 279
552 73
1311 1756
749 815
815 838
838 802
802 242
242 149
1482 1459
568 180
180 506
506 1270
758 1417
1417 203
898 178
178 386
386 920
920 467
715 76
76 1111
...

output:

-1

result:

points 0.50 Partially Correct | type = 2

Test #59:

score: 9
Acceptable Answer
time: 8ms
memory: 103248kb

input:

50
39 327 2
11 9
9 24
32 3
3 23
23 20
20 18
18 31
37 6
39 25
4 14
14 29
29 19
19 35
38 17
17 33
10 15
16 30
30 21
21 12
12 8
8 1
1 26
28 22
34 31
22 15
15 13
13 24
5 25
25 27
36 35
35 24
24 7
7 26
26 33
33 6
6 2
2 31
31 27
39 501 2
5 15
15 8
6 23
23 4
17 32
32 34
11 9
9 35
35 14
13 2
18 25
25 24
24 ...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
36 25 5 37 15 3 24 4 20 22 34 8 23 27 33 19 18 10 35 13 21 31 32 26 29 30 1 7 28 6 14 38 2 9 17 11 16 12 
-1
-1
15 28 13 25 4 33 7 1 36 11 8 24 22 5 27 23 19 26 20 31 10 29 18 30 21 35 12 2 14 3 16 6 34 9 17 32 
-1
-1
-1
-1
-1
-1
-1
-1
-1
-...

result:

points 0.50 Partially Correct | type = 2

Test #60:

score: 9
Acceptable Answer
time: 4ms
memory: 102056kb

input:

330
6 14 2
4 3
3 1
1 5
5 2
2 6
6 8 1
1 3
3 6
6 5
2 5
5 4
6 12 1
1 4
4 5
2 3
3 5
5 6
6 14 2
1 6
3 2
2 5
5 6
6 4
6 6 1
2 1
1 5
5 6
6 3
3 4
6 14 2
1 5
5 2
2 6
4 6
6 3
6 10 2
6 2
2 1
3 4
4 1
1 5
6 9 1
2 1
1 5
5 4
4 3
3 6
6 12 2
6 2
2 3
3 4
4 1
1 5
6 10 2
3 2
2 5
5 4
4 1
1 6
6 14 2
5 2
2 3
3 1
1 4
6 4
6 ...

output:

5 6 3 4 2 1 
-1
-1
5 4 3 6 1 2 
-1
6 1 4 3 2 5 
1 5 4 3 2 6 
-1
3 6 4 1 5 2 
5 4 1 6 2 3 
3 5 4 6 2 1 
-1
3 6 5 4 1 2 
-1
-1
1 5 6 3 4 2 
-1
2 3 4 6 5 1 
4 5 6 3 2 1 
-1
2 1 4 5 6 3 
-1
3 6 2 5 4 1 
3 2 5 6 4 1 
-1
3 6 4 1 2 5 
-1
6 3 2 4 5 1 
2 1 4 6 3 5 
5 6 1 4 3 2 
3 4 2 1 6 5 
-1
-1
4 5 6 2 1 3...

result:

points 0.50 Partially Correct | type = 2

Test #61:

score: 9
Acceptable Answer
time: 10ms
memory: 103172kb

input:

100
19 44 1
13 18
18 10
10 5
9 7
16 6
6 8
8 3
2 17
17 1
11 19
15 19
4 14
14 5
5 1
1 7
7 19
19 3
3 12
20 96 1
14 2
2 9
7 16
16 10
8 20
20 5
19 11
11 1
15 4
4 3
3 10
10 5
5 9
9 12
12 13
18 1
1 17
6 13
13 17
19 106 2
4 12
12 16
16 19
19 6
6 15
9 5
5 8
7 14
11 18
18 3
3 8
8 17
17 2
10 2
2 15
1 14
14 15
...

output:

-1
-1
15 10 4 11 12 18 1 3 16 9 7 5 19 8 14 17 13 6 2 
5 2 4 10 16 1 3 6 15 20 18 13 14 9 19 7 12 11 8 17 
-1
1 13 8 16 6 9 11 17 19 10 14 12 15 7 2 3 18 5 4 
-1
2 13 10 9 6 5 3 7 15 16 14 12 17 18 8 19 11 4 1 
-1
6 7 10 5 1 3 15 9 2 14 16 17 12 13 11 4 18 8 
7 19 4 6 16 20 1 14 15 13 12 2 17 11 10 ...

result:

points 0.50 Partially Correct | type = 2

Test #62:

score: 9
Acceptable Answer
time: 7ms
memory: 103412kb

input:

100
19 59 1
7 2
8 16
16 11
11 3
3 5
5 4
15 1
19 6
9 12
14 1
18 2
2 4
4 6
6 13
13 1
1 17
17 12
12 10
18 104 2
3 17
1 14
14 11
18 2
5 6
6 4
4 15
15 10
10 7
7 8
8 17
17 16
16 11
11 13
13 9
9 2
2 12
19 53 1
12 9
8 11
3 5
5 13
13 7
7 2
2 16
19 1
17 14
14 16
15 6
6 9
9 1
4 1
1 16
16 11
11 10
10 18
18 29 1...

output:

-1
17 5 2 18 12 6 9 4 13 15 1 10 14 7 16 11 8 3 
-1
-1
20 4 1 14 19 6 7 11 17 12 10 2 16 15 9 18 5 13 8 3 
12 14 16 4 5 6 3 13 19 2 8 11 7 1 9 18 17 15 10 
8 7 14 1 13 12 16 9 11 2 18 6 19 15 17 5 3 4 20 10 
16 7 14 11 3 12 9 13 15 6 19 2 8 17 18 10 1 5 4 
6 18 3 7 10 16 2 17 12 11 9 8 4 14 1 19 20 ...

result:

points 0.50 Partially Correct | type = 2

Test #63:

score: 9
Acceptable Answer
time: 7ms
memory: 103984kb

input:

20
99 794 1
32 56
34 98
98 86
2 37
37 13
13 22
22 47
82 95
49 39
5 91
28 80
50 15
92 26
26 93
93 59
88 9
46 79
79 14
14 38
38 97
97 83
83 75
75 20
20 76
76 33
54 25
25 72
72 18
89 58
58 66
24 27
27 87
36 10
10 3
3 30
30 85
85 45
45 55
73 71
81 35
35 17
67 69
74 40
40 63
51 16
7 42
42 11
11 29
77 64
...

output:

-1
12 83 86 60 89 80 19 16 98 71 63 52 68 76 72 37 62 61 92 35 14 99 58 85 59 100 75 93 82 9 49 44 25 34 11 38 33 2 24 42 17 15 54 50 5 69 66 22 30 39 81 28 4 21 65 6 90 56 18 73 23 53 64 1 13 47 77 10 55 78 97 32 43 41 84 96 70 57 95 26 87 74 51 48 3 36 88 20 29 8 7 67 40 91 46 27 94 79 45 31 
-1
-...

result:

points 0.50 Partially Correct | type = 2

Test #64:

score: 9
Acceptable Answer
time: 7ms
memory: 103608kb

input:

20
90 624 1
35 32
81 1
1 51
46 27
27 13
84 58
77 48
48 61
64 42
42 29
29 31
31 25
25 67
38 10
10 2
2 57
12 3
50 66
66 5
5 80
80 60
60 15
15 70
70 9
9 22
72 68
68 76
79 20
20 73
73 54
54 59
59 21
21 45
45 52
52 82
63 55
55 37
37 74
28 90
14 19
19 43
43 41
41 62
62 26
4 71
7 82
23 89
56 11
30 36
78 39...

output:

-1
-1
-1
80 28 29 32 6 98 35 53 15 16 30 10 79 34 50 36 95 66 94 13 75 27 47 70 77 39 90 96 89 61 54 64 21 1 78 67 8 14 3 86 68 74 51 63 56 85 12 62 44 71 49 20 17 33 7 31 11 25 5 41 65 82 57 83 46 9 4 97 76 22 18 24 59 88 45 72 2 58 81 93 73 23 48 42 52 84 37 69 99 55 40 38 19 91 26 92 87 60 43 
-1...

result:

points 0.50 Partially Correct | type = 2

Test #65:

score: 9
Acceptable Answer
time: 12ms
memory: 103416kb

input:

20
98 788 2
78 38
38 90
8 69
69 47
47 62
62 6
35 92
92 57
20 70
11 17
17 89
28 5
5 68
68 73
73 64
26 42
31 46
46 86
56 21
30 95
60 33
33 13
13 22
40 65
65 4
4 15
15 58
71 80
80 48
52 49
49 27
27 98
98 36
94 82
79 63
63 93
93 85
85 67
67 91
84 9
9 75
24 29
51 96
96 1
23 87
87 43
43 59
59 54
54 76
76 ...

output:

58 81 1 96 51 44 22 13 33 60 72 25 16 12 3 88 7 83 59 43 87 23 74 71 54 77 80 76 26 48 49 52 42 50 98 27 32 28 36 97 5 69 8 61 68 47 55 73 62 18 64 6 95 30 45 37 39 53 34 79 19 84 63 24 9 93 29 75 85 66 31 67 35 46 91 92 86 56 57 11 21 2 17 40 78 14 89 65 38 94 20 4 90 82 70 41 15 10 
-1
32 72 34 85...

result:

points 0.50 Partially Correct | type = 2

Test #66:

score: 9
Acceptable Answer
time: 8ms
memory: 103428kb

input:

5
381 3720 1
140 69
69 271
192 329
18 358
358 164
164 336
336 75
75 282
282 222
14 12
12 321
321 236
236 272
272 311
150 121
121 372
186 257
257 370
370 91
201 92
92 356
356 60
60 202
273 317
129 279
279 110
251 253
77 11
11 22
22 175
175 40
40 157
161 287
287 242
345 235
228 364
364 226
103 246
246...

output:

-1
74 143 318 229 184 99 285 70 190 48 106 340 102 315 10 259 173 268 78 223 37 316 162 155 357 256 329 195 142 21 178 97 207 213 321 274 81 88 9 153 323 324 32 35 124 288 11 276 246 253 13 71 43 31 120 279 6 168 45 36 127 119 83 166 107 185 335 126 291 112 353 193 343 306 20 308 378 331 139 147 192...

result:

points 0.50 Partially Correct | type = 2

Test #67:

score: 9
Acceptable Answer
time: 4ms
memory: 104008kb

input:

5
376 5912 1
256 172
156 371
371 300
133 115
115 138
176 1
1 342
342 27
27 370
370 243
243 260
178 337
337 233
233 116
116 372
108 294
53 331
331 134
134 202
202 247
247 259
259 208
350 3
3 15
15 119
119 89
89 31
31 5
237 104
104 278
278 9
9 324
324 231
151 106
106 314
314 363
111 367
126 46
46 43
1...

output:

-1
-1
-1
-1
269 97 299 35 301 245 342 308 55 352 182 23 322 139 256 290 155 126 36 137 32 13 354 267 235 304 229 135 362 132 328 234 265 85 68 260 11 91 282 306 51 161 183 239 162 363 67 218 127 167 361 307 377 129 178 297 225 367 136 224 343 10 340 188 294 124 70 9 208 60 177 276 277 338 259 244 18...

result:

points 0.50 Partially Correct | type = 2

Subtask #8:

score: 5
Acceptable Answer

Dependency #7:

50%
Acceptable Answer

Test #68:

score: 10
Accepted
time: 8ms
memory: 54360kb

input:

100000
1 0 1
1 0 1
1 0 2
1 0 1
1 0 2
1 0 2
1 0 1
1 0 2
1 0 2
1 0 1
1 0 1
1 0 2
1 0 1
1 0 1
1 0 1
1 0 2
1 0 1
1 0 2
1 0 2
1 0 1
1 0 2
1 0 1
1 0 1
1 0 2
1 0 2
1 0 2
1 0 2
1 0 1
1 0 2
1 0 1
1 0 1
1 0 2
1 0 2
1 0 2
1 0 1
1 0 1
1 0 2
1 0 1
1 0 2
1 0 1
1 0 2
1 0 2
1 0 2
1 0 2
1 0 1
1 0 1
1 0 1
1 0 1
1 0 1...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok Accepted.

Test #69:

score: 5
Acceptable Answer
time: 19ms
memory: 98680kb

input:

20
4739 5853376 2
241 1557
2727 144
828 4540
4356 4276
2664 1248
3140 3044
2673 2465
4472 4588
4088 1582
1402 837
249 2576
4222 2011
4326 3478
618 1837
2221 2758
4294 4571
4420 99
783 4166
2904 2230
2043 3395
4697 394
1658 1677
2315 931
4132 173
2863 4183
1156 2961
3832 4207
4175 2577
3526 2571
3844...

output:

4176 1571 447 183 335 3189 976 4065 1197 4458 2753 645 2790 1512 4732 2722 1803 4079 2994 1875 3801 2937 4398 434 722 265 997 378 3256 316 2219 763 4262 3648 1415 586 1037 3529 4261 2731 4348 1681 1994 2190 4399 3515 1403 4149 2840 4674 3751 3899 1194 2399 3096 2615 4231 2269 2286 3686 4029 3336 273...

result:

points 0.50 Partially Correct | type = 2

Test #70:

score: 5
Acceptable Answer
time: 16ms
memory: 107272kb

input:

10
9775 28387496 2
4111 1845
5328 8463
5658 5847
3140 4296
2304 2863
3059 9597
3416 4942
4155 8323
5427 420
4277 6009
6681 2156
2015 6300
3901 7434
3626 7491
34 8881
2933 1589
2493 3247
3049 2124
7966 8151
7298 5798
4005 1543
6558 7955
7205 7231
6962 8747
9115 2347
6678 2313
6313 5913
5718 2087
4601...

output:

6531 9282 4177 378 6342 453 6539 8257 8520 8411 5682 1691 4542 6850 9068 6212 7779 5009 2994 1352 2931 4909 1138 309 9307 2032 7037 2371 5215 6989 9043 9154 4047 5308 4848 3625 1771 1315 6526 4062 865 5077 6239 2375 7118 4777 5388 5944 2984 2260 1409 2944 30 6381 92 157 6912 1935 9674 5532 1539 4297...

result:

points 0.50 Partially Correct | type = 2

Test #71:

score: 5
Acceptable Answer
time: 18ms
memory: 107612kb

input:

5
18424 102019945 1
6009 5000
688 5707
7377 2483
17135 11887
11730 10212
8202 2298
10379 4241
11435 9713
12686 1606
7194 701
4130 17140
12866 7314
5553 17608
17154 14894
476 15049
8664 31
16244 10749
7130 14423
15077 15440
3494 14841
14846 5537
15852 16565
9158 1139
9750 14771
16068 5101
5313 2422
9...

output:

-1
16355 16638 18652 13194 4156 7516 10700 17653 8487 2138 3768 12916 10509 2475 13824 2833 9893 9770 1700 2930 14785 6770 12222 9384 17117 3961 2666 7900 3793 681 11187 14897 14953 9433 14516 10346 17758 5285 8239 12703 6344 8234 15161 1807 10065 9286 14007 13650 4914 583 17557 6270 12008 3107 1976...

result:

points 0.50 Partially Correct | type = 2

Test #72:

score: 10
Accepted
time: 36ms
memory: 111108kb

input:

3
31442 1897522 2
227 18045
19811 21817
17841 21143
23712 9546
31355 10107
2019 12690
10655 15526
21289 27919
21190 18604
762 28189
31092 22046
941 7045
25679 6271
341 5776
16779 28120
396 3989
18232 11559
24181 31300
6960 8713
12363 9404
18439 27196
16813 9762
10651 332
3494 20107
13995 26937
2428 ...

output:

23689 25045 5963 4505 18150 13928 16431 19772 22080 15223 16875 8078 3038 7967 11490 10485 29457 27644 7679 27188 9142 15119 4225 22786 28277 23125 11575 7957 3206 11674 5183 15781 1502 2611 11033 15361 3208 15449 11962 29829 28786 17085 28490 9793 23120 21300 3545 2517 27328 27254 1613 17183 21477 ...

result:

ok Accepted.

Test #73:

score: 5
Acceptable Answer
time: 7ms
memory: 54520kb

input:

3
32308 277196163 1
28236 28059
13478 9068
28454 28849
16817 246
11618 9818
28123 4662
20902 9080
13907 9158
5441 10539
27228 25652
13268 4496
13075 15781
9747 15408
24294 13278
29091 28311
3433 30055
20111 22336
24462 24005
16412 2106
17953 18082
11530 16617
17947 4128
2459 26569
9247 18592
19713 1...

output:

-1
-1
-1

result:

points 0.50 Partially Correct | type = 2

Test #74:

score: 5
Acceptable Answer
time: 12ms
memory: 100936kb

input:

233
427 58203 1
279 292
169 156
224 109
215 332
268 84
335 383
381 6
166 228
261 252
47 241
118 197
136 140
31 80
329 149
241 351
387 61
400 208
60 219
187 199
116 365
420 186
288 98
427 55
391 305
192 40
88 339
278 308
87 322
221 185
415 360
285 295
422 140
10 218
359 92
15 286
286 33
102 396
246 1...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
103 286 330 229 115 177 338 35 133 269 312 17 104 404 80 7 73 318 107 361 257 327 249 226 170 156 108 344 182 313 352 165 358 302 49 164 9 345 95 192 260 356 59 240 151 213 1...

result:

points 0.50 Partially Correct | type = 2

Test #75:

score: 5
Acceptable Answer
time: 11ms
memory: 103588kb

input:

10000
9 16 2
4 8
1 3
3 5
5 8
8 6
6 9
9 2
2 7
10 29 1
5 7
8 2
3 10
10 1
1 6
6 4
4 9
9 2
2 7
10 38 1
10 1
8 9
2 1
1 3
3 5
5 9
9 7
7 4
4 6
10 22 1
5 6
2 6
7 1
1 3
3 6
6 4
4 8
8 10
10 9
9 27 1
8 3
9 6
6 3
3 1
1 4
4 2
2 7
7 5
9 20 2
8 6
6 3
4 5
5 3
3 9
9 2
2 1
1 7
10 13 1
3 10
10 5
5 1
1 4
4 6
6 9
9 2
2 ...

output:

8 6 9 2 7 5 3 1 4 
-1
-1
-1
-1
3 8 4 9 2 1 7 6 5 
-1
-1
3 9 2 6 8 7 5 4 1 
-1
4 7 3 5 9 8 6 2 1 
3 1 9 5 4 6 7 8 2 10 
-1
8 4 2 6 5 10 1 7 9 3 
10 1 2 4 9 8 3 7 6 5 
-1
-1
-1
-1
1 8 7 2 5 9 3 6 4 
7 6 1 4 2 8 10 9 5 3 
-1
5 10 4 2 6 7 3 8 9 1 
5 4 8 9 7 6 2 3 1 
-1
-1
9 6 1 10 4 8 5 7 3 2 
4 9 7 5 8...

result:

points 0.50 Partially Correct | type = 2

Test #76:

score: 5
Acceptable Answer
time: 3ms
memory: 103620kb

input:

5000
20 66 2
19 1
1 15
4 8
3 16
12 17
17 8
13 8
8 20
20 6
6 2
2 5
5 9
9 14
14 11
11 7
7 15
15 16
16 18
18 10
19 37 1
4 10
6 16
10 1
11 3
3 13
13 15
12 17
17 8
8 2
2 18
18 7
7 16
16 1
1 19
19 9
9 14
14 15
15 5
18 99 1
8 18
16 14
12 2
17 11
10 3
11 4
2 7
7 9
9 4
4 1
1 14
14 18
18 6
6 3
3 13
13 5
5 15
...

output:

9 15 1 19 16 3 18 10 8 4 17 12 13 7 20 11 2 6 14 5 
-1
-1
4 1 7 15 13 2 3 9 11 18 16 20 19 12 14 5 17 10 8 6 
-1
3 14 7 18 4 5 12 16 9 17 15 2 11 13 8 10 6 1 
-1
19 4 2 5 12 3 15 8 10 1 9 13 17 6 14 18 7 16 11 
-1
-1
4 1 7 3 5 6 18 8 12 2 13 9 19 17 14 16 15 11 10 
-1
14 10 6 12 2 5 8 1 11 3 9 17 18...

result:

points 0.50 Partially Correct | type = 2

Test #77:

score: 5
Acceptable Answer
time: 19ms
memory: 103664kb

input:

2000
47 252 2
41 8
34 25
5 38
45 18
46 12
44 12
40 21
11 10
14 47
19 7
42 35
35 2
13 39
3 23
10 31
31 16
16 15
15 30
30 7
7 26
26 2
2 27
27 25
25 39
39 38
38 4
4 20
20 24
24 23
23 21
21 32
32 6
6 17
17 33
33 8
8 29
29 1
1 28
28 37
37 22
22 47
47 12
12 18
18 9
9 43
43 36
46 682 2
42 4
6 46
25 16
5 43...

output:

23 28 37 22 47 14 12 46 44 18 45 9 43 36 2 35 42 26 7 19 30 15 16 31 10 11 1 34 27 29 25 41 13 8 39 33 5 17 38 6 4 32 20 40 24 21 3 
10 15 23 45 40 21 35 11 17 31 38 28 39 37 36 7 33 44 24 32 27 25 34 16 26 20 3 41 8 19 22 29 2 18 5 13 12 43 9 6 42 46 4 30 14 1 
9 36 30 31 10 8 45 21 44 11 43 32 15 ...

result:

points 0.50 Partially Correct | type = 2

Test #78:

score: 5
Acceptable Answer
time: 3ms
memory: 100952kb

input:

1000
100 2700 2
30 1
80 16
38 94
10 15
32 2
83 88
58 8
12 78
95 35
14 18
63 5
39 70
78 72
3 16
67 4
89 84
52 66
44 43
64 11
61 96
22 48
48 35
92 1
90 75
40 46
74 79
27 28
43 96
57 34
34 73
51 81
81 56
73 99
99 9
97 8
24 77
91 26
42 85
13 77
77 49
49 17
17 28
28 8
8 98
98 69
69 86
86 1
1 85
85 84
84 ...

output:

2 5 63 62 17 49 77 24 13 18 14 28 27 48 22 97 95 58 35 8 76 98 34 57 69 73 86 99 92 9 30 36 1 52 42 66 85 93 89 53 84 29 7 21 67 39 4 70 20 25 40 33 46 51 45 81 60 56 6 3 82 80 31 16 38 87 94 50 10 100 15 55 90 71 75 68 47 59 12 23 78 44 72 43 74 61 79 96 41 19 64 83 11 88 54 37 91 65 32 26 
4 66 35...

result:

points 0.50 Partially Correct | type = 2

Test #79:

score: 5
Acceptable Answer
time: 16ms
memory: 104260kb

input:

500
181 10132 2
63 62
111 83
175 78
89 149
163 95
54 2
165 55
55 119
162 58
131 86
4 8
41 71
15 47
130 20
10 42
35 141
146 166
14 135
181 176
42 7
68 128
51 116
16 64
160 171
38 21
90 25
168 20
100 50
177 132
65 138
43 147
25 164
115 127
27 22
58 21
7 150
44 144
12 141
124 173
102 109
29 153
32 112
...

output:

140 180 51 84 116 68 45 128 108 60 178 157 9 26 88 39 151 48 59 93 162 70 58 134 38 53 21 27 36 22 73 77 54 125 2 13 181 179 176 120 79 57 87 133 81 19 40 75 91 170 118 31 24 145 23 17 175 167 78 72 168 101 130 155 20 96 67 172 46 115 161 127 104 29 80 153 159 160 66 171 124 65 173 138 92 143 100 10...

result:

points 0.50 Partially Correct | type = 2

Test #80:

score: 5
Acceptable Answer
time: 12ms
memory: 104492kb

input:

200
471 12114 2
415 145
297 397
304 440
14 104
181 443
273 49
105 78
84 2
212 53
432 390
394 451
468 286
127 263
113 238
171 196
59 117
392 349
215 94
356 442
344 338
192 86
66 257
241 450
306 26
272 142
161 384
58 196
218 463
93 23
312 372
54 308
308 68
452 345
51 247
418 76
122 8
198 139
424 108
5...

output:

382 315 124 73 242 281 148 48 371 245 360 367 144 10 336 421 374 274 178 65 219 15 155 268 372 312 138 381 291 22 201 75 266 43 270 97 454 391 21 275 120 81 257 66 112 125 96 118 362 289 136 283 373 448 130 334 400 209 346 449 258 303 157 246 388 433 110 335 210 111 23 93 278 146 175 461 214 378 128...

result:

points 0.50 Partially Correct | type = 2

Test #81:

score: 5
Acceptable Answer
time: 11ms
memory: 104660kb

input:

100
975 217172 2
649 311
744 359
221 637
308 496
259 838
859 382
738 637
17 87
454 452
546 664
703 942
867 284
754 964
12 467
114 932
36 393
390 469
42 328
115 480
462 329
39 8
233 588
86 130
325 316
872 258
341 967
967 162
941 288
687 871
258 356
321 468
581 476
31 813
133 538
635 824
331 377
71 50...

output:

878 540 57 369 899 415 243 389 440 591 438 263 969 934 343 291 804 333 617 965 67 854 923 741 388 150 782 658 714 763 443 195 246 538 133 898 870 184 301 536 829 545 77 320 103 560 926 675 789 339 642 568 876 47 800 779 733 772 493 375 373 278 72 713 441 908 316 325 716 155 597 548 11 565 698 280 88...

result:

points 0.50 Partially Correct | type = 2

Test #82:

score: 5
Acceptable Answer
time: 23ms
memory: 104544kb

input:

50
1867 423383 1
1402 1596
1768 1660
84 1611
368 1781
53 1341
996 1046
806 1866
1460 742
1359 1004
1863 605
489 250
388 1318
135 845
392 346
1257 855
654 77
490 640
1808 1148
384 614
1495 275
1196 1236
827 75
75 1712
254 726
1436 1432
1344 1476
728 739
1016 523
523 1837
381 1623
1703 1397
59 1827
52...

output:

-1
178 277 721 1800 1256 1303 1751 357 711 610 566 836 1344 744 442 568 1335 1721 873 24 1834 1030 1317 152 734 1369 899 997 1392 1361 256 1608 1719 896 1728 1749 1442 1686 273 825 1009 214 1188 750 655 1202 1671 142 205 1496 785 545 957 190 83 592 482 1065 393 1044 4 973 1137 917 1622 1116 150 859 ...

result:

points 0.50 Partially Correct | type = 2

Subtask #9:

score: 11
Acceptable Answer

Dependency #1:

100%
Accepted

Dependency #2:

50%
Acceptable Answer

Dependency #3:

50%
Acceptable Answer

Dependency #4:

50%
Acceptable Answer

Dependency #5:

50%
Acceptable Answer

Dependency #6:

50%
Acceptable Answer

Dependency #7:

50%
Acceptable Answer

Dependency #8:

50%
Acceptable Answer

Test #83:

score: 22
Accepted
time: 15ms
memory: 55040kb

input:

500000
1 0 2
1 0 2
1 0 1
1 0 1
1 0 2
1 0 2
1 0 2
1 0 1
1 0 2
1 0 2
1 0 2
1 0 2
1 0 2
1 0 2
1 0 2
1 0 2
1 0 1
1 0 1
1 0 2
1 0 2
1 0 2
1 0 2
1 0 1
1 0 2
1 0 2
1 0 2
1 0 1
1 0 1
1 0 2
1 0 2
1 0 2
1 0 2
1 0 1
1 0 1
1 0 1
1 0 1
1 0 1
1 0 1
1 0 1
1 0 1
1 0 1
1 0 2
1 0 1
1 0 1
1 0 2
1 0 1
1 0 1
1 0 2
1 0 2...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok Accepted.

Test #84:

score: 11
Acceptable Answer
time: 47ms
memory: 108068kb

input:

100
4914 5868584 2
4855 1980
1713 1299
1733 640
3936 2505
1258 1919
2989 2100
1549 1808
3837 534
2254 2130
459 1376
3914 200
2187 692
3465 2689
4501 1594
4516 3783
4095 3045
22 2133
1256 1369
1073 1136
646 3990
4506 3499
2663 3812
3649 3512
3573 2111
2241 2707
1879 2677
4216 2691
2878 1285
4604 4816...

output:

4138 919 868 1096 2627 2136 2958 4500 4844 4016 1885 4599 328 4594 2500 2568 4365 4322 4042 4603 1746 2462 1438 3458 418 3269 4616 2935 3118 339 4046 1992 2214 2634 4356 2112 2023 4712 3209 3622 4101 432 2085 4606 3049 491 36 909 4774 4155 4879 4541 679 1200 3027 1490 1201 1579 2038 4180 161 4227 32...

result:

points 0.50 Partially Correct | type = 2

Test #85:

score: 11
Acceptable Answer
time: 50ms
memory: 111976kb

input:

50
9264 14343522 2
4127 3748
8726 7859
1654 448
5251 8559
2277 3834
8033 4427
8913 6115
759 3415
671 312
1678 2639
6702 2797
3520 7485
464 1726
2509 6969
3491 6541
1904 4841
443 3242
6363 7280
2589 1882
2697 5015
9186 9026
125 70
2312 5699
5927 4834
4402 4396
7256 8408
2441 5044
1999 3156
564 3901
2...

output:

3703 5791 5151 8950 6885 7313 3178 138 883 5787 8182 6646 7678 912 1570 640 2036 2669 756 1735 2341 1172 5973 1205 4931 3567 1242 478 6643 4610 2167 2272 494 3698 3686 7575 5143 6827 2348 3928 7861 3438 2477 9118 353 7716 399 8312 3841 7055 4973 2698 8041 9042 6111 7135 3172 79 5941 2543 3322 1610 1...

result:

points 0.50 Partially Correct | type = 2

Test #86:

score: 11
Acceptable Answer
time: 41ms
memory: 109116kb

input:

50
9392 58225 1
6228 6729
316 3831
4383 827
4783 206
901 8057
8725 8920
6509 5267
2014 6918
7013 8718
699 1492
7298 8293
309 3846
5194 5883
3758 6754
7087 2643
2026 4947
7467 4209
5897 1024
7167 8508
4305 2042
6807 9031
2272 3612
7696 4195
3339 8474
8564 1256
8979 1773
3222 4076
4412 8107
27 3558
23...

output:

-1
1670 230 2530 2090 9444 429 828 8557 1335 946 7424 4101 5906 5667 3063 1301 3599 5913 2142 6361 5239 7228 5674 4489 6128 7514 7762 5730 9165 8945 7173 1511 8703 5649 966 1756 6120 8024 273 6747 1180 571 2717 182 6696 6988 4565 9362 7766 4379 3354 8385 5767 3433 4981 1674 3872 5196 21 681 5453 768...

result:

points 0.50 Partially Correct | type = 2

Test #87:

score: 11
Acceptable Answer
time: 77ms
memory: 112788kb

input:

25
19790 20927306 2
4444 6276
14933 10108
6231 5388
15299 4203
17068 12794
10252 8287
6787 4058
2947 7053
16913 8475
5104 4109
10834 9443
11748 12927
8388 16660
4325 9605
16413 2446
16668 323
2038 4364
19597 2386
17857 2971
12045 2107
10345 15034
5324 4685
1910 9248
19068 3915
8777 3401
17337 2365
1...

output:

3593 15882 5192 3284 14125 633 5694 19142 19130 14350 7810 6913 14515 15880 5055 7317 11287 8529 6218 2711 14840 6076 17614 10039 4817 6991 12086 4123 3739 1003 13207 14672 7608 3898 4024 5803 16973 5498 8973 13063 12133 12658 2337 4544 10200 13821 8384 12132 12576 17076 5481 17838 6560 15963 19241 ...

result:

points 0.50 Partially Correct | type = 2

Test #88:

score: 11
Acceptable Answer
time: 77ms
memory: 107120kb

input:

25
19975 93145930 2
12432 1834
1881 14484
15930 10534
10845 7335
8074 9798
361 16500
1801 6929
4437 3207
14447 5118
6677 4193
1052 4088
869 640
15256 8605
8186 18363
15464 3806
5778 17272
9822 14677
5350 15754
1674 18160
1783 8216
15853 14470
14582 12437
2545 812
1606 18202
19624 9375
1895 6171
8629...

output:

12748 4100 2315 7985 12791 1258 2071 9879 7744 7288 6109 3717 1122 4807 1781 11993 1208 12428 2030 6190 14685 8147 9099 6495 3889 16899 3511 3636 18142 3300 9884 15780 8436 13823 6099 1679 3391 1108 5220 8037 8803 19327 11042 2262 9906 15080 12606 4449 16522 2118 3346 7643 11930 18848 10839 15437 26...

result:

points 0.50 Partially Correct | type = 2

Test #89:

score: 11
Acceptable Answer
time: 71ms
memory: 106668kb

input:

10
47976 591885312 2
5124 43680
2252 9516
19288 8740
28470 38971
44005 16449
35113 31009
7142 23054
26551 47176
10450 26089
21857 23087
41980 36670
42848 35489
10282 16403
5395 30470
15802 45845
17969 7447
34743 7617
34799 20623
34264 26807
33968 43764
29498 27833
40072 29805
28680 33112
22228 26794...

output:

47561 43708 10508 39627 18215 39000 47500 3690 28249 18629 27583 41595 4320 43629 45722 12630 11324 2829 24797 46611 39947 22483 31460 1116 22923 13131 41430 33016 24464 23410 18356 7377 42889 38725 26932 12025 3002 7199 13522 2017 47022 43936 7115 14587 43941 26627 10146 11567 30530 29938 30376 318...

result:

points 0.50 Partially Correct | type = 2

Test #90:

score: 11
Acceptable Answer
time: 80ms
memory: 112340kb

input:

10
45442 215847028 1
18473 30982
44534 41274
2723 45201
13119 6426
38639 43918
31640 2906
32096 15308
1356 8922
22081 4880
45055 5993
13173 20550
16941 19759
16629 2018
19954 43873
13002 18173
11394 28098
41851 25383
5142 31705
27108 15842
35992 22440
32300 24908
6264 14876
8386 39768
27107 20226
11...

output:

-1
32950 4964 14609 2298 34200 34930 44042 27062 36026 24130 3288 41449 26064 41434 36404 42158 5702 29868 6467 16163 4724 35504 2054 29199 29554 36573 26392 3016 3952 9435 29817 23820 37114 15616 40974 18684 12183 16150 36903 40419 41852 28942 2433 11721 45551 39805 18486 42872 10081 631 12686 3297...

result:

points 0.50 Partially Correct | type = 2

Test #91:

score: 11
Acceptable Answer
time: 94ms
memory: 121716kb

input:

5
98026 412627902 2
48046 18927
13901 28466
35521 5201
80007 11667
80793 96581
55539 20025
5543 85851
55543 21411
29340 34851
29610 60263
18792 84130
32073 75581
78498 30643
1376 11678
50702 79538
3515 33613
58947 90914
32141 54510
97107 57425
16944 15325
26833 50683
53820 39405
4095 9382
40911 6943...

output:

54951 80974 92127 49617 13085 24091 58587 1407 159 33031 67764 5476 65850 11349 53098 13441 12959 20270 20520 54943 92834 94809 87973 11122 13277 94949 97995 83498 37412 16305 94894 97232 17141 61101 33014 86418 31119 95713 54834 13949 82837 53642 88131 41403 45575 76907 57957 95211 1353 74607 6452 ...

result:

points 0.50 Partially Correct | type = 2

Test #92:

score: 11
Acceptable Answer
time: 41ms
memory: 115096kb

input:

5
91305 1628174951 1
56198 20850
52916 85909
35476 56437
1834 9115
12192 10250
42982 57176
9593 27306
24150 48020
65107 42644
78643 42705
52340 56849
10078 23282
57269 5876
77632 26605
32767 24018
81204 21219
47096 12948
33055 2485
54922 15109
4406 72601
71077 36886
57706 24314
9215 42336
36145 6145...

output:

-1
-1
-1
-1
28269 32630 45287 20224 85787 2985 18968 58320 33676 48992 29267 33518 31051 23035 83523 10501 11094 68205 81942 37964 63342 75146 84182 44763 24095 38299 46449 35600 32558 87981 41592 78552 47623 55131 29725 34036 29556 54596 72060 63281 82630 21531 34164 22128 64109 9038 23024 15856 74...

result:

points 0.50 Partially Correct | type = 2

Test #93:

score: 11
Acceptable Answer
time: 19ms
memory: 55108kb

input:

1
472025 16043466085 1
417926 39623
195768 229314
370537 57531
267104 382113
170933 141578
53561 74294
250159 31886
9352 36181
322148 394068
117039 351210
300887 304015
24549 24940
114489 128610
411952 339863
71691 11387
73530 4523
10760 14371
149252 155462
22680 357719
350109 402379
152082 101050
2...

output:

-1

result:

points 0.50 Partially Correct | type = 2

Test #94:

score: 11
Acceptable Answer
time: 32ms
memory: 101712kb

input:

62500
8 19 1
8 1
2 3
7 3
3 6
6 4
4 1
1 5
8 14 2
3 2
8 2
1 4
4 5
5 6
6 2
2 7
8 20 1
2 1
4 7
7 3
3 6
6 8
8 1
1 5
8 10 1
1 3
8 6
6 3
3 4
4 7
7 5
5 2
8 11 1
5 6
6 1
1 8
8 3
3 4
4 2
2 7
8 14 2
6 1
2 4
4 1
1 8
8 3
3 5
5 7
8 14 1
8 6
3 5
5 7
7 4
4 6
6 1
1 2
8 15 1
4 3
1 6
8 6
6 3
3 2
2 5
5 7
8 22 2
4 7
6 3...

output:

-1
2 8 7 6 5 4 1 3 
-1
-1
-1
8 3 5 7 1 6 4 2 
-1
-1
2 5 6 1 4 8 3 7 
4 1 7 2 8 6 5 3 
2 6 8 3 7 5 4 1 
8 7 2 3 6 4 5 1 
-1
8 5 1 7 2 6 4 3 
5 4 7 2 6 8 1 3 
5 7 2 3 1 4 6 8 
6 7 5 8 1 3 4 2 
-1
7 6 1 5 4 2 3 8 
-1
-1
2 8 6 5 7 1 3 4 
-1
-1
5 7 4 2 6 3 1 8 
-1
8 6 5 1 4 7 3 2 
5 6 8 4 7 3 2 1 
3 8 6 ...

result:

points 0.50 Partially Correct | type = 2

Test #95:

score: 11
Acceptable Answer
time: 16ms
memory: 54992kb

input:

1
482724 69862381824 1
137472 24627
53394 136713
29923 24872
183115 104962
360179 53778
95044 16923
208793 216766
343809 82383
389111 122728
267129 163660
381943 86337
191746 130719
179638 171500
16541 49248
9266 60892
245541 12470
324537 105560
368925 467572
480713 67654
10418 410596
140876 300727
...

output:

-1

result:

points 0.50 Partially Correct | type = 2

Test #96:

score: 11
Acceptable Answer
time: 19ms
memory: 54200kb

input:

1
466556 37068012357 1
296077 254374
55895 139417
250053 262476
281210 151748
361746 75307
38308 211
25635 226913
290473 170308
112117 207274
333222 333380
165721 128597
76733 301893
137129 112197
171945 20656
193257 43287
93646 249912
343755 80957
434796 359970
277965 34924
188290 4117
401431 43469...

output:

-1

result:

points 0.50 Partially Correct | type = 2

Test #97:

score: 11
Acceptable Answer
time: 19ms
memory: 54172kb

input:

1
470507 15553613111 1
116590 375013
25458 460568
274726 423221
185476 26173
129323 115569
393959 379177
186613 320883
413505 47092
298840 72519
445171 170296
28563 18974
198881 343336
153370 1813
428633 372899
188361 262767
97460 411511
23648 449045
388428 367955
10793 398742
305885 3039
441903 422...

output:

-1

result:

points 0.50 Partially Correct | type = 2

Test #98:

score: 22
Accepted
time: 260ms
memory: 178068kb

input:

1
484644 70415722676 2
387061 60091
283751 60069
107460 354884
445876 55307
338664 281406
388782 24215
35572 117625
177669 98530
7682 233035
116725 414416
355609 95819
475062 198221
241991 472832
44124 13983
140233 377622
213795 216775
272564 443204
119914 351907
326597 142211
466195 381175
457028 2...

output:

271472 292069 293952 474645 266355 411109 188944 85999 430211 151898 150674 312184 215152 83233 233668 307874 425462 209149 477176 454326 173286 212138 356448 405233 15740 282065 389433 323753 373698 273970 374624 116049 101990 410234 27545 55409 429551 317826 80834 474774 425056 290775 369167 10010...

result:

ok Accepted.

Test #99:

score: 22
Accepted
time: 247ms
memory: 174184kb

input:

1
480049 66333578702 2
414780 52384
229954 204017
477598 350060
177290 395393
22600 399649
194443 4952
375752 445636
81605 302911
366288 84718
57315 335522
472784 367329
137447 408097
409021 236863
121965 347700
346918 58159
445793 183641
255068 367810
442172 237707
471652 352900
286081 25476
89138 ...

output:

260795 300118 114916 338431 471823 185697 9395 29214 10992 246125 252255 417225 37253 51062 156805 30841 343067 141464 30382 254240 387779 112767 194163 323903 130209 263553 203370 195024 154223 351348 188484 468693 274912 175237 326937 446243 225199 77253 479073 248890 29080 424614 46813 451006 449...

result:

ok Accepted.

Test #100:

score: 11
Acceptable Answer
time: 25ms
memory: 101760kb

input:

1000
498 181292 1
55 405
423 313
133 192
359 39
367 203
366 42
100 76
358 263
183 445
87 27
114 402
331 371
272 424
394 194
417 268
285 284
328 59
125 495
495 364
201 407
310 18
337 283
213 154
346 229
16 65
341 480
315 252
393 19
7 153
365 86
95 144
287 349
262 470
332 295
424 255
336 491
491 311
6...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
426 396 196 191 301 367 77 10 233 37 356 334 314 329 239 265 139 148 438 52 311 282 395 49 363 364 204 460 360 91 410 461 80 222 266 418 248 445...

result:

points 0.50 Partially Correct | type = 2

Test #101:

score: 11
Acceptable Answer
time: 34ms
memory: 101728kb

input:

10000
45 550 2
44 17
41 23
36 17
38 11
35 13
5 30
24 26
1 9
25 16
16 40
13 18
26 37
32 7
7 17
39 2
27 12
12 34
34 15
15 30
30 14
14 18
18 37
37 20
20 9
9 29
29 28
28 8
8 3
3 23
23 19
19 6
6 17
17 10
10 2
2 40
40 21
21 33
33 11
11 45
45 4
4 22
22 43
43 42
42 31
46 635 1
1 9
27 4
26 25
19 23
44 11
18 ...

output:

19 34 12 27 42 31 15 22 43 5 4 30 45 14 38 35 11 13 33 18 21 24 25 26 16 37 40 20 39 1 2 9 10 29 32 28 7 8 36 3 44 41 17 23 6 
-1
-1
41 1 39 31 27 28 34 35 25 20 44 38 46 26 24 47 12 32 43 29 10 45 30 19 36 48 14 4 9 16 11 23 50 5 2 49 18 7 40 3 6 8 42 33 21 37 22 17 15 13 
32 29 30 46 20 9 6 3 41 1...

result:

points 0.50 Partially Correct | type = 2

Test #102:

score: 11
Acceptable Answer
time: 37ms
memory: 102504kb

input:

2000
230 11927 1
198 69
181 202
214 145
16 114
211 199
20 92
100 194
177 145
55 228
228 152
101 138
203 42
137 186
36 77
189 152
152 196
6 22
57 123
123 213
213 27
217 157
187 127
22 172
172 168
224 155
33 144
144 13
167 166
61 209
135 175
48 200
199 124
50 230
161 109
190 226
30 155
86 79
79 183
29...

output:

-1
-1
-1
179 121 201 170 223 138 238 117 162 194 240 42 109 185 79 218 66 210 61 190 76 234 59 91 56 60 186 199 197 243 58 164 152 124 73 196 72 26 25 127 65 128 41 168 129 105 141 112 227 113 131 2 119 160 183 17 88 9 224 192 150 231 86 226 110 96 233 37 114 216 139 11 21 154 36 69 27 95 51 55 142 ...

result:

points 0.50 Partially Correct | type = 2

Test #103:

score: 11
Acceptable Answer
time: 50ms
memory: 105836kb

input:

1000
465 6312 1
172 465
369 274
119 226
243 432
107 307
438 450
462 86
210 147
283 27
463 112
75 236
452 25
381 451
366 131
92 121
394 111
241 400
317 67
85 161
254 13
153 277
251 83
295 398
145 261
165 219
311 454
66 399
272 445
387 236
120 10
37 273
216 181
464 439
108 298
214 253
441 234
186 234
...

output:

-1
-1
19 4 94 3 151 172 33 423 51 409 267 115 157 113 292 293 191 302 485 378 446 424 346 343 98 8 99 209 43 122 286 234 154 285 53 194 323 197 40 428 192 88 397 464 148 305 330 173 245 421 328 155 108 283 351 116 279 358 377 47 461 434 449 326 347 181 29 349 359 214 318 247 185 49 132 28 54 91 270 ...

result:

points 0.50 Partially Correct | type = 2

Test #104:

score: 11
Acceptable Answer
time: 45ms
memory: 106808kb

input:

500
975 3692 1
48 713
274 540
244 542
880 807
684 55
596 796
763 802
626 90
958 281
863 846
215 708
894 106
301 585
772 776
305 252
182 782
314 574
254 211
533 842
86 389
527 388
459 595
726 938
601 412
338 392
669 176
737 556
897 160
121 963
262 106
641 462
462 733
581 224
740 878
817 485
350 895
9...

output:

-1
-1
601 320 511 820 567 653 201 454 255 326 924 279 105 133 459 86 419 322 694 528 229 532 425 669 387 95 456 2 954 833 113 625 223 66 725 6 268 917 664 518 701 265 457 655 478 126 563 198 533 256 682 587 942 738 803 429 945 34 91 671 597 615 733 849 542 594 512 830 691 735 349 58 497 227 131 524 ...

result:

points 0.50 Partially Correct | type = 2

Test #105:

score: 11
Acceptable Answer
time: 41ms
memory: 106812kb

input:

500
962 55094 2
235 718
135 459
342 659
434 460
921 812
495 217
751 340
546 326
439 820
337 780
523 223
658 277
938 947
701 493
809 501
198 895
883 554
293 504
627 939
103 688
297 215
26 828
3 402
273 885
190 172
470 871
465 889
244 698
356 926
878 940
23 961
730 476
906 459
80 479
823 139
881 395
3...

output:

571 350 460 434 704 774 147 782 365 532 501 809 473 484 771 45 714 420 48 59 330 320 694 681 642 922 616 709 461 732 362 618 959 653 340 751 661 443 822 941 299 877 790 824 65 463 847 600 131 961 23 453 841 842 853 605 317 419 947 938 415 535 695 776 727 710 696 543 932 637 934 407 536 22 25 451 166...

result:

points 0.50 Partially Correct | type = 2

Test #106:

score: 11
Acceptable Answer
time: 49ms
memory: 108040kb

input:

100
4746 1051132 2
1237 3867
2107 4075
3048 3224
2208 1419
3875 1498
598 1118
4554 3504
1732 1316
1594 1279
3626 2781
2662 3766
3719 4529
4566 3799
178 2964
340 768
2823 3777
217 2269
2504 2945
345 4068
2882 3668
2116 471
2368 3872
606 1614
2884 961
1854 4389
4510 920
3424 2284
3637 2875
1692 2741
1...

output:

1322 853 1454 2010 4278 1717 2275 91 2671 2307 901 758 3759 142 4325 1808 4243 1613 3974 1855 4323 2451 3272 329 4518 4513 783 1764 719 3864 1328 3818 4443 4178 1059 462 2331 1911 3883 844 2744 3136 77 313 959 1300 2547 3778 3648 4182 4486 3926 4355 3722 4252 4144 3474 1705 4058 4460 588 1691 2566 2...

result:

points 0.50 Partially Correct | type = 2

Test #107:

score: 11
Acceptable Answer
time: 47ms
memory: 109816kb

input:

100
4503 2286264 1
1641 2688
3396 2617
2562 833
1305 2310
638 850
2450 2086
1235 1661
4143 1757
3412 3937
1584 12
1159 736
3175 3109
1202 2747
3778 3893
1592 1029
203 982
3709 1326
2540 2325
2707 893
43 2008
2203 2422
1901 3772
559 3365
4355 2942
1770 3316
2864 2218
2544 359
763 4500
3537 2236
376 2...

output:

-1
-1
633 308 4959 1339 1280 1549 4860 4018 1051 3212 4765 4414 224 1281 3994 2082 3473 4841 3709 3115 3131 3614 4570 3835 4111 4351 171 4819 4711 223 756 582 1030 3124 3562 417 1389 4425 70 4613 2801 1481 3915 1045 3199 3139 4698 4479 1009 872 3367 2562 1673 4375 3432 4474 674 1766 1295 508 2051 92...

result:

points 0.50 Partially Correct | type = 2