QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#187944#7507. AldLynkcatAC ✓453ms105984kbC++2012.6kb2023-09-25 07:39:142023-09-25 07:39:14

Judging History

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

  • [2023-09-25 07:39:14]
  • 评测
  • 测评结果:AC
  • 用时:453ms
  • 内存:105984kb
  • [2023-09-25 07:39:14]
  • 提交

answer

#include <bits/stdc++.h>

namespace std {

template<class Fun>
class y_combinator_result {
	Fun fun_;
public:
	template<class T>
	explicit y_combinator_result(T &&fun): fun_(std::forward<T>(fun)) {}

	template<class ...Args>
	decltype(auto) operator()(Args &&...args) {
		return fun_(std::ref(*this), std::forward<Args>(args)...);
	}
};

template<class Fun>
decltype(auto) y_combinator(Fun &&fun) {
	return y_combinator_result<std::decay_t<Fun>>(std::forward<Fun>(fun));
}

} // namespace std

template <typename T, class Compare = std::less<T>> class RangeMinQuery : private Compare {
	static const int BUCKET_SIZE = 32;
	static const int BUCKET_SIZE_LOG = 5;
	static_assert(BUCKET_SIZE == (1 << BUCKET_SIZE_LOG), "BUCKET_SIZE should be a power of 2");
	static const int CACHE_LINE_ALIGNMENT = 64;
	int n = 0;
	std::vector<T> data;
	std::vector<T> pref_data;
	std::vector<T> suff_data;
	std::vector<T> sparse_table;
	std::vector<uint32_t> range_mask;

private:
	int num_buckets() const {
		return n >> BUCKET_SIZE_LOG;
	}
	int num_levels() const {
		return num_buckets() ? 32 - __builtin_clz(num_buckets()) : 0;
	}
	int sparse_table_size() const {
		return num_buckets() * num_levels();
	}
private:
	const T& min(const T& a, const T& b) const {
		return Compare::operator()(a, b) ? a : b;
	}
	void setmin(T& a, const T& b) const {
		if (Compare::operator()(b, a)) a = b;
	}

	template <typename Vec> static int get_size(const Vec& v) { using std::size; return int(size(v)); }

public:
	RangeMinQuery() {}
	template <typename Vec> explicit RangeMinQuery(const Vec& data_, const Compare& comp_ = Compare())
		: Compare(comp_)
		, n(get_size(data_))
		, data(n)
		, pref_data(n)
		, suff_data(n)
		, sparse_table(sparse_table_size())
		, range_mask(n)
	{
		for (int i = 0; i < n; i++) data[i] = data_[i];
		for (int i = 0; i < n; i++) {
			if (i & (BUCKET_SIZE-1)) {
				uint32_t m = range_mask[i-1];
				while (m && !Compare::operator()(data[(i | (BUCKET_SIZE-1)) - __builtin_clz(m)], data[i])) {
					m -= uint32_t(1) << (BUCKET_SIZE - 1 - __builtin_clz(m));
				}
				m |= uint32_t(1) << (i & (BUCKET_SIZE - 1));
				range_mask[i] = m;
			} else {
				range_mask[i] = 1;
			}
		}
		for (int i = 0; i < n; i++) {
			pref_data[i] = data[i];
			if (i & (BUCKET_SIZE-1)) {
				setmin(pref_data[i], pref_data[i-1]);
			}
		}
		for (int i = n-1; i >= 0; i--) {
			suff_data[i] = data[i];
			if (i+1 < n && ((i+1) & (BUCKET_SIZE-1))) {
				setmin(suff_data[i], suff_data[i+1]);
			}
		}
		for (int i = 0; i < num_buckets(); i++) {
			sparse_table[i] = data[i * BUCKET_SIZE];
			for (int v = 1; v < BUCKET_SIZE; v++) {
				setmin(sparse_table[i], data[i * BUCKET_SIZE + v]);
			}
		}
		for (int l = 0; l+1 < num_levels(); l++) {
			for (int i = 0; i + (1 << (l+1)) <= num_buckets(); i++) {
				sparse_table[(l+1) * num_buckets() + i] = min(sparse_table[l * num_buckets() + i], sparse_table[l * num_buckets() + i + (1 << l)]);
			}
		}
	}

	T query(int l, int r) const {
		assert(l <= r);
		int bucket_l = (l >> BUCKET_SIZE_LOG);
		int bucket_r = (r >> BUCKET_SIZE_LOG);
		if (bucket_l == bucket_r) {
			uint32_t msk = range_mask[r] & ~((uint32_t(1) << (l & (BUCKET_SIZE-1))) - 1);
			int ind = (l & ~(BUCKET_SIZE-1)) + __builtin_ctz(msk);
			return data[ind];
		} else {
			T ans = min(suff_data[l], pref_data[r]);
			bucket_l++;
			if (bucket_l < bucket_r) {
				int level = (32 - __builtin_clz(bucket_r - bucket_l)) - 1;
				setmin(ans, sparse_table[level * num_buckets() + bucket_l]);
				setmin(ans, sparse_table[level * num_buckets() + bucket_r - (1 << level)]);
			}
			return ans;
		}
	}
};
namespace zyk
{
	using namespace std;
	#define fi first
	#define se second
	using path_t = pair<int, int>;
	using diam_t = pair<int, path_t>;
	constexpr int N = 2e5 + 10, inf = 1e9;
	int n, q, ans[N];
	int son[N], sz[N], top[N], fa[N], dep[N], len[N];
	int st[N][20];
	vector<int> G[N];
	namespace sub1 {
		vector<pair<int, int>> qry[N];
		int rt, all, mx[N], sz[N], vis[N];
		int dep[N], cnt[N];
		void findrt(int u, int par) {
			sz[u] = 1, mx[u] = 0;
			for(auto v : G[u]) if(v != par && !vis[v]) {
				findrt(v, u);
				sz[u] += sz[v];
				mx[u] = max(mx[u], sz[v]);
			}
			mx[u] = max(mx[u], all - sz[u]);
			if(mx[u] < mx[rt]) rt = u;
		}
		void calc(int u, int par, int k) {
			vector<int> s;
			int mx = 0;
			function<void(int, int)> dfs = [&](int u, int par) {
				cnt[dep[u]] ++;
				mx = max(mx, dep[u]);
				s.emplace_back(u);
				for(auto v : G[u]) if(v != par && !vis[v]) {
					dep[v] = dep[u] + 1;
					dfs(v, u);
				}
			};
			dfs(u, par);
			for(int i = 0; i <= mx; i ++) cnt[i] += cnt[i - 1];
			for(auto u : s) for(auto [d, id] : qry[u]) {
				if(d >= dep[u])	ans[id] += k * cnt[min(mx, d - dep[u])];
			}
			for(int i = 0; i <= mx; i ++) cnt[i] = 0;
		}
		void solve(int u) {
			vis[u] = 1;
			dep[u] = 0;
			calc(u, u, 1);
			for(auto v : G[u]) if(!vis[v]) {
				calc(v, u, -1);
			}
			for(auto v : G[u]) if(!vis[v]) {
				findrt(v, u), rt = 0, all = sz[v], findrt(v, u), solve(rt);
			}
		}
		void work() {
			for (int i=0;i<=n;i++) vis[i]=0,dep[i]=0,mx[i]=sz[i]=vis[i]=cnt[i]=0;
			mx[rt = 0] = inf, all = n, findrt(1, 1);
			solve(rt);
		}
	}
	namespace sub2 {
		vector<pair<int, int>> qry[N];
		int *f[N], mem[N << 1], *cur = mem;
		int totc=0;
		void append(int u) {
			f[u] = cur, cur += len[u] + 1;
			totc+=len[u]+1;
		}
		struct Bit {
			int vis[N], c[N], timer;
			void upd(int p, int x) {
				for(; p; p -= p & -p) {
					if(vis[p] != timer) c[p] = 0, vis[p] = timer;
					c[p] += x;
				}
			}
			int qry(int p) {
				int ans = 0;
				for(; p < N; p += p & -p) {
					if(vis[p] != timer) c[p] = 0, vis[p] = timer;
					ans += c[p];
				}
				return ans;
			}
			void clear() {
				timer ++;
			}
		}ds;
		void dfs(int u) {
			f[u][0] = 1;
			if(son[u]) f[son[u]] = f[u] + 1, dfs(son[u]);
			for(auto v : G[u]) if(v != fa[u] && v != son[u]) {
				append(v);
				dfs(v);
				for(int i = 0; i <= len[v]; i ++) f[u][i + 1] += f[v][i];
			}
			if(top[u] == u) {
				vector<vector<pair<int, int>>> upd(len[u] + 1);
				vector<vector<pair<int, int>>> ask(len[u] + 1);
				int cnt = 0;
				for(int x = u; x; x = son[x]) {
					cnt ++;
					for(auto [d, id] : qry[x]) {
						if(d <= len[x]) ask[d].emplace_back(cnt + d, id);
					}
					upd[0].emplace_back(1, cnt);
					for(auto y : G[x]) if(y != son[x] && y != fa[x]) {
						for(int i = 0; i <= len[y]; i ++) {
							upd[i + 1].emplace_back(f[y][i], cnt + i + 1);
						}
					}
				}
				ds.clear();
				for(int i = 0; i <= len[u]; i ++) {
					for(auto [w, p] : upd[i]) {
						ds.upd(p, w);
					}
					for(auto [p, id] : ask[i]) {
						if(id > 0) ans[id] += ds.qry(p);
						else ans[-id] -= ds.qry(p);
					}
	 			}
			}
		}
		void add(int u, int v, int d, int id) {
			while(top[u] != top[v]) {
				qry[son[u]].emplace_back(d, -id);
				qry[top[u]].emplace_back(d, id);
				u = fa[top[u]];
			}
			qry[son[u]].emplace_back(d, -id);
			qry[son[v]].emplace_back(d, id);
		}
		void work() {
			cur=mem;
			for (int i=0;i<totc;i++) mem[i]=0;
			totc=0;
			append(1);
			dfs(1);
		}
	}
	void dfs1(int u, int par) {
		st[u][0]=par;
		for (int i=1;i<20;i++)
			st[u][i]=st[st[u][i-1]][i-1];
		sz[u] = 1, fa[u] = par, dep[u] = dep[par] + 1,son[u]=0,len[u]=0;
		for(auto v : G[u]) if(v != par) {
			dfs1(v, u);
			sz[u] += sz[v];
			if(sz[v] > sz[son[u]]) son[u] = v;
			len[u] = max(len[u], len[v] + 1);
		}
	}
	void dfs2(int u, int tpar) {
		top[u] = tpar;
		if(son[u]) dfs2(son[u], tpar);
		for(auto v : G[u]) if(v != fa[u] && v != son[u]) {
			dfs2(v, v);
		}
	}
	void init() {
		dfs1(1, 1), dfs2(1, 1);	
		for (int i=0;i<=n;i++) vector<pair<int,int>>().swap(sub1::qry[i]);
		for (int i=0;i<=n;i++) vector<pair<int,int>>().swap(sub2::qry[i]);
		sub2::cur=sub2::mem;
	}
	int lca(int u, int v)
	{
		while(top[u] != top[v])
		{
			if(dep[top[u]] < dep[top[v]]) swap(u, v);
			u = fa[top[u]];
		}
		return dep[u] < dep[v] ? u : v;
	}
	int dis(int x,int y)
	{
		return dep[x]+dep[y]-2*dep[lca(x,y)];
	}
	inline int jmp(int x,int y)
	{
		for (int i=19;i>=0;i--)
			if((y>>i)&1) x=st[x][i];
		return x;
	}
	void wtf(int nn,int qq,vector<vector<int>>adj,vector<diam_t>ds,vector<int>qrys) {
		n=nn;
		q=qq;
		for(int i = 1; i <= n; i ++) 
		{
			G[i]=adj[i-1];
			for (auto &u:G[i]) u++;
		}
		init();
		for(int i = 1; i <= q; i ++) ans[i]=0;
		for(int i = 1; i <= q; i ++)
		{
			if (qrys[i-1]==-1) continue;
			int u, v, d;
			u=ds[i-1].se.fi,v=ds[i-1].se.se;
			d=ds[i-1].fi;
			if (u==-1)
			{
				qrys[i-1]=-2;
				continue;
			}
			u++,v++;
			// cout<<u<<" "<<v<<" "<<d<<endl;
			if (d!=0)
			{
				if (dep[u]<dep[v]) swap(u,v);
				if (d%2==0)
				{
					u=v=jmp(u,d/2);
				} else 
				{
					u=jmp(u,d/2);
					v=st[u][0];
				}
				d=qrys[i-1]-(d+1)/2;
			} else d=qrys[i-1];
			if (u==-1||d<0)
			{
				qrys[i-1]=-2;
				continue;
			}
			int w = lca(u, v);
			sub1::qry[w].emplace_back(d, i);
			sub2::add(u, w, d, i);
			sub2::add(v, w, d, i);
		}
		sub1::work();
		sub2::work();
		for(int i = 1; i <= q; i ++) {
			if (qrys[i-1]==-1) continue;
			if (qrys[i-1]==-2) cout<<0<<'\n';
			else
				cout << ans[i] << '\n';
		}
	}
}
void BellaKira()
{
using namespace std;
	using path_t = pair<int, int>;
	using diam_t = pair<int, path_t>;

	int N, Q; cin >> N >> Q;
	vector<vector<int>> adj(N);
	for (int e = 0; e < N-1; e++) {
		int u, v; cin >> u >> v; u--, v--;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}

	vector<int> depth(N);
	vector<int> preorder_idx(N);
	vector<pair<int, int>> preorder_lcas(N-1);
	int cur_idx = 0;
	std::y_combinator([&](auto self, int cur, int prv = -1) -> void {
		depth[cur] = (prv == -1 ? 0 : depth[prv] + 1);
		preorder_idx[cur] = cur_idx;
		cur_idx++;
		for (int nxt : adj[cur]) {
			if (nxt == prv) continue;
			preorder_lcas[cur_idx-1] = max(preorder_lcas[cur_idx-1], {depth[cur], cur});
			self(nxt, cur);
		}
	})(0);

	RangeMinQuery<pair<int, int>> lca_rmq(preorder_lcas);

	auto lca = [&](int a, int b) {
		if (a == b) return a;
		a = preorder_idx[a];
		b = preorder_idx[b];
		if (a > b) swap(a, b);
		return lca_rmq.query(a, b-1).second;
	};

	auto dist = [&](int a, int b) {
		return depth[a] + depth[b] - 2 * depth[lca(a,b)];
	};


	auto closest_pt = [&](int a, path_t p) {
		int c = lca(p.first, p.second);
		int x = lca(a, p.first);
		int y = lca(a, p.second);
		return max({c,x,y}, [&](int u, int v) { return depth[u] < depth[v]; });
	};

	diam_t NO_DIAM{int(1e9), path_t{-1, -1}};

	auto build_diam = [&](int a, int b) -> diam_t {
		return {dist(a,b), {a,b}};
	};

	auto update_diam = [&](diam_t d, path_t a) -> diam_t {
		if (d == NO_DIAM) return {0, a};
		int x = closest_pt(d.second.first, a);
		int y = closest_pt(d.second.second, a);
		if (x != y) {
			if (d.first == 0) {
				return {0, {x, y}};
			} else {
				return d;
			}
		}
		assert(x == y);
		if (d.first == 0) {
			int z = closest_pt(x, d.second);
			return build_diam(x, z);
		} else {
			return max({d, build_diam(d.second.first, x), build_diam(d.second.second, x)});
		}
	};

	set<pair<path_t, int>> alive;
	vector<vector<path_t>> ops(2*Q);
	vector<int> queries(Q, -1);

	for (int q = 0; q < Q; q++) {
		int op; cin >> op;
		if (op == 1 || op == 2) {
			int u, v; cin >> u >> v; u--, v--;
			if (u > v) swap(u, v);
			path_t path(u, v);
			if (op == 1) {
				alive.insert({path, q});
			} else {
				auto it = alive.lower_bound({path, -1});
				assert(it != alive.end() && it->first == path);
				int t0 = it->second;
				alive.erase(it);

				for (int a = Q+t0, b = Q+q; a < b; a >>= 1, b >>= 1) {
					if (a & 1) ops[a++].push_back(path);
					if (b & 1) ops[--b].push_back(path);
				}
			}
		} else if (op == 3) {
			int d; cin >> d;
			queries[q] = d;
		} else assert(false);
	}
	for (auto it : alive) {
		int t0 = it.second;
		path_t path = it.first;
		for (int a = Q+t0, b = Q+Q; a < b; a >>= 1, b >>= 1) {
			if (a & 1) ops[a++].push_back(path);
			if (b & 1) ops[--b].push_back(path);
		}
	}

	vector<diam_t> actual_diam(Q);
	std::y_combinator([&](auto self, int a, diam_t d) -> void {
		for (path_t p : ops[a]) {
			d = update_diam(d, p);
		}
		if (a >= Q) {
			actual_diam[a-Q] = d;
		} else {
			self(2*a, d);
			self(2*a+1, d);
		}
	})(1, NO_DIAM);
	// cout<<"??"<<endl;
	zyk::wtf(N,Q,adj,actual_diam,queries);
	return;
}
signed main()
{
	using namespace std;
	int T=1;
	ios_base::sync_with_stdio(false), cin.tie(nullptr);
	cin>>T;
	while (T--)
	{
		BellaKira();
	}
}
	

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 30308kb

input:

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

output:

0
7
3

result:

ok 3 number(s): "0 7 3"

Test #2:

score: 0
Accepted
time: 52ms
memory: 32628kb

input:

10000
8 9
1 2
1 3
3 4
2 5
4 6
1 7
6 8
3 8
3 1
1 7 8
2 7 8
3 8
1 8 6
1 7 7
2 7 7
3 5
1 6
3 1
1 1 1
2 1 1
1 1 1
2 1 1
1 1 1
2 2
1 2
3 0
3 1
7 9
1 2
2 3
3 4
1 5
4 6
5 7
1 3 3
2 3 3
1 5 7
3 7
2 5 7
1 2 1
3 1
1 4 6
3 5
4 4
1 2
2 3
3 4
3 3
3 1
3 2
3 0
6 6
1 2
2 3
2 4
4 5
2 6
1 2 1
1 6 5
1 2 1
2 6 5
3 4
2 ...

output:

0
0
0
8
0
0
0
7
4
7
0
0
0
0
6
0
0
7
0
0
9
0
9
9
5
0
0
0
1
1
0
0
0
0
0
0
0
1
1
1
1
0
0
4
0
0
0
0
0
0
9
10
0
0
0
0
0
8
0
0
6
6
6
6
4
2
0
0
0
0
0
0
0
1
0
4
5
6
0
10
2
0
0
0
0
0
0
0
0
0
0
6
6
0
0
2
0
0
0
9
10
10
0
4
0
0
2
2
0
1
0
0
0
0
8
8
8
8
0
0
0
0
0
0
0
2
0
0
0
0
0
7
0
0
0
1
4
4
9
0
0
0
0
0
0
0
1
2
...

result:

ok 22564 numbers

Test #3:

score: 0
Accepted
time: 82ms
memory: 30320kb

input:

10000
10 10
1 2
1 3
1 4
2 5
3 6
6 7
4 8
3 9
4 10
3 8
3 10
1 8 7
1 2 3
3 7
3 2
1 2 3
3 2
3 9
2 8 7
10 10
1 2
1 3
3 4
4 5
1 6
3 7
7 8
2 9
7 10
1 3 2
1 4 6
2 4 6
2 3 2
3 4
3 6
3 7
1 6 7
2 6 7
3 1
10 10
1 2
1 3
2 4
3 5
5 6
4 7
3 8
3 9
2 10
1 1 6
1 6 8
2 6 8
2 1 6
1 7 1
1 2 3
3 0
2 7 1
2 2 3
3 9
10 10
1 ...

output:

0
0
10
10
10
10
0
0
0
0
2
0
0
0
0
0
0
0
0
0
0
0
10
10
0
10
10
10
3
0
0
0
0
10
10
6
10
0
0
0
0
0
0
0
10
10
7
0
0
0
10
10
0
10
9
10
10
10
10
0
10
10
7
10
10
10
2
0
10
10
10
10
0
0
9
10
10
10
10
2
10
10
0
0
0
0
0
10
10
10
8
10
10
0
10
1
0
0
0
0
0
0
0
10
10
10
10
10
10
10
0
10
0
10
6
0
0
0
0
0
0
0
0
10
...

result:

ok 39484 numbers

Test #4:

score: 0
Accepted
time: 83ms
memory: 28344kb

input:

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

output:

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

result:

ok 39854 numbers

Test #5:

score: 0
Accepted
time: 318ms
memory: 74588kb

input:

1
99968 99920
12328 30612
75431 3389
47274 68763
61952 53251
12770 2313
53089 17045
18954 47810
84960 35981
87320 1250
65851 20501
94791 20163
31839 43446
87859 44280
65181 34364
37058 96930
52761 95156
30691 45654
96364 50268
89912 53877
87814 65218
78729 6520
90843 22848
91503 46590
9040 49269
709...

output:

0
0
42624
3551
99968
99968
99968
99968
63
99968
1023
639
65535
4095
32767
99968
11
23
99968
191
47
99968
63
15
99968
99968
0
99968
99968
3071
767
47
5
99968
639
99968
159
20479
99968
50816
99968
99968
4
1279
99968
319
5119
99968
159
19
159
99968
0
1
99968
2559
99968
19
9
99968
99968
99968
40959
639
...

result:

ok 25019 numbers

Test #6:

score: 0
Accepted
time: 314ms
memory: 78824kb

input:

1
99988 99964
27726 37863
84833 38309
96656 66746
60134 91616
80578 5325
41580 25785
64482 11587
15741 13670
58973 36685
66238 12294
71097 37863
16219 56995
98577 92459
11778 98035
76298 64247
86057 8195
90308 40433
86252 41533
33398 99824
35124 56972
83401 48022
37482 56259
61316 25891
17534 79149
...

output:

17
27
99988
98303
19
99988
2047
0
81919
40959
99988
81919
2559
99988
99988
639
20479
0
99988
99988
639
99988
159
99988
99988
16383
99988
99988
3071
99988
99988
12287
99988
319
4
0
0
99988
99988
11
0
99988
99988
16383
0
99988
0
6143
47
1535
767
99988
383
6143
99988
99988
12287
99988
0
23
0
3071
98303...

result:

ok 24892 numbers

Test #7:

score: 0
Accepted
time: 310ms
memory: 77228kb

input:

1
99964 99977
74747 24685
32426 42538
80187 53070
35370 31761
96765 22872
91643 24816
92552 84215
54959 56415
67368 8465
60438 20780
18125 50799
52086 19750
19288 63917
50941 33272
69734 99862
81421 33090
55090 72418
88938 59889
67068 9016
24383 11261
68274 73535
29975 16700
23370 70256
2804 9172
91...

output:

99964
99964
81919
99964
99964
99964
99964
223
99964
99964
81919
0
223
1791
0
99964
11263
99964
99964
10239
99964
0
99964
99964
40959
99964
20479
1279
99964
639
39
159
99964
31
65535
63
99964
99964
7
99964
99964
99964
99964
4
0
0
375
99964
99964
28671
99964
40959
30
40959
7935
61
1983
0
251
99964
671...

result:

ok 25155 numbers

Test #8:

score: 0
Accepted
time: 290ms
memory: 75808kb

input:

1
99985 99991
71238 82383
53659 78762
7086 59211
94188 81174
92857 15842
11580 89282
18719 9288
64350 79673
87105 51180
80503 38975
99471 27713
23502 10125
73904 28774
11745 4566
90770 11829
45629 39829
51863 76315
83827 96691
33700 39223
66896 61372
27173 49396
22047 8781
26157 16812
18769 62809
14...

output:

391
895
57343
99985
99985
1791
99985
115
0
99985
99985
28671
7167
1919
99985
99985
28671
99985
99985
2815
99985
99985
99985
175
22527
1407
99985
99985
81919
99985
99985
99985
0
2815
351
4
99985
99985
99985
21
99985
14
0
99985
99985
239
81919
7679
99985
99985
99985
639
99985
0
98303
319
79
99985
4095...

result:

ok 49860 numbers

Test #9:

score: 0
Accepted
time: 268ms
memory: 74844kb

input:

1
99943 99921
12485 51517
61822 28031
72420 99346
94972 68171
28804 73803
55068 79807
57613 41980
66059 74956
74803 19199
29184 21168
31887 2536
19046 58338
52465 1451
74723 2895
81175 24391
45883 39605
70607 13243
63738 51078
66093 95031
68091 68230
54131 64840
75890 11358
50608 3134
9039 38081
702...

output:

99943
351
99943
99943
87
99943
11263
99943
2815
6655
28671
103
0
255
99943
4
99943
99943
99943
50791
2
99943
99943
99943
50791
447
99943
99943
99943
0
447
50791
639
99943
99943
0
4
10239
0
0
0
99943
0
0
99943
6
0
12287
0
6143
99943
67175
23
99943
175
11263
351
1
99943
0
98303
2
3071
95
95
0
99943
38...

result:

ok 50019 numbers

Test #10:

score: 0
Accepted
time: 286ms
memory: 74884kb

input:

1
99917 99998
53190 54375
13582 35667
52626 99871
58253 38521
38290 10731
74159 21185
67200 59302
9368 41898
74783 18370
36068 83362
77911 89191
23341 18299
27512 89676
348 2899
19757 84762
56348 58214
51615 90691
40444 49691
16554 96685
27025 8031
57019 74201
98610 15742
2866 37215
42684 77340
7016...

output:

8191
28671
47
99917
99917
31
8191
99917
127
16383
99917
99917
99917
99917
14335
7167
98303
1791
6
223
99917
99917
0
99917
99917
16383
15
99917
31
7
99917
99917
511
1983
99917
22527
45055
87
175
1407
99917
4
2815
5631
351
57343
99917
22527
11263
4
99917
1407
99917
703
0
0
99917
99917
99917
99917
9991...

result:

ok 49755 numbers

Test #11:

score: 0
Accepted
time: 262ms
memory: 90048kb

input:

1
99916 99917
52684 55851
6874 28197
85367 69719
7695 96752
27721 90033
47848 18499
56130 55486
63541 81747
78216 2118
45901 67596
46529 43942
80543 62527
23160 68872
77300 53025
66572 71620
58674 29141
86638 52592
64819 26224
53933 96748
64612 33033
33720 28987
77109 71185
61803 65803
82339 91889
3...

output:

7423
98303
12799
4223
391
1311
73727
719
391
98303
73727
98303
12799
98303
1311
1311
391
98303
211
211
2367
113
211
12799
113
29
73727
81919
113
98303
29
4223
211
211
12799
1311
81919
81919
391
73727
73727
98303
391
53247
53247
7423
113
21503
113
81919
391
12799
1311
21503
73727
113
60
1311
7423
532...

result:

ok 25020 numbers

Test #12:

score: 0
Accepted
time: 221ms
memory: 93144kb

input:

1
99935 99974
56646 89095
2976 28295
40655 55363
19355 61412
35226 79028
83773 84876
30517 7105
14148 3778
54814 11812
61958 57376
83979 24075
53719 22539
53170 86933
45685 85193
88508 36785
93151 47360
81525 91351
11966 78211
49068 18408
91831 90179
48028 61204
77954 48916
3777 49739
54007 58980
99...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
181
5503
8959
30303
3263
19455
98
3263
8959
181
5503
98
19455
599
3263
3263
599
3263
13823
3263
25
13823
13823
181
1887
3263
50783
8959
5503
331
50783
25
13823
30303
25
13823
42591
1071
331
331
5503
1887
42591
19455
5503
30303
3263
1071
1071
3263
52
13823
5503
550...

result:

ok 75073 numbers

Test #13:

score: 0
Accepted
time: 283ms
memory: 88872kb

input:

1
99965 99960
46586 32609
72833 90532
20097 62814
51638 62618
3913 58138
48739 99953
79461 17957
95401 25827
3855 84566
2711 57725
85196 87568
33063 675
74413 61876
71428 98562
47503 48090
30071 95498
83065 20276
8716 56512
74299 22743
64976 76726
48891 50701
94002 64921
20824 82839
87844 21750
6738...

output:

57343
99965
2431
28
7679
57343
57
13311
36863
28
13311
99965
7679
399
57
1343
2431
28
22527
99965
1343
4351
13311
57343
735
735
57
57
36863
7679
111
399
735
2431
2431
81919
399
22527
4351
2431
215
399
1343
7679
1343
81919
99965
4351
735
57
399
28
2431
57343
111
22527
28
7679
36863
215
13311
7679
435...

result:

ok 50035 numbers

Test #14:

score: 0
Accepted
time: 249ms
memory: 70924kb

input:

1
99943 100000
66180 77747
55691 55070
79171 36073
30443 42247
70620 52093
634 61129
25342 59768
55453 25717
20888 15466
83973 99582
35017 13794
8279 42828
91988 80434
58354 89141
14063 58807
62709 85236
55568 49193
26238 18245
27155 16336
84276 80529
29459 97973
95432 39265
84769 21209
79526 67615
...

output:

17919
1135
99943
165
45055
6527
99943
81919
40
99943
165
99943
40
6527
99943
99943
17919
99943
57343
315
45055
38911
19
99943
599
99943
7167
895
1791
111
14335
99943
13
99943
99943
99943
99943
99943
11
5
479
42599
447
99943
0
99943
99943
191
0
0
3071
767
67175
0
11
2
2
0
6143
0
99943
99943
191
0
999...

result:

ok 20000 numbers

Test #15:

score: 0
Accepted
time: 238ms
memory: 72740kb

input:

1
99932 100000
78927 37416
83980 33554
72512 89513
19759 37442
62000 18683
49899 70389
2134 3538
87199 65074
62169 62400
28959 55888
13206 64447
74661 71916
78229 71500
52250 28729
21334 62433
80923 94739
49240 40638
12017 88238
52830 42286
73642 64353
5620 46883
41442 65845
16295 75881
71875 31242
...

output:

7679
215
57
99932
99932
99932
99932
99932
99932
99932
99932
99932
99932
4351
99932
99932
99932
99932
99932
13311
99932
99932
36863
99932
99932
99932
36863
99932
57343
99932
50780
99932
27
99932
0
99932
0
4
0
79
39
98303
1
9
99932
159
0
79
99932
0
0
24575
383
99932
0
767
6143
0
99932
0
98303
0
0
0
99...

result:

ok 20000 numbers

Test #16:

score: 0
Accepted
time: 253ms
memory: 71952kb

input:

1
99936 100000
27988 12699
36186 88802
79222 8340
75735 48387
86976 44713
45042 3481
28363 36654
68599 33449
55691 19835
7109 47620
18723 61710
31011 57487
76121 26056
27959 7394
82262 79105
9368 17253
36871 70950
39207 94605
92196 32427
96327 29038
1999 38497
36473 34052
96125 42898
75036 15305
365...

output:

99936
99936
7679
29
99936
99936
99936
2431
99936
99936
99936
2431
22527
215
399
99936
13311
58976
399
115
2431
99936
99936
13311
99936
95
11
99936
11
99936
2047
99936
511
1023
99936
99936
4
99936
99936
0
0
0
99936
45055
57343
21
703
98303
1407
21
99936
99936
0
0
0
0
10
21
0
87
43
0
99936
99936
1407
...

result:

ok 20000 numbers

Test #17:

score: 0
Accepted
time: 275ms
memory: 74440kb

input:

1
99901 100000
2098 46695
17945 91900
27617 24783
68209 26942
14135 64343
1260 37676
16625 63255
50340 16090
5903 25727
97140 22971
64497 65841
84446 17425
5457 71957
93982 61580
54094 4966
38625 98138
36854 61631
61667 38121
43596 83954
85635 26244
66080 49198
81005 73387
13577 37326
85896 61145
62...

output:

22527
2431
99901
735
99901
57
99901
99901
99901
99901
58941
7679
99901
99901
57
399
83517
99901
99901
215
83517
99901
36863
99901
57
99901
99901
13311
99901
99901
4351
28
99901
7679
4351
2431
36863
13311
13311
399
99901
99901
215
22527
58941
13311
99901
215
99901
36863
99901
99901
115
99901
99901
99...

result:

ok 20000 numbers

Test #18:

score: 0
Accepted
time: 273ms
memory: 73188kb

input:

1
99937 100000
11650 82361
30125 15266
49487 20408
18845 77378
7014 46969
82200 47738
1281 63870
79532 34168
58352 74492
31535 72790
74669 67929
91994 15384
70582 51066
92956 29508
12397 93834
25300 40542
41515 22051
91440 93637
37088 7714
14623 23106
45471 52098
3073 97910
71630 42500
40652 27562
1...

output:

99937
99937
36863
99937
2431
735
13311
57
99937
2431
99937
57
99937
99937
99937
99937
99937
1343
99937
2431
735
22527
13311
99937
13311
99937
22527
111
1343
99937
111
99937
111
4351
111
4351
99937
99937
735
99937
13311
2431
99937
99937
99937
99937
99937
99937
99937
99937
99937
99937
99937
22527
9993...

result:

ok 20000 numbers

Test #19:

score: 0
Accepted
time: 276ms
memory: 74504kb

input:

1
99962 100000
54695 11712
67678 45162
4342 64300
68101 51422
96233 71174
88287 40192
34915 34578
52638 89502
41886 32532
14867 75636
64959 87521
29974 95482
8465 62658
23325 62082
25156 59648
97579 98759
61034 46965
29396 49542
25114 36369
35840 66353
10163 51498
22540 35755
35480 4199
9033 93440
7...

output:

22527
99962
13311
83578
99962
99962
99962
99962
38522
99962
99962
99962
99962
99962
55
215
99962
111
1343
99962
38522
83578
2431
399
38522
215
99962
215
22527
99962
38522
735
99962
99962
7679
99962
399
83578
99962
1343
99962
7679
7679
4351
99962
99962
735
4351
99962
22527
83578
99962
99962
22527
999...

result:

ok 20000 numbers

Test #20:

score: 0
Accepted
time: 148ms
memory: 79220kb

input:

1
99995 99907
61111 19201
10492 19201
19201 15624
19201 48509
19201 28197
45692 19201
19201 60663
87722 19201
76281 19201
19201 49827
19201 51648
19201 13639
19201 57545
97838 19201
19201 78013
19201 74967
91502 19201
79496 19201
90941 19201
19201 515
32555 19201
19201 1717
66349 19201
66380 19201
1...

output:

0
0
99995
1
1
99995
99995
99995
99995
99995
99995
1
99995
99995
99995
1
99995
99995
99995
99995
99995
99995
99995
99995
99995
99995
99995
1
1
99995
99995
99995
99995
99995
1
1
99995
99995
99995
1
1
1
99995
99995
99995
1
99995
99995
99995
99995
99995
99995
1
99995
99995
99995
99995
99995
99995
1
1
99...

result:

ok 24893 numbers

Test #21:

score: 0
Accepted
time: 158ms
memory: 78832kb

input:

1
99976 99974
55069 15229
24618 55069
55069 30112
77712 55069
73829 55069
54116 55069
20313 55069
55069 13333
55069 14287
55069 93909
63447 55069
55069 58081
37540 55069
55069 22793
55069 541
63169 55069
51435 55069
55069 52240
9680 55069
3286 55069
55069 10982
55069 79524
55069 30844
55069 13878
55...

output:

0
99976
99976
99976
99976
99976
99976
99976
1
99976
99976
99976
1
1
99976
99976
99976
99976
99976
99976
99976
1
99976
99976
1
1
99976
99976
1
99976
99976
1
99976
99976
99976
99976
99976
1
99976
1
99976
1
1
99976
99976
1
99976
1
99976
99976
99976
99976
99976
99976
1
99976
99976
99976
1
99976
99976
99...

result:

ok 25183 numbers

Test #22:

score: 0
Accepted
time: 162ms
memory: 79768kb

input:

1
99964 99927
18688 93232
18688 1306
48656 18688
20265 18688
20556 18688
24998 18688
18688 74358
18688 42912
18688 65749
52931 18688
85652 18688
18688 6615
89366 18688
18688 81496
18688 48691
18688 26162
10424 18688
89420 18688
70844 18688
47341 18688
63849 18688
38279 18688
18688 87113
18688 93044
...

output:

0
0
99964
99964
99964
99964
99964
1
99964
99964
99964
99964
1
1
1
99964
1
99964
99964
99964
99964
99964
99964
1
99964
99964
99964
99964
99964
99964
99964
99964
99964
99964
1
1
99964
99964
1
99964
99964
99964
1
1
99964
99964
99964
1
99964
99964
99964
99964
1
99964
99964
99964
99964
99964
99964
99964
...

result:

ok 24935 numbers

Test #23:

score: 0
Accepted
time: 138ms
memory: 77192kb

input:

1
99960 99974
37530 30374
65847 30374
97923 30374
58696 30374
79634 30374
2259 30374
45395 30374
23690 30374
19159 30374
43439 30374
30374 85443
89192 30374
30374 40477
85777 30374
30374 89391
68120 30374
30374 98529
30374 15401
88513 30374
30374 84334
30374 62866
69868 30374
30374 61031
30374 22877...

output:

0
0
0
0
0
0
99960
99960
99960
99960
3
99960
99960
1
1
1
99960
1
99960
99960
1
99960
1
99960
99960
1
99960
99960
99960
99960
99960
99960
99960
99960
99960
99960
99960
99960
99960
99960
99960
99960
99960
99960
1
99960
99960
99960
99960
99960
99960
99960
99960
1
1
99960
99960
99960
99960
99960
99960
99...

result:

ok 50047 numbers

Test #24:

score: 0
Accepted
time: 145ms
memory: 75988kb

input:

1
99913 99955
26441 13669
26441 27083
26441 97326
26441 83037
26441 12577
16022 26441
26441 39647
41193 26441
32136 26441
26441 19969
49516 26441
26441 56437
76485 26441
26441 34335
26441 34562
42867 26441
80726 26441
26441 45003
55676 26441
26441 85788
26441 41685
26441 58387
26441 85205
90297 2644...

output:

0
99913
99913
99913
3
3
99913
99913
99913
99913
99913
99913
3
99913
99913
99913
99913
3
99913
99913
1
1
99913
99913
99913
99913
1
99913
99913
1
99913
99913
99913
99913
99913
1
99913
99913
1
1
1
99913
99913
99913
99913
99913
1
99913
1
99913
99913
99913
1
99913
99913
99913
1
99913
99913
1
99913
99913
...

result:

ok 50132 numbers

Test #25:

score: 0
Accepted
time: 146ms
memory: 79240kb

input:

1
99971 99974
82683 77240
82683 31015
82683 5689
12523 82683
61293 82683
76641 82683
82683 38839
4407 82683
88301 82683
88529 82683
82683 27245
82683 86296
82683 38842
82683 85056
40385 82683
82683 63090
82683 79793
82683 56759
82683 72262
82683 59228
96880 82683
82683 50359
82683 63474
82683 86953
...

output:

0
0
0
99971
99971
99971
99971
1
99971
99971
99971
1
1
99971
1
99971
99971
1
99971
99971
1
99971
99971
99971
99971
99971
99971
99971
99971
99971
99971
99971
99971
99971
1
99971
1
99971
99971
99971
99971
99971
99971
99971
99971
99971
99971
99971
99971
99971
99971
99971
1
99971
1
99971
1
99971
99971
99...

result:

ok 49653 numbers

Test #26:

score: 0
Accepted
time: 201ms
memory: 86936kb

input:

1
99912 99939
26806 36039
26806 70589
26806 93581
26806 69857
26806 60572
16606 26806
21812 26806
26806 12732
25313 26806
26806 2419
83907 26806
26806 20639
26806 40813
26806 54131
26218 26806
59863 26806
77249 26806
26806 34214
14119 26806
26806 79560
66302 26806
26806 10727
26806 21693
92841 26806...

output:

99912
99912
99912
99912
99912
99912
1
1
99912
99912
99912
99912
99912
99912
99912
99912
99912
99912
99912
1
99912
99912
1
99912
99912
1
99912
99912
1
99912
99912
1
99912
99912
99912
99912
99912
99912
99912
99912
99912
99912
99912
99912
99912
1
99912
99912
99912
99912
99912
99912
1
1
99912
1
1
99912
...

result:

ok 24777 numbers

Test #27:

score: 0
Accepted
time: 174ms
memory: 81304kb

input:

1
99907 99948
45929 53221
92795 53221
53221 94270
53221 72784
53221 8991
57145 53221
53221 76772
76356 53221
13660 53221
53221 35560
30418 53221
54067 53221
65377 53221
87607 53221
53221 90430
53221 70262
53221 65206
53221 77526
53221 52677
53221 33305
72588 53221
53221 29431
44524 53221
39371 53221...

output:

3
99907
99907
99907
99907
99907
1
99907
99907
99907
99907
99907
1
1
1
1
99907
99907
99907
1
99907
99907
1
1
99907
99907
99907
1
99907
99907
99907
1
99907
99907
1
99907
99907
99907
99907
99907
1
99907
99907
99907
1
99907
99907
99907
99907
1
99907
99907
99907
99907
1
1
1
99907
1
99907
99907
1
99907
99...

result:

ok 49793 numbers

Test #28:

score: 0
Accepted
time: 210ms
memory: 85704kb

input:

1
99956 99984
6670 48543
2521 48543
48543 80751
48543 10786
48543 16559
9372 48543
13037 48543
48543 44328
2042 48543
48543 24056
47758 48543
33543 48543
14304 48543
48543 82306
83328 48543
48543 38738
48543 94539
5133 48543
6784 48543
48543 18706
15086 48543
30706 48543
21741 48543
76077 48543
1046...

output:

3
1
99956
99956
1
99956
99956
99956
99956
1
99956
99956
1
99956
99956
1
1
99956
99956
99956
99956
99956
99956
99956
1
99956
99956
99956
99956
1
99956
99956
99956
1
99956
99956
99956
99956
99956
1
99956
1
99956
1
99956
99956
99956
99956
99956
99956
99956
99956
1
1
1
99956
1
99956
1
99956
99956
1
9995...

result:

ok 25094 numbers

Test #29:

score: 0
Accepted
time: 129ms
memory: 72288kb

input:

1
99996 100000
33603 60125
60125 41151
21815 60125
60125 4428
60125 76675
63225 60125
48599 60125
6779 60125
64973 60125
33525 60125
95195 60125
60125 62172
60125 47040
48294 60125
70679 60125
60125 99375
60125 44276
60125 51754
60125 88479
60125 71964
60125 74144
60125 21700
67567 60125
60125 56202...

output:

99996
1
1
1
99996
99996
99996
99996
99996
1
99996
99996
99996
1
99996
99996
99996
99996
99996
99996
99996
99996
99996
1
1
1
99996
99996
99996
99996
99996
99996
1
1
99996
1
99996
1
99996
1
1
99996
99996
1
99996
99996
99996
99996
99996
99996
99996
99996
1
99996
1
1
99996
99996
99996
99996
99996
99996
...

result:

ok 20000 numbers

Test #30:

score: 0
Accepted
time: 127ms
memory: 72372kb

input:

1
99969 100000
22975 48326
22975 35662
22975 80138
16424 22975
22975 12012
22975 51873
72349 22975
93345 22975
22975 62534
22975 68077
12843 22975
43172 22975
22975 37899
56829 22975
56050 22975
3811 22975
22975 65785
26352 22975
22975 51731
22975 17781
22975 57650
22975 51665
16583 22975
22975 8535...

output:

1
99969
99969
99969
99969
99969
99969
99969
99969
1
99969
99969
1
99969
99969
1
99969
99969
99969
99969
99969
99969
1
99969
99969
99969
1
99969
99969
99969
1
1
99969
99969
99969
1
99969
99969
1
99969
1
99969
1
99969
1
1
99969
99969
1
99969
99969
1
99969
1
1
99969
99969
99969
99969
99969
99969
1
9996...

result:

ok 20000 numbers

Test #31:

score: 0
Accepted
time: 126ms
memory: 73852kb

input:

1
99900 100000
13189 69226
69226 89260
88880 69226
69226 50633
69226 13052
54534 69226
69226 59897
2543 69226
69226 51695
69226 55347
49008 69226
23895 69226
49639 69226
69226 23519
69226 31727
69226 46764
22853 69226
69226 55993
70731 69226
69226 30358
69226 82554
69226 95813
69226 55869
69226 4353...

output:

1
99900
1
99900
99900
99900
99900
99900
99900
99900
1
99900
99900
99900
99900
99900
99900
1
99900
1
99900
99900
99900
99900
99900
99900
99900
99900
99900
99900
1
99900
99900
99900
99900
99900
99900
99900
99900
99900
99900
99900
99900
1
99900
99900
99900
99900
1
99900
99900
99900
1
99900
1
99900
9990...

result:

ok 20000 numbers

Test #32:

score: 0
Accepted
time: 159ms
memory: 78212kb

input:

1
99932 100000
32541 37722
37722 31584
42545 37722
62545 37722
37722 76462
71552 37722
37722 80640
37722 74184
13447 37722
37722 27991
46783 37722
37722 74315
37722 93680
37722 49319
37722 98882
37722 83629
49682 37722
37722 98227
37722 92874
44042 37722
37722 71543
37722 92875
37722 89776
37722 976...

output:

99932
99932
99932
99932
1
99932
99932
99932
1
1
99932
99932
99932
99932
1
99932
99932
1
1
1
99932
99932
99932
1
99932
99932
99932
99932
99932
99932
1
99932
99932
99932
99932
99932
99932
99932
99932
99932
99932
99932
99932
99932
1
1
99932
99932
99932
99932
99932
99932
99932
99932
1
99932
99932
99932
...

result:

ok 20000 numbers

Test #33:

score: 0
Accepted
time: 152ms
memory: 77720kb

input:

1
99903 100000
95817 812
76446 95817
33660 95817
46562 95817
43004 95817
95817 41322
20495 95817
86089 95817
95817 31555
69782 95817
95817 7180
40718 95817
93760 95817
62781 95817
33757 95817
95817 29468
95817 74173
95817 8194
95817 65204
95817 1407
95817 88475
95817 4326
35721 95817
95817 9026
9581...

output:

99903
99903
99903
99903
99903
1
99903
1
1
99903
99903
1
99903
1
99903
99903
99903
1
99903
99903
99903
1
99903
99903
1
1
99903
1
99903
99903
1
99903
99903
99903
99903
1
99903
99903
99903
99903
99903
99903
99903
1
99903
99903
99903
99903
99903
99903
99903
99903
99903
99903
99903
99903
99903
99903
1
99...

result:

ok 20000 numbers

Test #34:

score: 0
Accepted
time: 150ms
memory: 76348kb

input:

1
99992 100000
35698 89398
69170 35698
8784 35698
35698 39721
67059 35698
9751 35698
35698 18575
35698 27167
25581 35698
37968 35698
82783 35698
35698 75326
35698 42231
35698 29225
18402 35698
35698 25820
35698 42988
35698 11790
35698 99019
4317 35698
35698 47955
35698 42282
41775 35698
39582 35698
...

output:

99992
99992
99992
99992
99992
99992
99992
99992
99992
99992
99992
99992
99992
1
99992
99992
1
1
1
99992
99992
99992
99992
99992
1
99992
99992
1
1
99992
99992
99992
99992
99992
99992
99992
99992
1
99992
99992
99992
99992
99992
99992
1
99992
99992
99992
99992
1
99992
99992
99992
99992
99992
99992
9999...

result:

ok 20000 numbers

Test #35:

score: 0
Accepted
time: 406ms
memory: 105984kb

input:

1
99937 99954
85695 11865
8 16626
13389 79773
35697 75213
78330 14953
75603 27974
89923 71675
14440 97575
56987 25380
56607 9660
95786 16079
17388 4506
16919 32519
13581 56042
23762 40273
47202 32893
42853 2563
59641 2081
38057 86529
17685 88941
39923 71679
51761 47845
30258 78690
77214 83674
9407 1...

output:

94193
99937
99937
99937
10539
99937
4269
87424
0
97925
0
0
0
0
99937
0
0
0
0
0
56354
10534
0
0
99937
8954
19262
24654
99937
32850
81900
0
99937
99937
0
59104
0
85892
32890
97099
99937
0
99937
23684
0
93353
49832
0
99937
99937
99937
29133
53655
0
4325
99937
0
0
47463
14535
98041
27821
0
18367
19009
3...

result:

ok 25206 numbers

Test #36:

score: 0
Accepted
time: 415ms
memory: 99332kb

input:

1
99985 99997
44865 64924
86277 50117
24615 9585
41632 33394
10038 77265
32925 91449
9076 34452
65556 49584
3142 39763
57830 61693
7207 73114
72504 49382
81327 550
68892 34279
58519 95945
27695 54890
10081 34328
17602 13804
75582 76478
34100 19050
55797 77192
19138 53197
63563 60028
83379 17222
5237...

output:

0
99985
93562
72395
68879
66596
99985
99985
24752
99985
0
99985
19002
65253
99985
414
81516
99985
0
0
99985
99985
99985
0
68337
32311
0
0
0
81687
99985
22395
99985
0
87476
91394
99985
79329
33915
41219
0
57669
0
3191
37645
0
99985
79204
61756
0
0
93052
0
0
52264
6662
0
0
51991
50521
97421
0
43321
0
...

result:

ok 24965 numbers

Test #37:

score: 0
Accepted
time: 440ms
memory: 96024kb

input:

1
99986 99988
39458 47775
94742 40322
15443 86072
29410 33628
468 83522
32524 92596
7235 95885
10329 51716
49503 10709
1164 95995
23883 46939
75061 40234
65729 41669
57774 49709
6862 19425
82390 61132
3322 44505
79681 73575
5157 81086
69238 21485
99675 86903
81269 73778
65990 96141
83360 88661
93692...

output:

0
95812
0
99986
10107
99986
2999
98391
99986
99986
88820
2530
0
98240
48398
15494
99986
84277
99986
86723
0
55256
36598
99986
96964
0
99986
79146
97246
74238
74587
99986
99986
32687
95715
30287
80219
87177
0
0
0
8917
0
72285
0
0
82332
68383
0
0
0
21966
61702
0
44413
58021
0
31798
75712
40676
46772
8...

result:

ok 24959 numbers

Test #38:

score: 0
Accepted
time: 427ms
memory: 90676kb

input:

1
99988 99911
95142 51231
42372 47952
20711 39750
44727 3450
93836 98473
5987 48516
1199 31150
70050 78203
28341 85487
48012 17751
78460 17573
35718 24342
82061 11107
46271 23104
2645 41614
80773 54762
82746 45013
78698 830
80944 55484
44901 25059
65763 27883
17613 29356
58549 12608
12993 42985
5973...

output:

0
0
0
0
0
0
89278
0
8411
30741
2067
22917
99988
99572
63351
52573
67519
80897
64429
0
99988
34649
0
64499
1637
13915
31343
90507
0
10079
73301
99988
0
62171
72391
80375
84931
1361
0
0
4603
57061
99962
6325
99988
0
70699
99988
99988
54201
0
44803
78927
99988
40729
32429
0
10967
0
67897
0
99988
0
4820...

result:

ok 49962 numbers

Test #39:

score: 0
Accepted
time: 420ms
memory: 99216kb

input:

1
99907 99919
19182 85345
65099 48194
45603 39108
78989 67420
74482 96319
83383 25913
54522 8843
33360 56889
83909 16064
38920 6688
35541 8846
37816 92094
11719 74655
61578 24868
80182 11860
23100 75297
14871 18596
45796 95402
38039 39359
97821 2010
81155 55257
12928 17498
45700 55173
5701 96728
437...

output:

99907
0
93242
67038
74870
72127
99907
99907
94770
99907
32395
99907
67392
99907
57610
40594
95402
99907
99907
99907
29999
67489
99907
12291
99907
99907
99907
8670
99907
98684
59105
44291
89329
82569
0
99907
99907
6585
59267
99907
17159
761
99907
0
28510
0
87682
0
30266
26050
0
0
49804
0
99907
0
9990...

result:

ok 49710 numbers

Test #40:

score: 0
Accepted
time: 411ms
memory: 99936kb

input:

1
99930 99947
35859 53923
56384 10513
64105 98556
62438 12208
47184 40837
71715 67187
66654 34928
49596 79747
80 68974
16597 60754
12711 14488
41788 8938
52953 82120
48823 47827
50161 66768
39694 17907
64284 19695
61746 79590
67646 94966
57641 48867
15295 21865
19271 99443
28828 96017
52431 57157
55...

output:

0
39692
68392
60355
53644
54453
10105
57618
78811
63773
83708
10518
99930
92720
0
78582
90260
99930
96123
52551
99930
0
0
25753
88797
0
0
93147
0
99930
0
91855
0
0
42139
68587
29421
65899
27735
0
111
99349
28161
86123
64699
95577
99930
99930
0
0
59904
0
60354
5066
99930
92244
662
26376
0
0
0
0
14466...

result:

ok 50067 numbers

Test #41:

score: 0
Accepted
time: 393ms
memory: 103712kb

input:

1
99957 99989
85555 18946
2076 47463
19997 84750
85407 73396
37128 73672
83071 66648
1478 26446
69914 54302
6657 43043
90864 83169
62821 55287
21956 43706
33491 86610
28901 34621
4472 45327
77374 12621
95970 97759
85446 44900
68840 14276
29242 26592
78787 29649
303 88895
37296 57755
54172 33876
1891...

output:

90662
72926
95457
83351
83683
47366
88023
74748
56142
71413
53861
65047
85749
51791
78239
58001
52958
76782
77828
53188
72630
87915
95750
79763
95960
46777
60986
52242
58674
94257
57303
56518
65936
79971
68323
52644
65283
96304
89938
76414
74661
84169
50026
85115
76534
74716
87683
87172
76930
50755
...

result:

ok 74753 numbers

Test #42:

score: 0
Accepted
time: 393ms
memory: 92532kb

input:

1
99924 99953
76768 89566
6460 51988
61139 11825
83267 26667
26728 18539
19841 12018
78522 22154
60148 76923
19375 66990
93702 20413
93263 84821
62857 43213
62495 51561
41459 43268
66178 49043
30080 38607
39303 10385
83410 56747
71002 99802
42975 66550
55342 81037
92908 83381
46934 64545
12168 4013
...

output:

0
0
0
0
0
99924
99924
99924
99924
99924
82154
46984
77847
43072
86136
50550
99924
76162
74281
56386
79104
91117
90589
71474
97067
52621
51891
78701
49719
19301
78300
33015
78639
33941
59749
62939
52800
43897
80943
57692
80702
81722
77455
74266
16633
46625
69258
76446
53513
56229
60614
53365
79438
57...

result:

ok 74994 numbers

Test #43:

score: 0
Accepted
time: 386ms
memory: 97260kb

input:

1
99957 99920
90182 89518
80266 62174
83854 94257
88017 6139
14092 10531
46537 33587
99037 31464
29834 54485
83562 97947
40238 30712
20827 31988
43878 61442
18120 52659
96806 92059
25494 37724
65936 72875
29439 69455
30534 33556
74323 53837
44063 17455
99398 25886
32978 2581
64959 22029
2086 95912
1...

output:

0
0
0
0
99957
99957
99957
99957
99957
99957
99957
99957
99957
57484
46653
71833
80764
82329
73275
38861
61214
42763
65413
69698
55614
73157
58849
78737
74525
52680
51273
70982
64283
78084
47069
31057
39199
49920
54186
58005
43714
52109
34312
26889
34801
35052
10874
30771
44053
50904
48463
48532
4784...

result:

ok 75022 numbers

Test #44:

score: 0
Accepted
time: 389ms
memory: 93360kb

input:

1
99925 100000
78069 44020
94057 50023
41017 95877
40699 131
84561 28009
2315 97859
54641 31874
88989 59886
6666 45875
34902 3123
3132 66094
81458 94112
29660 95435
33662 62887
67698 11277
3386 45610
15368 11628
94725 66125
87982 49681
84582 81086
90126 59648
93943 57894
95565 29806
55048 84791
8413...

output:

99925
55523
99925
63888
99925
99925
99925
99925
99925
99925
84433
85771
77553
78543
65713
99925
99925
99925
90039
99925
77155
99925
73673
90041
99925
99925
69880
99925
61334
95779
0
7638
27930
5362
0
19190
0
66982
2312
0
99925
0
0
35608
0
99925
85098
0
90488
0
99925
0
0
84992
79982
82306
0
84385
187...

result:

ok 20000 numbers

Test #45:

score: 0
Accepted
time: 375ms
memory: 89612kb

input:

1
99965 100000
52610 26721
8520 77456
7018 79564
59148 68133
55867 49145
32316 61884
5482 33485
476 79038
25623 29005
7182 47985
68333 4673
77233 94777
40389 84206
21930 89364
26227 31813
80157 44143
23329 5207
17706 25072
51307 77079
66548 9743
25587 73619
84378 53073
62585 44325
52780 88121
67536 ...

output:

95709
95987
99965
99965
30543
98011
54163
99367
69685
99965
99965
71039
99965
23315
11479
99965
99965
90215
99965
20827
99965
99965
21777
14213
18213
40487
99965
48517
87630
51360
99965
71628
99965
0
99965
35209
623
99965
0
19407
89595
0
9499
4821
0
92554
50327
54327
2951
0
0
0
7063
95967
69821
7133...

result:

ok 20000 numbers

Test #46:

score: 0
Accepted
time: 373ms
memory: 88012kb

input:

1
99925 100000
34949 92640
94431 84055
49885 51682
1389 60997
41293 9402
58797 56908
28003 6449
81540 12019
50537 68354
4536 60101
83291 60264
52340 78620
5874 53734
89930 7133
63510 59870
53936 65982
91190 58331
9827 30873
84446 88963
86962 54377
43297 27475
75405 20493
83477 15085
25136 94911
5044...

output:

42915
97635
99925
99925
91841
99925
97219
73141
92713
28823
52411
99925
99925
99925
99925
99925
99925
68067
99925
99925
99925
99925
99925
99925
52263
84310
31082
94464
70158
89495
82689
85759
97308
0
83236
62386
0
86482
0
0
75541
58669
99312
0
52977
0
26179
99925
93689
785
0
91252
45118
0
0
0
99925
...

result:

ok 20000 numbers

Test #47:

score: 0
Accepted
time: 406ms
memory: 103032kb

input:

1
99943 100000
66033 85424
74819 22068
33999 76425
78872 9342
18300 67117
68782 13833
7505 24040
64958 80785
17199 49603
91453 12425
16019 77470
42363 96379
51816 61056
3039 70367
31359 72280
45561 44318
80260 35282
41295 57569
29915 7910
20686 9352
68079 41512
78048 18563
32208 62248
40870 56744
79...

output:

99943
67279
99943
99943
99943
99943
99943
99943
99943
99943
90096
99943
55759
99943
99943
99943
99943
99943
99943
99943
99943
99943
93746
89328
99943
99943
91776
99943
99943
97937
78143
99943
91585
99943
99943
99943
99943
92503
99943
99943
99943
71709
99943
99943
99943
99943
99943
99943
99943
94245
...

result:

ok 20000 numbers

Test #48:

score: 0
Accepted
time: 414ms
memory: 97252kb

input:

1
99985 100000
45832 80526
72011 3909
3737 49966
86423 3416
44162 4277
86013 5931
24883 53901
34624 58459
97413 79117
70387 62339
30043 93795
17673 70529
32294 69785
44841 94400
84168 47660
62792 59950
48904 71568
22774 31457
11572 55241
88371 8744
688 77728
94844 85124
79474 22392
49250 31254
56531...

output:

99985
99985
78407
99985
99985
97962
99985
99985
99985
99985
77744
99985
99985
99985
99985
99985
99985
99985
99985
99985
99985
99985
99985
99985
99985
99985
93804
84619
99985
99985
99985
84610
99985
96782
99985
99985
99985
99985
86703
99985
92357
99985
99985
99985
99985
99985
99985
99985
99985
99985
...

result:

ok 20000 numbers

Test #49:

score: 0
Accepted
time: 405ms
memory: 102356kb

input:

1
99940 100000
42943 51711
73386 47926
96942 84555
22285 71865
81069 83180
70182 74500
92481 21367
68268 79957
91881 38216
93440 5786
40148 34098
29250 59305
34486 1940
16151 87467
26397 95999
98782 39709
46842 69889
33619 79265
41955 23912
62405 18748
28373 61963
15935 18282
67602 86604
15328 43829...

output:

62396
99940
99940
99940
83264
82841
35417
44466
58612
49346
83719
71202
97342
99940
57132
99940
99940
90210
99940
99940
55576
77409
99940
99940
99940
99940
93511
61416
99940
99940
99940
99940
99940
70348
99940
78509
92027
99940
99940
99940
55533
36139
54300
92145
65654
46007
99940
50258
99940
99940
...

result:

ok 20000 numbers

Test #50:

score: 0
Accepted
time: 433ms
memory: 84236kb

input:

1
99946 99931
97141 42540
75631 98783
25973 77710
81258 82322
1700 4637
77137 98847
53893 22263
16273 33338
70579 8469
79666 81680
48298 91089
22715 35298
79120 12988
51865 54364
7932 13157
3027 84278
41059 4191
41192 96323
88601 34311
99325 59293
2830 2840
65231 46415
18519 86288
57241 82126
24210 ...

output:

99946
99946
0
0
0
0
36687
0
78496
60040
99946
84420
0
78550
56420
36894
91388
99946
66418
96558
81151
99946
0
99946
18190
91045
11669
0
55749
98229
79941
0
0
99946
21829
66842
17452
3171
19043
0
0
2684
31103
0
92581
0
86836
0
0
42299
0
29039
32697
3827
87694
0
0
0
0
99946
43415
65119
70776
0
21382
0...

result:

ok 24945 numbers

Test #51:

score: 0
Accepted
time: 453ms
memory: 90680kb

input:

1
99974 99915
86401 32641
39079 45138
65048 21761
1442 22194
7708 18607
72998 44422
24462 2144
19169 43090
45697 26428
9511 61231
13618 10206
50587 22712
39660 22107
96098 67478
40764 43062
99059 31033
97379 14721
98162 57609
79198 59176
84504 27092
42311 48224
1750 98367
11544 70479
46141 59947
698...

output:

0
60658
96834
99974
99974
87450
99974
12470
99690
55822
71768
99974
72278
97559
99974
19288
99974
85054
99974
99974
93941
0
99974
99974
99974
0
99974
35549
0
99974
0
0
92057
62816
0
0
0
0
99974
95269
21167
45000
48262
34674
41161
0
3553
99974
82680
41778
0
2016
0
95205
0
81154
0
0
99974
99974
0
9220...

result:

ok 25261 numbers

Test #52:

score: 0
Accepted
time: 375ms
memory: 91356kb

input:

1
99919 99915
60688 20523
92472 60814
98953 20487
27920 30189
33470 41652
33208 30980
18143 82021
35934 24687
81896 26244
34010 79945
8184 31177
141 83007
34688 42272
71409 8006
23020 30067
730 32518
26982 59368
92802 30332
32334 58106
58908 97001
23151 96467
54388 96508
31899 12017
42813 85940
4320...

output:

91529
38750
99919
27583
98716
94253
81786
99919
43734
65664
99919
87856
39790
8708
0
99919
49743
0
77651
46899
99919
6924
99919
97926
79970
65372
0
93858
59058
0
0
98102
99919
0
28145
0
0
0
0
0
7843
0
88099
98705
0
70091
0
50785
8507
24126
36244
0
0
10837
0
0
27525
0
0
54774
0
93057
0
58387
19
0
493...

result:

ok 24871 numbers

Test #53:

score: 0
Accepted
time: 354ms
memory: 89708kb

input:

1
99940 99960
89151 48781
98467 26474
76964 79791
34704 28141
15982 77497
69177 92104
11494 26851
49755 66864
82076 97454
16148 22961
4860 56691
61636 63708
47716 38173
15351 63329
12131 22445
96096 69770
44750 21633
12245 1727
55030 59067
48614 42221
3598 4750
19117 61468
70034 34228
58159 6998
993...

output:

0
0
0
0
61349
23615
78014
94378
63301
91033
84526
59692
0
98925
94082
88430
99940
4841
46897
21102
79019
57486
68120
0
99940
80802
847
0
99940
99940
99940
99940
43476
19226
96776
99940
0
0
10629
36904
0
81142
83411
26916
8917
0
0
0
38884
98520
48359
99940
0
0
0
0
92640
93310
91343
52105
0
21903
0
95...

result:

ok 50130 numbers

Test #54:

score: 0
Accepted
time: 374ms
memory: 85912kb

input:

1
99969 99970
17950 76415
50427 43496
43317 72262
23937 84088
752 15556
61509 62912
96231 42099
77791 74568
37986 55597
81217 99452
37870 38807
62342 35522
73273 29033
11185 92900
1635 71318
19353 78393
3731 65483
24178 47559
94438 80186
4743 31290
99125 652
43667 18987
14704 39448
50339 22787
60564...

output:

99969
47877
94298
0
0
0
0
32404
75281
70006
99969
71957
99969
99969
99969
99969
99969
99969
81151
68740
90585
99969
99969
18070
99969
99969
99969
76701
38762
58787
99969
44308
0
24907
0
37866
76696
0
99969
0
3277
45227
15979
7278
51635
30683
0
0
97090
21650
0
0
0
99969
54806
0
54796
0
75753
43044
39...

result:

ok 50073 numbers

Test #55:

score: 0
Accepted
time: 354ms
memory: 85112kb

input:

1
99953 99907
60982 71702
4124 71651
88263 97967
50910 94421
93666 49333
35673 50021
38090 36278
475 39561
53267 71717
12829 17400
24513 59556
97225 41766
4780 25721
59074 32570
35264 35106
82287 86696
67965 55861
7703 26948
34264 88600
92977 85167
54185 75727
23495 91134
31690 63820
71797 67708
703...

output:

0
0
0
0
99953
0
0
0
0
0
85639
0
0
0
63249
78170
99953
99953
99953
99953
92837
93959
53501
51655
17082
79692
77653
93573
0
35381
0
0
82359
0
0
43959
72488
0
44110
0
59339
5170
0
22157
0
48919
0
99953
0
99953
76764
99953
42629
11589
88943
66852
28577
0
99953
0
99953
0
0
0
89311
71940
0
78541
0
78026
2...

result:

ok 49803 numbers

Test #56:

score: 0
Accepted
time: 402ms
memory: 93352kb

input:

1
99935 99930
15684 79503
57255 32214
44675 93105
62102 804
69533 18239
50408 73792
72100 17850
1598 32349
95166 23897
69987 12617
32414 8101
84546 44810
30557 1090
24870 45616
95373 62885
42599 91472
13038 90394
18438 66408
45924 26702
65072 62705
33438 36233
39038 20472
83957 69033
97169 18238
620...

output:

0
78086
72766
86799
67205
91290
33975
83678
79986
95059
86733
68326
30425
89780
37664
48422
82522
99530
78535
84085
44589
36664
72312
92536
96972
49154
89077
82001
85169
66862
93539
47564
90430
78077
64010
64063
34148
99935
99935
53391
40058
99935
34509
99839
79901
86094
47438
94933
81497
81102
8179...

result:

ok 25032 numbers

Test #57:

score: 0
Accepted
time: 346ms
memory: 87928kb

input:

1
99921 99985
48454 34305
61101 52854
32924 70276
28148 48822
7184 32907
8541 63696
34181 11772
24643 93562
40541 95070
3031 66609
26164 78378
31921 89915
18550 75078
92389 27271
48390 95021
14417 90336
34134 93371
47434 47994
40881 27335
35144 57134
71399 89532
95689 43369
79447 68074
23321 24857
6...

output:

0
0
0
0
0
0
0
0
0
0
0
65245
99921
97857
48200
55254
88609
49463
84735
74870
77757
78688
99921
87560
85035
54781
87130
71136
77397
65093
87054
86723
56180
48038
74079
89877
77138
45240
47672
87239
58632
76074
66398
49819
75550
52193
75619
89731
75110
80629
63461
80137
66529
54567
60458
77025
24752
23...

result:

ok 75073 numbers

Test #58:

score: 0
Accepted
time: 391ms
memory: 90700kb

input:

1
99999 99963
25102 87868
2190 7
51520 91877
68830 62613
4633 35617
95627 22377
32758 79750
72153 74793
12507 53067
27278 46225
98357 85257
71554 94523
15207 29378
71149 58733
28930 18654
38751 31858
70414 54108
90672 6874
62337 5614
99302 57718
3875 64718
93114 31542
93916 13935
87703 88990
49320 6...

output:

22805
59092
76858
49583
72236
61230
66168
59229
50416
80037
17415
71134
72774
75421
21975
65665
70577
58984
76989
71209
36490
65019
53110
70455
56454
67584
45105
66456
71771
39096
70274
70422
48867
63136
55452
67882
30626
37144
17471
64474
53648
32692
65889
38665
11057
48176
17894
57630
63230
58364
...

result:

ok 50266 numbers

Test #59:

score: 0
Accepted
time: 353ms
memory: 86264kb

input:

1
99996 100000
98748 30320
10809 34490
53045 345
85882 14273
13873 83767
47532 98808
39835 28612
75215 45430
18364 56166
53652 78376
14757 89404
17901 90603
69926 94649
23437 61167
78981 53157
76090 65457
17031 43005
86845 99648
34171 94164
51702 21444
57037 13912
82318 79368
64632 33494
37518 6934
...

output:

42929
99996
32611
99996
50414
99996
99996
99996
99996
39921
99996
22331
37692
31456
38875
99996
99996
31246
99996
99996
99996
26286
99996
62568
99996
99996
99996
99996
0
99996
74854
7402
47841
36679
0
0
0
99996
10265
83796
45321
0
55810
0
99996
28898
80537
0
697
0
5992
17901
0
49018
43611
75449
3470...

result:

ok 20000 numbers

Test #60:

score: 0
Accepted
time: 347ms
memory: 82028kb

input:

1
99914 100000
76471 60149
96287 93024
45507 82085
26949 4090
65043 39870
52581 93955
14032 24369
77335 68934
1066 41828
17788 28270
82039 5323
90158 98682
90170 44297
24452 18360
22999 5206
70563 46814
15585 22429
65565 2008
13926 33142
60392 59331
94063 41559
83412 60134
84900 46577
56613 41533
24...

output:

16264
99914
99914
99914
99914
29368
29921
99914
92934
99914
41306
99914
99914
99914
99914
75610
42964
99914
93048
44809
89676
99914
99914
86440
50756
66612
99914
85743
79670
86374
97735
0
1681
43359
57639
33698
99914
0
75668
0
17019
24695
0
91037
99914
45455
30635
53548
0
0
99914
79775
0
0
0
21717
9...

result:

ok 20000 numbers

Test #61:

score: 0
Accepted
time: 359ms
memory: 85164kb

input:

1
99949 100000
77482 64131
62982 38218
37979 45607
69774 59707
89353 85138
4980 19775
22220 3846
45724 44468
10148 15369
20407 94919
88410 38673
47041 85523
64733 66341
99525 82695
99341 99634
52058 48305
66523 95735
15784 76385
94347 86825
63148 9901
57176 84127
93870 98428
17411 60611
89079 90367
...

output:

90288
79138
99949
98367
99949
30362
99949
99949
66260
99949
42563
21482
99949
68167
99949
42910
50722
90199
70856
99949
32655
99949
99949
46129
68293
99949
25344
90642
53590
99949
35912
4320
0
80265
0
11475
88833
97770
99765
74274
0
99949
48325
6839
56869
43515
1675
0
0
83661
0
0
0
0
0
91746
14143
9...

result:

ok 20000 numbers

Test #62:

score: 0
Accepted
time: 409ms
memory: 87408kb

input:

1
99913 100000
76535 84050
39264 25666
54616 31257
95012 73265
77598 27606
83983 79919
46757 20691
22184 5753
77225 23892
39986 13488
97657 91243
253 50994
57189 22868
80079 29255
30577 25952
40401 12016
28242 12438
20201 79013
35104 41226
6121 73970
98184 21272
13304 38253
85609 43617
66059 63373
3...

output:

99913
99913
99913
99913
99913
99913
99913
99913
99913
99913
78692
99913
99913
99913
99913
99913
99913
99913
99913
99913
99913
98155
99913
99913
99913
99913
99913
99913
99913
99913
99913
99913
99913
99913
99913
99913
99913
99913
99913
99913
99913
99913
99913
99913
99913
99913
99621
99913
99913
99913
...

result:

ok 20000 numbers

Test #63:

score: 0
Accepted
time: 377ms
memory: 87092kb

input:

1
99939 100000
57662 12607
41812 79289
67233 2519
35661 39171
98236 52731
11251 48319
67317 78047
54999 16897
64905 4343
74303 90895
21519 71146
28558 97203
47899 64309
38429 28767
70857 11796
50644 72500
33342 71407
1568 2708
55207 70587
97362 15622
47569 67553
3517 59827
62223 3672
70090 34046
524...

output:

95443
54089
18158
93663
40518
92642
62089
17625
99939
59108
57552
86246
91960
18150
85629
99033
39387
64063
65331
35209
72575
84303
42588
40048
72559
68793
98010
65185
66018
75244
87863
23795
42313
13920
91257
36191
92076
67346
39284
40636
99688
80575
96708
78899
9533
99939
68312
30507
15038
99939
9...

result:

ok 20000 numbers

Test #64:

score: 0
Accepted
time: 356ms
memory: 87520kb

input:

1
99938 100000
73002 81831
64294 96041
67378 92609
80567 68473
70801 77467
54913 22916
39464 14631
1312 30590
69144 18066
48107 26329
56830 77152
38235 30172
51065 85637
20008 50646
49585 97487
51653 70584
39714 77147
6328 87033
68962 34408
75319 60241
11294 46397
38538 37959
36023 37883
76123 65344...

output:

99938
81226
99938
99938
95346
65074
99938
99938
60224
99938
99938
99938
99938
61629
99938
89616
99938
99938
64078
99938
99938
99938
90970
99938
99938
93496
99938
82422
96438
99938
99938
54831
92661
78177
99938
99938
99938
68959
99938
90879
99938
52420
99938
93911
99938
99938
69106
99938
99938
99938
...

result:

ok 20000 numbers

Test #65:

score: 0
Accepted
time: 330ms
memory: 75584kb

input:

1
99980 99934
7812 21679
76924 40280
23501 87743
83271 38480
31616 45755
1832 85903
19886 96457
2314 87620
39901 96681
5485 99053
17909 28667
66491 43617
28957 9042
3931 72871
31503 83130
97173 91262
2679 75966
77164 38842
40582 69302
8406 86989
66670 77879
20463 76810
99818 84698
64168 68098
55669 ...

output:

99980
82504
99980
93837
99976
96483
99756
99980
1
99980
0
99980
394
22017
6983
99980
99980
3205
99980
99628
2804
330
97760
99961
99980
91161
99980
99974
0
99980
99980
99788
99980
98770
97156
63746
0
99630
2804
99980
86339
90659
41216
29790
99976
24
7986
3726
3726
3726
99980
97673
99980
97673
99980
9...

result:

ok 24947 numbers

Test #66:

score: 0
Accepted
time: 306ms
memory: 77148kb

input:

1
99906 99905
73803 21423
96540 29367
46644 90360
96055 57286
49530 98398
24822 71772
9252 10930
73097 46933
64973 38895
56483 98946
66223 29918
97886 72784
7579 48543
98693 52886
99546 15032
24157 27855
85733 22958
3721 25884
9739 10626
90520 50692
32237 1958
96289 21885
32599 55025
54555 24799
825...

output:

96668
442
99906
99756
0
99906
99906
99906
14
99906
99906
41828
99906
99906
82854
74069
0
40519
99564
40519
99906
99906
2373
99906
46953
99906
79024
99906
99906
99756
22561
6854
99067
99906
3121
99906
99906
99898
99906
99906
0
99529
99906
99906
99906
97714
99906
0
763
99529
99898
99906
90830
99906
99...

result:

ok 25069 numbers

Test #67:

score: 0
Accepted
time: 308ms
memory: 76660kb

input:

1
99907 99937
40891 98542
28331 68273
61586 82604
39824 57285
91562 6802
98091 19779
18960 67815
70592 70521
85936 49110
20161 89944
46454 89504
71314 28718
67606 43452
47196 6517
22426 69645
45800 54418
61977 38225
71348 77599
28705 16705
54931 46601
54097 39038
90437 56032
54002 70617
75808 2768
8...

output:

1199
99257
99257
99907
99858
99907
62900
1
4117
17
99907
99907
99907
99907
0
1
99907
17195
87059
99907
5369
99905
99907
2
99907
3478
3478
99907
0
98490
99294
99907
61961
99907
99907
99907
3478
99907
99907
99907
99826
61961
3478
7515
23816
35744
1
23816
99907
99907
7515
99907
99907
82850
48986
99907
...

result:

ok 25058 numbers

Test #68:

score: 0
Accepted
time: 287ms
memory: 74944kb

input:

1
99900 99996
69024 63098
8845 71295
32287 45340
80234 38802
11694 59323
4716 18777
30019 71611
5002 41042
41410 41787
51786 76520
25481 11234
96497 96411
6304 56440
54070 99823
68307 91457
29846 12605
83913 91081
90962 54388
40811 57605
5326 7374
92293 81225
17803 67865
86305 66401
17238 87117
6897...

output:

91654
3714
12
96334
15911
99900
99900
72160
99879
99879
97946
14055
99900
99900
99900
99900
99900
99900
3478
99892
99713
99900
99900
97946
99900
0
14055
99900
99900
93221
60780
99900
99900
99879
99900
97946
99900
23367
0
99900
98964
99900
99900
99900
99900
99900
99900
99900
23367
15
99879
99900
9989...

result:

ok 49933 numbers

Test #69:

score: 0
Accepted
time: 292ms
memory: 75308kb

input:

1
99951 99981
92528 28645
72117 63122
96292 10857
46757 19108
56682 83841
70771 60505
4080 97079
73445 91679
31622 72132
3302 52742
444 15522
23901 14304
10166 86461
27998 63074
63503 44999
48959 27733
165 56040
75511 79955
6181 58838
76586 6029
44801 41706
99591 37343
92324 88049
60339 62407
79785 ...

output:

15093
0
86517
97000
0
99951
99951
99951
1617
2
99951
99902
99951
99951
99951
48963
48963
6447
99929
0
26922
99951
99951
95457
1950
99951
99951
99951
99951
12803
99951
99951
12803
824
99951
99951
277
99942
95457
77652
67
99951
99951
3998
99951
99951
30819
95457
277
14
99951
67
12803
99951
824
99951
9...

result:

ok 50015 numbers

Test #70:

score: 0
Accepted
time: 270ms
memory: 73592kb

input:

1
99986 99906
69623 960
89025 41252
95178 78139
75722 25686
68994 73086
44628 23928
99779 47002
35903 41836
88554 36298
44358 19296
73326 24467
33987 13904
64999 22346
26903 51953
2038 92704
92087 65496
29349 92016
91267 14296
68869 79181
92408 12716
22625 39735
39414 26384
18457 50215
76992 52934
2...

output:

3136
0
0
19
97904
8462
26097
99986
99986
89339
98
99942
99986
99942
99986
89339
99986
99986
99983
98848
99964
99986
3892
99986
99986
14
26097
99986
99986
26097
99986
99986
99986
15861
34791
91313
99695
99986
99986
1
90
99964
90
99986
99986
99986
96801
99815
38550
99377
99942
437
99986
99986
74638
99...

result:

ok 50364 numbers

Test #71:

score: 0
Accepted
time: 240ms
memory: 86016kb

input:

1
99918 99971
27916 24724
13784 86221
81886 82132
33990 75043
62948 87891
47745 82410
94904 42263
48006 20612
80532 70650
47207 39016
84359 20188
71150 46059
47355 49683
68661 81267
56704 52114
1944 88317
62163 46223
67558 88937
4354 66205
37528 63703
77767 54367
12150 62853
31732 7503
44538 39847
7...

output:

0
0
0
99092
99842
3707
96720
1419
99092
43139
66149
99916
99916
84141
90164
99916
94
99890
99842
99745
16
99524
7702
94
94161
99842
7702
99916
99918
96720
99918
99092
98240
54856
99890
21691
94161
94
90164
99890
43139
99092
99092
98240
99918
66149
31766
99842
7702
66149
96720
84141
99890
99842
99911...

result:

ok 49921 numbers

Test #72:

score: 0
Accepted
time: 236ms
memory: 87032kb

input:

1
99993 99927
57245 80516
3911 52879
27445 42057
73734 88686
18032 6449
79428 8051
33518 87179
17066 66271
22808 29166
46813 99067
81134 86319
3313 10960
93555 37431
11087 61326
67676 26339
42180 18700
70729 13268
19710 57541
95472 83831
14161 3257
35050 59874
86783 93948
68161 94142
91999 36962
164...

output:

0
62741
17084
89993
98747
37572
37572
17
249
99927
83
99988
17084
83135
97233
26140
62741
99468
674
10466
73934
50242
62741
82
3197
82
14
50242
98747
62741
99798
82
37572
94497
10466
89993
99927
6029
98747
94497
82
97233
14
98747
1572
83135
89993
249
1572
99798
37572
82
6029
10466
99798
99468
249
67...

result:

ok 75165 numbers

Test #73:

score: 0
Accepted
time: 246ms
memory: 87128kb

input:

1
99967 99998
7327 80142
52780 8520
4876 62341
4826 60052
11209 52636
68247 96933
6527 21956
50313 66975
21108 75116
6172 55964
97236 48230
76897 21168
27265 58847
77217 36030
29003 30178
25098 60082
74295 52919
22045 45440
73743 6337
29869 81173
63455 19226
51043 9025
53002 77780
29223 44424
49408 ...

output:

99956
34877
12540
2403
97054
98374
2403
22365
98374
99967
94580
12540
99966
191
99133
99133
99572
22365
98374
99966
74503
22365
97054
48901
12540
99967
62597
22365
99918
99813
12540
99918
94580
99133
98374
6008
99813
12540
782
34877
6008
98374
191
99918
62597
99956
62597
99967
99813
6008
99967
191
2...

result:

ok 25270 numbers

Test #74:

score: 0
Accepted
time: 244ms
memory: 71916kb

input:

1
99948 100000
47972 71882
8382 33636
95686 34813
8970 5870
20239 37626
42151 3170
22500 57843
58288 15683
15857 77995
10259 61561
56870 41383
83950 26984
3247 38818
33405 53196
3260 11421
8165 34981
19593 98466
99440 49423
3769 89706
17635 59770
45314 74484
87251 78466
68577 39768
61753 22630
73819...

output:

99822
5120
137
99948
99948
99948
99948
99948
99948
99948
99901
1913
1913
99948
99948
98313
93869
99948
99948
82256
99948
99948
72536
99948
99948
99948
99948
94733
99902
11
99948
84105
0
99497
99941
99945
99948
0
28489
99948
1
99318
99948
11
50379
99948
90493
86
0
99948
3643
99948
99948
99948
99948
2...

result:

ok 20000 numbers

Test #75:

score: 0
Accepted
time: 266ms
memory: 70720kb

input:

1
99965 100000
95737 35587
31918 39826
31350 84214
54686 58212
84829 5273
88256 83766
55032 85833
44933 85016
51412 68464
38678 84567
51432 56249
76627 29443
84594 5768
45324 63097
4760 58913
97424 90494
1537 32544
78090 24668
29184 70661
97947 66642
51719 73605
42358 37746
9386 69215
53582 38542
66...

output:

99965
99965
25
99955
99965
30722
99965
99679
99965
99965
99965
1741
99965
99965
91084
20946
76569
99965
76569
30722
99965
42211
99965
99965
99965
99926
99926
9728
99965
2
99965
99965
99965
99965
99965
99965
49992
0
99965
99965
99255
4594
99965
99965
0
99938
99965
90130
99965
99965
4594
99965
2
0
0
9...

result:

ok 20000 numbers

Test #76:

score: 0
Accepted
time: 254ms
memory: 70916kb

input:

1
99973 100000
47568 28253
41794 89230
79805 80837
2796 15437
35850 19730
69588 86565
15641 43903
73517 29961
32947 78946
83176 5350
62984 87677
37061 21179
87183 44650
19397 6553
74494 79564
35905 54034
51724 78591
9660 6165
8219 57508
49306 99654
54812 20434
56333 37712
85078 6113
47667 94628
1401...

output:

5453
10782
99973
99973
19206
99973
99973
99973
98793
43293
99973
99973
99973
30296
99973
99973
99973
30296
99973
99973
99973
99973
99973
99973
95529
99973
98240
391
0
99973
99973
99973
99973
99973
99973
4555
86863
4555
99973
99973
99678
99973
99973
2
93266
25912
17983
844
99969
284
99973
99973
75823...

result:

ok 20000 numbers

Test #77:

score: 0
Accepted
time: 270ms
memory: 74160kb

input:

1
99936 100000
62568 5004
10929 29997
69725 89696
1324 56710
46899 56465
20391 54925
61365 54306
6849 32980
7030 5673
77273 34365
12985 73735
52878 39734
29460 32319
23763 58615
81551 43155
81310 66619
32731 60240
62369 36874
21069 87495
90091 32666
24522 24866
3113 12501
3132 15423
47125 11642
2066...

output:

28075
99936
99936
99936
99936
99936
99936
99109
2048
99936
95991
99936
99936
99936
17451
54287
99936
99936
28075
99936
99936
99936
99936
99109
99936
99936
99586
99898
4808
99936
99936
99936
99936
17451
99935
99936
99936
99936
99936
99936
54287
99936
98034
99936
78214
99792
99898
99936
40757
99936
40...

result:

ok 20000 numbers

Test #78:

score: 0
Accepted
time: 278ms
memory: 74364kb

input:

1
99926 100000
41014 2171
20637 19369
82676 1096
22147 75562
77458 91705
61260 94663
90261 77019
34915 55935
9685 71280
44737 3673
2823 12225
32327 14548
36864 97452
73965 37939
13605 42947
55062 56345
2108 39885
21935 9296
36971 30324
52571 99365
7271 9046
75792 3196
79462 28788
29947 80807
94086 7...

output:

99926
99583
62415
99926
99917
99926
99926
99926
1377
99917
99926
99926
99926
93634
99926
82623
82623
99926
99926
450
73556
99926
24128
99926
99926
99926
99926
99926
3531
3531
99926
99926
99926
24128
450
99926
98241
49466
99926
96557
99926
14594
3531
99926
99926
99926
99926
14594
99926
99926
7740
999...

result:

ok 20000 numbers

Test #79:

score: 0
Accepted
time: 273ms
memory: 73356kb

input:

1
99983 100000
93996 33764
31353 44983
39499 61887
68919 15903
94453 71696
35183 39762
65299 91506
44214 36393
77268 40927
58797 74724
81182 92635
82934 64929
52049 61251
33485 89498
21574 24470
89096 54185
12480 69010
57103 80062
43768 12659
19417 35265
39392 20081
6679 21257
58838 93184
89469 4129...

output:

2090
99983
99983
99983
96243
99983
99977
99959
99983
99983
99983
73813
99973
17503
99983
99930
99930
5034
99983
17503
99983
99983
99977
99977
5034
17503
99983
99983
99983
96243
703
51096
63164
5034
99983
2090
10168
99983
97950
171
99973
99983
99983
99983
99529
99983
99983
99973
99983
5034
99983
7381...

result:

ok 20000 numbers

Test #80:

score: 0
Accepted
time: 164ms
memory: 79896kb

input:

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

output:

19629
27086
33069
37876
41825
44947
47574
49718
51430
52786
53896
54758
55449
56012
56509
56917
57242
57529
57756
57938
58081
58218
58327
58410
58479
58537
58586
58633
58668
58694
58722
58745
58763
58777
58786
58799
58816
58827
58841
58852
58866
58883
58896
58905
58913
58925
58937
58947
58962
58974
...

result:

ok 99999 numbers

Test #81:

score: 0
Accepted
time: 402ms
memory: 80096kb

input:

1
99929 99981
45693 75306
15264 58139
2066 26616
11022 77658
85716 83027
56528 87849
69207 69736
52640 33915
98016 59925
35331 35749
75397 30716
35650 51942
8005 21663
25542 78031
98332 31412
95215 94604
97063 90007
23678 52354
27713 3796
62140 17741
75550 58734
71129 43225
19897 92364
16964 77315
8...

output:

0
99929
99929
50671
99929
77852
31429
97395
50551
99929
88121
84345
22264
0
99929
6011
9230
61363
0
60723
0
99929
8137
99929
0
19341
0
75130
9204
0
0
7636
54658
0
10286
6356
88383
0
64310
99929
0
35785
78315
0
46004
0
71313
49034
96454
83951
0
0
56121
3159
0
19472
78992
64002
52778
0
23504
83220
590...

result:

ok 25085 numbers

Test #82:

score: 0
Accepted
time: 419ms
memory: 81680kb

input:

1
99902 99940
1455 3719
74050 72061
31546 19123
63299 89417
81171 38322
82793 1396
21885 17806
40384 62665
95639 51591
45701 99137
87038 2866
92210 38250
34726 91990
78394 6914
33060 81695
49164 42723
32878 76402
16293 44487
56568 66652
65195 33721
60196 15489
90393 62476
44255 23284
55612 5028
1567...

output:

99902
77166
99902
74076
99902
99902
0
22157
49714
0
99902
99902
26708
5239
99902
14603
22886
99902
99902
97851
75931
88817
0
0
99902
99902
42045
99719
25140
0
85199
61681
15525
0
22282
14512
0
99902
83763
98258
63090
0
19792
0
0
89158
73848
99849
10889
0
56675
75802
17305
0
0
0
0
99902
0
73848
82777...

result:

ok 24956 numbers

Test #83:

score: 0
Accepted
time: 415ms
memory: 83424kb

input:

1
99900 99962
42140 4762
62859 70400
85946 62594
68104 30645
38243 72146
1805 61718
15188 37299
55798 68697
23886 159
18051 4055
41676 33961
87503 97207
81554 98809
21675 20232
9317 91782
39468 45993
70932 21157
65714 26654
6507 5993
59878 36893
97376 23164
59265 20396
69643 15613
90100 27429
71190 ...

output:

67118
99900
30090
77758
99900
53354
0
99900
74354
79460
0
60743
0
0
0
77181
63114
0
0
0
34426
66032
0
22381
0
0
0
48287
0
29991
8389
0
0
35701
58290
0
96116
59741
0
23007
50750
0
55274
0
5045
0
0
0
0
0
0
0
0
43054
95684
8298
25134
80194
0
28582
55419
76750
0
0
58989
39601
93448
0
28932
99900
74027
5...

result:

ok 24990 numbers

Test #84:

score: 0
Accepted
time: 357ms
memory: 78396kb

input:

1
99993 99902
33201 66490
49662 14600
20696 49236
36899 24652
56048 26753
32486 96887
69377 83665
63540 80129
85358 55473
78589 38310
67599 87648
51743 99261
99966 73817
24633 27238
74031 72932
84902 52403
31718 59155
81120 92875
5494 57489
62764 63718
99891 71252
10074 57761
29103 20130
79695 93332...

output:

99993
99993
99993
89929
72121
40920
19828
99993
42112
86944
0
97884
0
4635
0
31484
50101
0
1856
70058
92735
78716
86195
0
60144
0
0
0
0
29887
90654
33464
0
0
0
95801
99165
77016
97430
0
99701
0
0
0
98958
66299
0
0
0
22705
45560
25369
41441
83860
89396
0
0
26453
14190
76368
52991
99153
99879
0
45412
...

result:

ok 50189 numbers

Test #85:

score: 0
Accepted
time: 369ms
memory: 78264kb

input:

1
99942 99987
92501 90303
93175 79330
14359 1159
95438 1803
50224 7001
32789 34371
17934 53569
59210 54981
90658 3980
759 27076
2315 46289
29826 8983
52618 26783
85981 62257
97656 60851
56668 88293
95057 4311
76621 30363
36153 58326
26870 37641
24431 22338
12203 40180
67742 27221
15014 9022
16766 83...

output:

0
0
0
89013
99942
99942
84044
99942
90913
99942
99942
78986
95892
26218
99942
99942
0
99942
99942
0
10127
0
99942
0
84736
73130
72168
21972
31463
91113
66517
0
0
99942
0
87492
95206
40288
4203
22758
0
13374
0
71846
97003
67587
99942
75783
1123
32334
16087
99942
0
99942
64132
99942
99942
99942
0
2228...

result:

ok 49730 numbers

Test #86:

score: 0
Accepted
time: 363ms
memory: 78080kb

input:

1
99997 99976
58224 83265
17145 57432
89415 11413
91317 53113
69110 73133
13448 83977
28632 76348
10591 85710
99552 22163
20731 34998
46354 62289
15916 96554
42983 12292
74270 8916
84577 47736
29292 94612
76618 87876
80500 19847
30786 4533
76391 42674
40240 22856
16739 11399
41676 94993
71892 10526
...

output:

0
80500
55795
99997
96711
40691
26719
99997
0
85260
0
62327
0
76506
0
0
0
3054
0
95845
99997
76519
0
0
52202
63766
0
0
24218
71242
0
26226
99997
0
20315
27181
87223
0
71578
37358
53586
47223
0
0
87800
55474
63348
0
0
93601
44068
0
66743
0
95601
76770
0
0
35937
59159
15171
24793
76627
11532
0
48609
9...

result:

ok 49911 numbers

Test #87:

score: 0
Accepted
time: 337ms
memory: 87936kb

input:

1
99970 99974
64739 68930
30109 11200
1806 89268
23287 6922
57858 16839
61719 66468
56000 56944
2081 90436
1988 40863
38489 12619
85667 4796
1788 60877
41290 56001
34335 5151
4116 9796
5075 46725
75482 39125
62823 63100
7370 97554
10500 86442
96611 67688
56317 45453
37570 121
78358 25475
86431 687
8...

output:

99970
91031
68494
54499
99475
79967
61378
55874
99970
99970
75530
57225
99970
51777
99970
99970
68366
98625
82857
99035
64188
43586
56165
77830
99970
99970
44512
68308
83970
99970
84131
56024
99970
96752
69407
59490
43611
99970
99970
99970
62287
91387
67555
54265
48501
99970
99970
99970
99970
99970
...

result:

ok 50116 numbers

Test #88:

score: 0
Accepted
time: 453ms
memory: 89464kb

input:

1
99962 99979
41985 6339
45172 90151
39247 78090
57677 369
25604 54197
98129 75635
66708 54105
96096 65278
89766 93809
91111 1157
23712 28832
18413 97407
58613 28700
85802 7530
17734 58669
78795 56155
20279 98304
83014 27674
60897 96928
82717 76676
5606 45116
10104 15822
46670 89672
44233 37790
1056...

output:

99962
99962
75470
99962
99962
99962
99962
99962
97019
99962
99962
82904
85999
99962
79730
99962
99962
99962
99962
84035
99962
99962
80301
99962
89957
94802
99962
86398
75714
99962
99962
99962
99962
81584
99962
99962
84475
99962
99962
94872
99962
99962
99962
89891
99962
99962
97866
99962
94244
81123
...

result:

ok 25114 numbers

Test #89:

score: 0
Accepted
time: 372ms
memory: 87420kb

input:

1
99958 99937
3050 80207
69163 19113
33512 5058
94995 49956
40806 35808
25586 65915
35814 27773
20760 85409
52683 10567
84571 8982
96768 717
94297 49780
73465 70305
75839 42935
86304 65805
71504 38070
93763 18901
45173 36836
31008 60511
72645 76293
8832 23745
31665 677
62238 45090
87576 53148
57817 ...

output:

40314
77100
40386
41745
42011
57265
51025
99462
44587
99958
64375
48984
99958
99958
91414
36680
39720
42011
41070
79087
99958
99958
99958
71133
79552
70096
39989
99958
99958
56395
99958
99958
99958
99958
40877
99958
78804
68028
50553
76412
99958
72833
99958
87729
99958
99958
95987
99958
64695
69972
...

result:

ok 25016 numbers

Test #90:

score: 0
Accepted
time: 346ms
memory: 76132kb

input:

1
99970 100000
87038 71905
10231 26429
2880 58617
85229 38660
12172 12020
6141 28069
27549 1839
47260 25825
96921 2520
71729 23138
6160 66046
3673 96155
21438 94750
76267 92502
79338 69414
85886 65390
11045 51042
77172 10613
17933 87141
46412 75261
15823 78414
48616 76730
79250 20472
39456 78727
150...

output:

99970
99970
99970
53400
99970
99970
99970
99970
99970
99970
99970
99970
97045
99970
99970
99970
99970
52872
99970
75872
99970
99970
89001
99970
85065
53381
87900
85561
99970
99970
28081
96920
73780
82831
0
0
28248
49022
30573
0
32904
52573
72891
0
91985
77542
99268
18017
9435
92141
47462
94330
99970...

result:

ok 20000 numbers

Test #91:

score: 0
Accepted
time: 342ms
memory: 74600kb

input:

1
99911 100000
21099 20823
75745 79241
82162 98975
85675 91891
62746 77611
61770 32867
19593 69075
9658 90015
46606 30242
54209 15276
94773 46874
92585 61076
87554 93031
28697 43849
21655 37691
31196 51918
95616 17460
66643 74184
70555 30512
71419 21020
23006 92144
35624 75994
64571 39406
27394 7625...

output:

38686
99911
33004
99911
99911
96856
99911
57045
99911
99911
16321
99911
99911
99911
73926
48705
99911
99911
35511
54457
99911
99911
99911
47663
99911
85858
0
78507
0
99911
724
4117
99911
0
0
0
86823
1116
0
0
0
29093
0
0
99911
18873
67985
6974
36491
40477
0
0
91904
19816
86576
31170
9842
0
52327
9274...

result:

ok 20000 numbers

Test #92:

score: 0
Accepted
time: 355ms
memory: 76012kb

input:

1
99905 100000
34865 21264
57932 17226
32827 31808
87300 76245
32460 58197
41602 74154
73720 69030
27580 48678
18351 7410
10013 70694
38737 81853
15240 23961
74525 88143
67843 3745
64381 60055
17050 8202
75547 77797
29751 87860
25918 62448
10740 68960
1250 54705
16159 30057
76874 96118
35062 75305
6...

output:

99905
99905
99905
99905
99905
99905
99905
99905
99905
97678
92117
99905
99905
99905
99905
99905
94285
99905
99905
91287
97426
99905
97485
99905
99905
87778
45848
99905
0
42306
10631
99905
89317
0
73078
45989
84590
76587
87692
77056
0
0
0
10454
0
0
0
72359
0
0
0
0
26984
0
6914
0
0
0
13358
26586
0
0
6...

result:

ok 20000 numbers

Test #93:

score: 0
Accepted
time: 335ms
memory: 76360kb

input:

1
99992 100000
77898 87357
26053 78366
83841 55152
49493 61139
49771 86451
70461 91060
55975 87969
8593 44855
90087 2415
91592 76864
25668 5613
22458 54044
73197 31383
28124 21958
79921 7968
92288 59368
67810 81008
48892 4110
55172 64534
68587 70006
26737 41080
86917 75699
67945 872
62026 62532
3208...

output:

99992
45045
99992
99992
68307
62053
99992
99992
99992
91004
99992
99992
93347
99992
94792
92409
99992
99992
99992
87296
84041
73017
99992
8720
99992
99992
39911
99992
99992
99992
13500
99992
10011
99992
99992
99992
99992
61852
99992
12221
30460
99992
12279
79040
76705
32846
12356
26815
99992
98912
9...

result:

ok 20000 numbers

Test #94:

score: 0
Accepted
time: 355ms
memory: 78452kb

input:

1
99972 100000
86758 63594
69470 80846
43924 90616
42946 95474
36135 34492
67988 27220
13114 76230
28019 22417
77637 68375
49545 46235
11678 9237
54120 46337
92570 72347
7569 95210
73459 65254
67643 12866
72248 61929
33977 72214
38527 55706
14559 26544
9422 81066
32880 64988
99702 50969
77434 38027
...

output:

99972
99972
61878
99972
87062
59466
99972
99972
97597
93038
50456
99972
99972
86015
99972
99972
99972
99972
68277
30608
99972
99972
99972
99972
99972
47358
94859
90166
99972
99972
99972
99972
99972
99972
77212
99972
99972
99972
99972
41028
99972
99972
51206
37823
99972
99972
99972
99972
99972
58988
...

result:

ok 20000 numbers

Test #95:

score: 0
Accepted
time: 365ms
memory: 77720kb

input:

1
99992 100000
67599 44979
6751 82873
38692 96021
22936 77953
87962 87813
81813 55988
67511 25440
44298 78182
75308 11577
28658 654
9568 16853
60481 20469
6186 11480
36364 83651
39377 36992
46732 82202
80957 87952
34732 17698
14687 32065
64701 89785
38656 95284
65711 91744
33594 81776
29114 78163
78...

output:

99992
87639
99992
99749
76990
99992
67361
99992
79555
99802
82738
99992
63317
99992
56757
99992
45025
99992
83867
99992
55750
98283
99992
94142
99992
99992
99992
99992
62482
99992
75804
55857
99992
99992
54676
57560
87295
72053
99992
79163
74611
38908
99992
99992
85858
89899
64123
90075
99992
99992
...

result:

ok 20000 numbers

Test #96:

score: 0
Accepted
time: 158ms
memory: 102096kb

input:

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

output:

100000
100000
100000
100000
100000
57343
13311
115
215
4351
100000
100000
100000
100000
61
2431
100000
100000
36863
7679
100000
13311
215
100000
215
81919
4351
100000
100000
57343
57343
100000
100000
100000
81919
100000
115
100000
13311
399
100000
100000
100000
4351
7679
100000
1343
61
100000
100000...

result:

ok 99999 numbers

Test #97:

score: 0
Accepted
time: 159ms
memory: 102072kb

input:

1
100000 100000
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:

58500
58502
58504
58506
58508
58510
58512
58514
58516
58518
58520
58522
58524
58526
58528
58530
58532
58534
58536
58538
58540
58542
58544
58546
58548
58550
58552
58554
58556
58558
58560
58562
58564
58566
58568
58570
58572
58574
58576
58578
58580
58582
58584
58586
58588
58590
58592
58594
58596
58598
...

result:

ok 99999 numbers

Test #98:

score: 0
Accepted
time: 58ms
memory: 74380kb

input:

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

output:

100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000...

result:

ok 99999 numbers