QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#765018#9607. 熟练WrongAnswer_90100 ✓568ms333968kbC++237.4kb2024-11-20 11:38:382024-11-20 11:38:41

Judging History

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

  • [2024-11-20 11:38:41]
  • 评测
  • 测评结果:100
  • 用时:568ms
  • 内存:333968kb
  • [2024-11-20 11:38:38]
  • 提交

answer

#include<bits/stdc++.h>
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define ll long long
#define lll __int128
#define fi first
#define se second
#define e emplace
#define eb emplace_back
#define db double
#define ef emplace_front
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vp vector<pii>
#define vt vector<tup>
#define all(x) x.begin(),x.end()
#define mp make_pair

#define FastI
#define FastO
//#define int ll
bool ST;
static const ll MOD=1e9+7,Phi=998244352,inv2=499122177,Root=3,iRoot=332748118;
static const ll inf=1073741823,Inf=4294967296,INF=4557430888798830399;
static const ld eps=1e-9,pi=3.1415926535;
char in[1<<20],*p1=in,*p2=in;
char out[1<<20],*p3=out;
using namespace std;
struct tup
{
	int x,y,z;
	tup(int X=0,int Y=0,int Z=0)
	{x=X,y=Y,z=Z;}
	bool operator <(const tup nd)const
	{return x<nd.x;}
};
#ifdef FastI
#define getchar() (p1==p2&&(p2=(p1=in)+fread(in,1,1<<20,stdin),p1==p2)?EOF:*p1++)
#endif
#ifdef FastO
#define putchar(x) (p3-out==1<<20?fwrite(out,1,1<<20,stdout),p3=out,0:0,*p3++=x)
#define puts(x) write(x,'\n')
#endif
namespace FastIO
{
	template<typename T> inline void write(T x,char ch=' ')
	{
		if(is_same<char,T>::value)putchar(x);
		else
		{
			if(x<0)x=-x,putchar('-');
			static char st[25];
			int top=0;
			do st[top++]=x%10+'0',x/=10;while(x);
			while(top)putchar(st[--top]);
		}
		ch!='~'?putchar(ch):0;
	}
	inline void write(const char*x,char ch=' ')
	{
		for(int i=0;x[i]!='\0';++i)putchar(x[i]);
		ch!='~'?putchar(ch):0;
	}
	inline void read(char&s){do s=getchar();while(s=='\n'||s==' ');}
	inline void read(char s[])
	{
		int len=0;char st;
		do st=getchar();while(st=='\n'||st==' ');
		s[++len]=st,st=getchar();
		while(st!='\n'&&st!=' '&&st!='\r')s[++len]=st,st=getchar();
		s[++len]='\0';
	}
	template<typename T> inline void read(T &s)
	{
		char ch=getchar();s=0;
		while((ch>'9'||ch<'0')&&ch!='-')ch=getchar();
		bool tf=(ch=='-'&&(ch=getchar()));
		while(ch>='0'&&ch<='9')s=(s<<1)+(s<<3)+ch-'0',ch=getchar();
		s=tf?-s:s;
	}
	inline void edl(){putchar('\n');}
	template<typename T1,typename T2> inline void read(pair<T1,T2> &s){read(s.fi),read(s.se);}
	template<typename T,typename...Args> inline void write(T x,Args...args){write(x,'~'),write(args...);}
	template<typename T,typename...Args> inline void read(T&x,Args&...args){read(x),read(args...);}
	#ifdef FastO
	struct Writer{~Writer(){fwrite(out,1,p3-out,stdout);}}Writ;
	#endif
}
using namespace FastIO;
namespace MTool
{
	inline int Cadd(int a,int b){return (ll)a+b>=MOD?(ll)a+b-MOD:a+b;}
	inline int Cdel(int a,int b){return a-b<0?a-b+MOD:a-b;}
	inline int Cmul(int a,int b){return 1ll*a*b%MOD;}
	inline int sqr(int a){return 1ll*a*a%MOD;}
	inline void Madd(int&a,int b){a=((ll)a+b>=MOD?(ll)a+b-MOD:a+b);}
	inline void Mdel(int&a,int b){a=(a-b<0?a-b+MOD:a-b);}
	inline void Mmul(int&a,int b){a=1ll*a*b%MOD;}
	inline int Cmod(int x){return (x%MOD+MOD)%MOD;}
	inline void Mmod(int&x){x=(x%MOD+MOD)%MOD;}
	template<typename T> inline bool Mmax(T&a,T b){return a<b?a=b,1:0;}
	template<typename T> inline bool Mmin(T&a,T b){return a>b?a=b,1:0;}
	template<typename...Args> inline void Madd(int&a,int b,Args...args){Madd(a,b),Madd(a,args...);}
	template<typename...Args> inline void Mmul(int&a,int b,Args...args){Mmul(a,b),Mmul(a,args...);}
	template<typename...Args> inline void Mdel(int&a,int b,Args...args){Mdel(a,b),Mdel(a,args...);}
	template<typename...Args> inline int Cadd(int a,int b,Args...args){return Cadd(Cadd(a,b),args...);}
	template<typename...Args> inline int Cmul(int a,int b,Args...args){return Cmul(Cmul(a,b),args...);}
	template<typename...Args> inline int Cdel(int a,int b,Args...args){return Cdel(Cdel(a,b),args...);}
	template<typename...Args,typename T> inline bool Mmax(T&a,T b,Args...args){return Mmax(a,b)|Mmax(a,args...);}
	template<typename...Args,typename T> inline bool Mmin(T&a,T b,Args...args){return Mmin(a,b)|Mmin(a,args...);}
	inline int power(int x,int y){int s=1;for(;y;y>>=1,Mmul(x,x))if(y&1)Mmul(s,x);return s;}
}
using namespace MTool;
namespace WrongAnswer_90
{
	int n,m;
	vi T[500010],ve[500010];
	vi add[500010],del[500010];
	int c[500010];
	pii a[500010];
	int ans[500010];
	
	namespace Tree
	{
		int tot,siz[500010],dep[500010],son[500010];
	    int top[500010],dfn[500010],id[500010],fa[500010];
	    inline int LCA(int x,int y)
	    {
	    	while(top[x]!=top[y])
	    	{
	    		if(dep[top[x]]>dep[top[y]])swap(x,y);
	    		y=fa[top[y]];
			}
			return dep[x]<dep[y]?x:y;
		}
	    void init()
		{
			for(int i=1;i<=n;++i)
			dep[i]=id[i]=dfn[i]=fa[i]=siz[i]=top[i]=son[i]=0;
			tot=0;
		    auto dfs0=[&](auto dfs0,int x,int Fa=0)->void
		    {
		        fa[x]=Fa,siz[x]=1;
		        dep[x]=dep[Fa]+1;
		        for(auto to:T[x])if(to!=Fa)
		        {
		            dfs0(dfs0,to,x),siz[x]+=siz[to];
		            if(siz[to]>siz[son[x]])son[x]=to;
		        }
		    };
		    auto dfs1=[&](auto dfs1,int x,int Top=1)->void
		    {
		        top[x]=Top;
				id[dfn[x]=++tot]=x;
		        if(son[x])dfs1(dfs1,son[x],Top);
		        for(auto to:T[x])if(to!=fa[x]&&to!=son[x])
		    	dfs1(dfs1,to,to);
		    };
	    	dfs0(dfs0,1),dfs1(dfs1,1);
		}
	}
	using namespace Tree;
	void dfs(int x)
	{
		for(auto to:T[x])if(to!=fa[x])
		dfs(to),c[x]+=c[to];
	}
	
	struct Delset
	{
	    int t[500010];
	    int top,st[500010];
	    void push(int x){st[++top]=x;}
	    void erase(int x){++t[x];}
	    void upd(){while(top&&t[st[top]])--t[st[top--]];}
	    int get(){return upd(),st[top];}
	}st[30];
	
	inline void modify(int x,int y,int z)
	{
		while(top[x]!=top[y])
		{
			if(dep[top[x]]>dep[top[y]])swap(x,y);
			del[top[y]].eb(z);
			add[y].eb(z);
			y=fa[top[y]];
		}
		if(dep[x]>dep[y])swap(x,y);
		add[y].eb(z);
	}
	void solve(int x,int dep=1)
	{
		if(x==1)cerr<<del[x].size()<<" "<<st[1].top<<" "<<st[1].st[3]<<' '<<st[1].get()<<endl;
		for(auto p:del[x])st[dep].erase(p);
		vi ers;
		for(auto id:ve[x])
		{
			ans[id]=st[dep].get();
			st[dep].erase(ans[id]);
			ers.eb(ans[id]);
			modify(a[id].fi,a[id].se,ans[id]);
		}
		if(son[x])
		{
			for(auto p:add[x])st[dep].push(p);
			solve(son[x],dep);
			for(auto p:add[x])st[dep].erase(p);
		}
		for(auto to:T[x])if(to!=fa[x]&&to!=son[x])
		solve(to,dep+1);
		
		for(auto p:ers)st[dep].push(p);
		for(auto p:del[x])st[dep].push(p);
	}
	
	void mian()
	{
		int x,y,lca;
		read(n,m);
		for(int i=1;i<=n;++i)
		{
			T[i].clear(),c[i]=0,ve[i].clear();
			add[i].clear(),del[i].clear();
		}
		for(int i=1;i<30;++i)
		{
			for(int j=1;j<=m;++j)st[i].t[j]=st[i].st[j]=0;
			st[i].top=0;
		}
		
		for(int i=1;i<n;++i)read(x,y),T[x].eb(y),T[y].eb(x);
		init();
		
		for(int i=1;i<=m;++i)
		{
			read(x,y),lca=LCA(x,y);
			++c[x],++c[y];
			--c[lca],--c[fa[lca]];
			a[i]=mp(x,y);
			ve[lca].eb(i);
		}
		
		dfs(1);
		int mx=-inf;
		for(int i=1;i<=n;++i)Mmax(mx,c[i]);
		
		for(int i=1;i<30;++i)for(int j=1;j<=mx;++j)st[i].push(j);
		solve(1);
		
		write(mx,'\n');
		for(int i=1;i<=m;++i)write(ans[i]);
		puts("");
	}
	inline void Mian()
	{
		int T=1,C;
		read(C,T);
		while(T--)mian();
	}
}
bool ED;
signed main()
{
//	ios::sync_with_stdio(0);
//	freopen("1.in","r",stdin);
//	freopen("1.out","w",stdout);
	double st=clock();
	WrongAnswer_90::Mian();
	double ed=clock();
 	cerr<<endl;
 	cerr<<"Time: "<<ed-st<<" ms\n";
 	cerr<<"Memory: "<<abs(&ST-&ED)/1024.0/1024.0<<" MB\n";
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 3
Accepted

Test #1:

score: 3
Accepted
time: 257ms
memory: 140312kb

input:

1
100000
1 2
1 1
1 1
3 5
1 2
2 3
2 1
2 3
1 1
1 1
3 3
1 3
1 1
1 1
1 1
4 4
1 2
2 3
3 4
3 3
2 1
3 3
4 2
5 3
1 2
1 3
1 4
2 5
1 1
3 3
3 1
1 5
1 1
1 1
1 1
1 1
1 1
2 5
1 2
2 1
1 2
1 2
1 2
1 2
2 2
1 2
2 2
2 2
4 2
1 2
1 3
1 4
4 4
2 3
2 3
1 2
1 2
1 1
1 1
1 4
1 1
1 1
1 1
1 1
5 3
1 2
2 3
3 4
4 5
3 4
4 5
5 2
2 1...

output:

2
2 1 
3
3 2 2 1 3 
3
3 2 1 
3
3 3 1 2 
2
2 2 1 
5
5 4 3 2 1 
5
5 4 3 2 1 
2
2 1 
1
1 1 
3
3 2 1 
4
4 3 2 1 
3
2 1 3 
1
1 
2
2 1 
4
4 3 2 1 
3
3 2 3 1 
3
3 2 2 1 
1
1 
2
1 2 
2
2 1 
4
4 3 2 1 
3
1 3 2 3 
4
4 3 2 1 2 
1
1 
4
4 3 2 1 
1
1 
5
5 4 3 2 1 
1
1 1 
5
5 4 3 2 1 
2
2 1 2 
3
3 2 3 1 
3
3 2 1 
...

result:

ok ok

Subtask #2:

score: 14
Accepted

Dependency #1:

100%
Accepted

Test #2:

score: 14
Accepted
time: 60ms
memory: 167528kb

input:

2
1005
489417 5
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:

4
2 1 4 4 3 
4
2 1 3 2 4 
3
1 1 3 3 2 
3
3 2 2 2 1 
4
1 4 3 2 
3
1 3 2 2 3 
4
1 4 3 2 
3
3 3 2 1 2 
4
2 4 3 1 
4
4 3 2 2 1 
3
3 2 3 1 
4
4 3 2 1 
5
5 4 1 3 2 
3
1 2 3 3 2 
5
5 4 3 2 1 
5
5 4 1 3 2 
4
4 1 3 2 
3
3 1 2 2 
4
4 3 2 1 
4
3 2 1 4 
4
2 4 4 3 1 
5
2 5 4 3 1 
3
3 3 1 2 1 
2
2 1 1 2 
5
3 1 2 ...

result:

ok ok

Test #3:

score: 14
Accepted
time: 193ms
memory: 211436kb

input:

2
9250
403459 5
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:

5
5 4 2 3 1 
4
2 4 3 2 1 
4
4 3 2 1 
4
4 3 2 1 
2
2 2 2 1 
4
4 1 3 2 
5
5 4 3 2 1 
3
3 2 2 3 1 
2
2 2 2 1 
4
4 3 2 1 
2
2 2 1 2 
4
4 2 3 3 1 
3
3 2 2 2 1 
4
3 4 2 1 
3
2 3 2 2 1 
2
2 2 1 1 2 
4
1 3 2 4 2 
3
1 2 1 3 
4
4 2 1 3 
3
2 3 3 2 1 
3
3 3 1 2 
5
4 5 3 1 2 
4
3 1 3 2 4 
2
2 2 1 1 
4
4 3 3 2 1 ...

result:

ok ok

Test #4:

score: 14
Accepted
time: 49ms
memory: 165936kb

input:

2
120
55394 5
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:

3
1 1 3 2 3 
2
2 2 1 1 2 
4
3 4 1 3 2 
4
4 2 3 2 1 
4
2 4 3 3 1 
3
2 3 1 3 2 
5
5 4 3 2 1 
4
4 3 2 1 
3
3 2 2 1 
3
3 2 1 3 
2
1 2 1 2 
3
1 1 3 2 2 
5
5 4 3 2 1 
5
5 4 3 2 1 
4
4 3 2 1 
3
3 2 2 1 
3
3 3 1 2 
3
3 2 2 1 
4
4 3 2 2 1 
5
5 4 3 2 1 
4
4 3 4 2 1 
3
2 3 1 1 3 
3
3 2 1 2 
5
5 4 3 2 1 
4
1 2 ...

result:

ok ok

Test #5:

score: 14
Accepted
time: 94ms
memory: 162648kb

input:

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

output:

5
5 4 3 2 1 
4
4 1 4 3 2 
4
1 3 4 4 2 
4
4 4 3 2 1 
4
4 3 2 3 1 
3
1 2 3 2 
3
1 3 2 3 
3
3 1 2 3 
5
5 4 3 2 1 
3
3 2 3 1 
4
4 2 1 3 
3
2 3 2 1 
3
3 2 2 1 
3
3 2 1 2 3 
4
2 4 3 2 1 
4
4 3 4 1 2 
4
4 3 2 1 
2
2 2 2 1 
5
2 5 4 1 3 
3
3 2 2 1 1 
5
5 2 4 1 3 
4
4 2 3 1 
5
3 5 2 4 1 
3
3 2 1 2 
4
2 4 3 2 ...

result:

ok ok

Test #6:

score: 14
Accepted
time: 37ms
memory: 140408kb

input:

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

output:

4
2 4 1 3 2 
2
1 2 2 2 1 
2
2 2 2 1 1 
4
3 1 3 2 4 
4
4 2 3 2 1 
3
3 1 2 3 2 
5
5 4 3 2 1 
4
4 3 3 1 2 
4
4 2 1 3 4 
4
4 4 2 3 1 
5
5 4 3 2 1 
5
4 3 5 1 2 
4
2 4 4 1 3 
3
3 3 1 3 2 
3
1 2 3 3 3 
2
2 1 1 2 1 
2
2 2 2 1 2 
3
3 2 3 3 1 
3
1 2 2 3 2 
5
5 4 3 2 1 
5
5 4 1 3 2 
4
1 2 3 3 4 
3
2 1 3 1 2 
3...

result:

ok ok

Test #7:

score: 14
Accepted
time: 32ms
memory: 140244kb

input:

2
400
2260 5
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 5...

output:

3
3 1 2 1 2 
4
1 3 4 3 2 
5
5 4 3 2 1 
4
4 4 3 1 2 
3
3 3 1 2 3 
5
5 4 3 2 1 
4
2 3 4 2 1 
4
4 3 2 3 1 
5
1 5 4 3 2 
4
4 4 3 2 1 
5
4 3 2 1 5 
5
5 4 3 2 1 
4
4 4 3 2 1 
4
4 3 2 1 1 
3
3 2 2 3 1 
3
3 2 3 1 1 
3
3 2 3 2 1 
5
5 4 3 2 1 
5
3 2 5 4 1 
5
5 4 3 2 1 
3
2 3 3 2 1 
4
4 3 2 1 4 
3
3 2 2 3 1 
5...

result:

ok ok

Test #8:

score: 14
Accepted
time: 103ms
memory: 172128kb

input:

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

output:

4
4 3 2 1 4 
4
4 3 3 1 2 
5
5 2 4 1 3 
5
2 5 3 4 1 
4
4 3 2 1 
4
4 3 2 1 4 
5
5 4 3 2 1 
4
4 4 3 2 1 
4
2 3 1 4 3 
4
4 4 1 3 2 
4
4 3 3 2 1 
2
2 2 2 1 
3
2 1 2 3 3 
4
4 3 2 1 4 
3
2 3 1 2 
3
2 1 3 2 
3
2 1 3 3 3 
4
4 4 2 3 1 
5
5 4 3 1 2 
3
3 1 2 2 
3
3 1 3 1 2 
4
4 2 3 2 1 
4
4 3 2 1 
4
3 4 3 2 1 
...

result:

ok ok

Test #9:

score: 14
Accepted
time: 125ms
memory: 161644kb

input:

2
9078
76509 5
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:

3
2 1 1 3 3 
4
1 4 3 2 3 
4
1 3 4 4 2 
5
5 4 3 2 1 
3
3 2 1 2 
5
5 1 4 3 2 
4
4 2 1 3 
4
3 2 1 2 4 
4
4 1 3 4 2 
2
2 2 1 1 
4
1 4 4 2 3 
4
4 1 2 3 
5
3 2 1 5 4 
4
4 3 2 1 
4
4 3 2 1 
5
5 4 1 3 2 
5
3 2 5 1 4 
3
3 2 3 3 1 
4
3 1 4 2 3 
3
3 2 3 2 1 
4
2 1 4 3 
5
4 1 2 3 5 
3
3 3 2 1 2 
3
3 3 2 2 1 
4
...

result:

ok ok

Test #10:

score: 14
Accepted
time: 211ms
memory: 173084kb

input:

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

output:

5
5 4 3 2 1 
5
4 1 3 2 5 
4
3 4 1 2 1 
3
3 2 1 3 
4
4 4 1 3 2 
3
2 3 1 2 
4
4 3 3 2 1 
4
4 3 2 1 
5
5 3 4 2 1 
4
4 2 3 1 
4
4 3 2 1 
5
5 2 4 1 3 
3
3 3 1 3 2 
5
5 2 4 1 3 
3
3 3 2 1 
2
1 2 2 1 
3
3 1 2 1 
3
3 2 3 1 1 
4
3 2 1 4 
5
5 4 3 2 1 
3
3 2 1 3 
4
2 4 1 3 4 
4
4 3 2 1 
5
5 2 1 4 3 
3
3 3 2 1 ...

result:

ok ok

Subtask #3:

score: 9
Accepted

Test #11:

score: 9
Accepted
time: 222ms
memory: 328824kb

input:

3
1769
481318 428631
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:

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

result:

ok ok

Test #12:

score: 9
Accepted
time: 188ms
memory: 190036kb

input:

3
5246
78503 54670
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:

12758
10983 3193 5 7934 5048 6413 10752 10597 11337 7660 4441 2005 2224 3662 4670 4106 12533 8438 5950 6137 2652 6911 11974 6029 475 11625 1283 4509 11891 3675 3704 210 5854 10636 908 9233 12450 557 7064 1769 2913 11999 6469 2703 313 8536 3709 8749 6445 9435 5699 487 1040 190 4072 5479 1536 3566 4 7...

result:

ok ok

Test #13:

score: 9
Accepted
time: 88ms
memory: 141572kb

input:

3
396
1125 1442
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:

160
90 111 57 132 154 131 136 77 21 127 35 114 150 119 61 60 27 145 47 44 67 120 7 28 2 107 73 37 100 135 88 70 56 105 29 93 91 16 157 12 151 137 97 90 43 83 45 80 66 69 81 44 97 147 16 109 17 11 115 72 64 81 133 70 124 144 108 99 98 100 48 114 151 151 152 50 150 104 86 79 15 148 10 125 31 68 126 13...

result:

ok ok

Test #14:

score: 9
Accepted
time: 81ms
memory: 140748kb

input:

3
487
1664 2238
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:

558
411 383 133 342 433 149 423 49 183 184 377 368 325 267 386 475 200 410 173 354 488 264 553 228 319 363 293 98 263 54 164 558 490 21 240 290 33 171 245 117 457 275 209 112 107 392 206 230 469 208 446 249 253 34 313 167 103 311 113 375 526 469 454 464 434 349 85 449 476 421 462 151 94 554 199 550 ...

result:

ok ok

Test #15:

score: 9
Accepted
time: 247ms
memory: 333968kb

input:

3
130
498610 459330
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:

28970
1919 17248 10376 24718 9038 11645 10000 5028 4288 26002 5948 19411 3080 26846 21150 12244 20237 23158 15747 12058 3765 13623 9570 12183 25434 7102 16949 12722 523 14545 17918 2848 13050 26548 10862 4850 9291 6206 28777 7561 17021 23345 6199 16612 23050 10205 28878 13104 27649 4599 8853 4772 20...

result:

ok ok

Test #16:

score: 9
Accepted
time: 231ms
memory: 321632kb

input:

3
3566
462541 448340
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:

183
112 36 86 170 56 88 45 149 146 69 12 48 161 164 96 170 175 161 116 24 38 164 15 118 109 73 160 73 94 46 41 95 104 121 151 44 133 84 74 111 77 138 81 29 80 102 123 107 89 79 60 120 83 97 148 165 57 111 72 140 131 12 166 172 85 123 119 180 177 59 118 105 182 63 7 179 178 51 20 134 135 170 127 79 1...

result:

ok ok

Subtask #4:

score: 20
Accepted

Test #17:

score: 20
Accepted
time: 4ms
memory: 139728kb

input:

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

output:

839
832 839 838 836 837 836 835 834 833 832 839 831 830 829 828 827 826 825 824 823 822 835 821 820 838 819 818 817 816 838 815 814 813 812 301 811 839 810 838 809 808 807 806 805 804 803 802 833 801 800 799 798 797 796 795 794 793 45 792 791 790 789 788 787 786 785 836 784 783 839 782 781 780 779 7...

result:

ok ok

Test #18:

score: 20
Accepted
time: 0ms
memory: 139544kb

input:

4
26
910 955
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 5...

output:

417
265 56 185 21 85 349 302 369 328 92 356 153 135 83 363 221 384 358 194 246 112 369 264 15 301 413 309 245 94 410 160 382 220 408 251 100 208 51 219 396 353 205 82 166 405 240 401 45 166 177 358 28 384 176 373 310 272 400 198 138 214 390 66 321 305 387 152 138 366 45 66 280 414 417 20 368 60 244 ...

result:

ok ok

Test #19:

score: 20
Accepted
time: 3ms
memory: 139612kb

input:

4
27
932 945
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 53
2...

output:

161
161 160 159 74 51 158 34 158 82 9 30 106 155 96 148 99 157 32 150 75 10 161 147 124 90 101 148 150 46 48 151 38 11 87 111 36 77 152 106 160 158 155 75 35 79 37 92 8 121 39 103 157 161 157 157 34 138 94 154 159 96 148 18 25 9 39 12 107 134 35 40 52 161 161 20 149 7 143 153 154 63 156 93 149 101 3...

result:

ok ok

Test #20:

score: 20
Accepted
time: 3ms
memory: 139592kb

input:

4
27
915 930
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 5...

output:

473
204 347 452 233 3 405 220 418 304 198 186 452 233 202 37 181 167 121 55 284 316 301 397 202 92 187 407 137 436 123 140 127 199 274 99 439 339 359 411 434 91 148 265 398 357 309 123 420 329 159 138 276 351 150 157 329 278 449 72 343 262 224 392 248 378 111 159 237 264 282 224 66 52 157 73 133 263...

result:

ok ok

Test #21:

score: 20
Accepted
time: 7ms
memory: 139656kb

input:

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

output:

196
59 196 60 73 195 92 194 193 192 191 151 167 190 169 55 160 58 189 188 54 53 187 7 186 52 185 184 4 183 51 50 182 52 181 180 179 178 177 117 176 175 5 174 191 49 173 48 172 47 171 170 169 46 187 168 6 167 166 45 44 165 189 164 43 151 163 162 161 160 4 42 41 149 159 158 141 157 156 155 154 153 152...

result:

ok ok

Test #22:

score: 20
Accepted
time: 3ms
memory: 139556kb

input:

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

output:

216
216 94 215 150 95 214 216 3 100 102 17 213 103 212 211 210 105 209 208 207 206 205 204 203 96 107 202 108 61 202 97 210 98 109 112 201 209 20 215 200 199 70 63 113 164 65 198 202 116 118 197 115 196 209 203 195 200 99 194 181 193 192 191 190 204 189 93 188 143 173 92 187 186 185 184 183 182 181 ...

result:

ok ok

Test #23:

score: 20
Accepted
time: 3ms
memory: 139632kb

input:

4
24
935 984
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 5...

output:

175
30 117 76 93 6 104 168 62 130 161 80 119 74 165 107 69 120 95 46 123 77 71 40 57 91 133 36 32 135 5 153 41 52 110 111 60 68 112 31 111 37 3 32 116 22 12 91 123 42 72 73 50 108 16 135 99 89 98 88 54 44 113 101 148 160 162 146 31 73 25 65 84 170 143 32 164 100 147 129 131 54 159 101 103 19 78 150 ...

result:

ok ok

Test #24:

score: 20
Accepted
time: 4ms
memory: 139572kb

input:

4
31
919 917
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 53
2...

output:

588
500 122 121 120 122 119 588 587 586 566 585 584 583 121 582 3 581 585 118 580 579 117 578 577 576 575 116 574 573 228 120 572 119 118 571 570 117 115 569 568 581 567 585 567 566 565 564 116 124 563 562 561 560 559 558 557 115 556 114 588 125 113 555 112 111 554 114 584 553 110 552 551 550 109 54...

result:

ok ok

Test #25:

score: 20
Accepted
time: 3ms
memory: 139740kb

input:

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

output:

123
9 123 28 121 122 15 120 10 123 122 10 2 11 119 12 50 11 12 82 118 8 9 3 121 13 120 13 10 14 121 117 16 4 5 120 116 15 14 11 17 12 15 119 13 115 114 16 6 119 16 113 17 7 14 15 123 118 16 17 17 122 118 117 18 18 116 117 19 18 19 112 19 20 20 18 19 21 121 115 22 21 20 21 111 110 114 22 109 108 20 2...

result:

ok ok

Test #26:

score: 20
Accepted
time: 3ms
memory: 139684kb

input:

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

output:

648
648 617 647 646 645 644 73 647 648 643 642 641 621 640 78 639 638 622 637 80 636 635 634 633 9 85 646 632 631 630 626 629 628 12 277 627 626 631 625 624 623 622 621 620 619 618 617 616 615 614 645 613 634 308 612 611 638 610 89 609 13 644 608 607 606 644 605 604 92 603 643 93 602 646 309 618 601...

result:

ok ok

Test #27:

score: 20
Accepted
time: 4ms
memory: 139800kb

input:

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

output:

675
18 665 257 265 588 587 272 274 281 301 586 283 22 306 675 350 671 367 385 585 584 148 583 582 30 161 35 675 581 580 579 428 578 432 577 576 575 436 461 574 38 472 496 573 572 513 668 571 570 514 569 568 567 523 527 40 662 529 540 566 573 47 565 564 563 562 561 50 674 137 560 574 673 672 559 575 ...

result:

ok ok

Test #28:

score: 20
Accepted
time: 0ms
memory: 139468kb

input:

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

output:

377
143 145 377 349 367 376 375 151 374 2 333 154 373 3 295 162 8 372 371 370 369 325 368 367 366 374 365 165 364 166 123 363 314 362 361 360 359 374 9 358 170 357 356 355 354 353 352 192 351 370 171 188 11 248 26 350 349 348 280 299 303 347 322 327 372 346 377 345 337 342 370 365 344 135 134 133 40...

result:

ok ok

Test #29:

score: 20
Accepted
time: 4ms
memory: 137552kb

input:

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

output:

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

result:

ok ok

Test #30:

score: 20
Accepted
time: 4ms
memory: 139700kb

input:

4
31
943 994
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 5...

output:

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

result:

ok ok

Test #31:

score: 20
Accepted
time: 4ms
memory: 137824kb

input:

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

output:

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

result:

ok ok

Test #32:

score: 20
Accepted
time: 3ms
memory: 139360kb

input:

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

output:

150
117 150 52 149 2 148 148 147 3 4 93 148 146 88 133 145 85 144 116 5 123 70 6 134 60 7 143 8 142 48 141 9 4 71 140 54 135 89 139 120 149 38 10 115 138 136 144 5 48 150 11 92 103 47 39 40 49 98 49 41 137 138 9 139 103 91 147 137 140 12 42 141 104 114 43 44 10 93 13 148 45 14 136 135 149 53 15 142 ...

result:

ok ok

Subtask #5:

score: 22
Accepted

Dependency #4:

100%
Accepted

Test #33:

score: 22
Accepted
time: 72ms
memory: 158100kb

input:

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

output:

27238
27238 27237 27236 27235 26630 27204 27234 27080 27233 27232 27231 27230 27229 27228 27227 27226 27225 27224 27223 27129 27222 27221 27220 27219 27218 27217 27216 27215 27214 27213 27212 27211 27210 27209 27208 27207 27206 27205 27204 27203 27202 27201 27200 27141 27199 27198 13398 27197 27196 ...

result:

ok ok

Test #34:

score: 22
Accepted
time: 77ms
memory: 159092kb

input:

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

output:

43611
43585 43611 43610 43609 16778 16784 43608 16786 43607 43576 16801 16805 43606 16806 2 33666 16808 16814 16815 43605 16819 42980 43604 43485 16823 43419 43603 16825 43020 16833 16836 43602 43081 43601 16842 42970 16843 43290 43600 16850 43599 3 16862 16864 42960 43077 43598 43597 16866 4 43596 ...

result:

ok ok

Test #35:

score: 22
Accepted
time: 96ms
memory: 164188kb

input:

5
465
95072 88256
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...

output:

58693
58693 34194 58692 58691 22781 18837 18837 56755 58690 58689 18836 58688 58687 58686 18835 18834 58685 58684 58683 3 58682 58081 17829 6 18833 58681 58680 58679 18836 18832 58678 58677 58676 58675 58674 57359 58368 58673 58469 18839 18831 18830 18829 58672 58671 58670 55772 58669 18828 58668 18...

result:

ok ok

Test #36:

score: 22
Accepted
time: 36ms
memory: 147920kb

input:

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

output:

11000
11000 10999 10998 10997 10992 10996 10995 10995 10994 10993 10992 10991 10990 10989 10961 10988 10987 10994 10986 1736 10985 10984 10983 10982 10981 10980 10979 10978 10977 10976 10975 4731 10974 10973 10920 10972 10971 10970 10969 10969 10968 10967 10966 10965 10964 10963 10962 10961 10960 10...

result:

ok ok

Test #37:

score: 22
Accepted
time: 38ms
memory: 148380kb

input:

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

output:

3386
3386 3385 955 3384 3383 3382 3381 956 3380 3379 957 958 959 960 1414 3378 3377 2 3376 961 3375 962 3374 3373 3158 963 3 3372 964 3371 3370 3369 3161 965 3368 966 967 3367 3366 3365 968 3143 3364 3363 3362 3361 4 969 3360 3359 3358 5 3357 3356 970 971 3355 3354 3353 972 174 3136 3352 3351 3350 3...

result:

ok ok

Test #38:

score: 22
Accepted
time: 35ms
memory: 147128kb

input:

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

output:

1051
291 549 123 240 1051 910 576 1050 1049 578 629 652 241 1048 242 672 677 678 684 124 1047 125 692 699 334 706 126 708 1046 894 243 712 1045 715 723 1044 736 743 1043 127 4 1042 789 128 1041 244 794 1040 245 246 1039 838 1038 182 683 1042 939 969 379 60 247 638 129 35 652 130 326 1048 248 302 300...

result:

ok ok

Test #39:

score: 22
Accepted
time: 27ms
memory: 141652kb

input:

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

output:

451
451 268 2 450 347 3 277 295 4 449 318 5 321 6 329 448 7 357 8 429 9 447 10 362 11 446 12 445 13 14 364 15 367 369 385 444 16 17 401 18 19 20 21 22 414 23 24 25 443 416 26 437 442 447 361 27 28 451 261 29 260 449 441 448 440 442 259 30 31 32 33 439 438 437 436 435 34 35 440 36 37 434 433 38 258 2...

result:

ok ok

Test #40:

score: 22
Accepted
time: 23ms
memory: 139672kb

input:

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

output:

118
118 118 117 116 117 115 114 113 112 111 110 2 109 108 107 106 105 104 103 99 112 102 96 101 100 99 98 97 96 95 94 93 3 92 91 90 89 88 87 86 85 84 83 82 4 110 81 81 88 118 105 80 5 6 80 17 79 85 90 78 103 111 109 18 88 87 7 77 19 8 108 20 79 76 107 91 9 75 107 21 22 105 6 103 89 74 61 85 78 77 10...

result:

ok ok

Test #41:

score: 22
Accepted
time: 20ms
memory: 141972kb

input:

5
227
1768 690
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:

345
23 182 178 178 176 30 320 258 230 238 139 71 105 75 7 32 216 187 223 224 74 73 218 6 291 77 164 206 80 112 143 237 41 328 203 294 116 213 284 210 48 62 219 198 174 192 121 7 323 302 130 311 143 259 265 123 216 295 262 340 289 258 165 53 147 57 212 240 272 238 150 172 304 21 117 194 38 175 152 33...

result:

ok ok

Test #42:

score: 22
Accepted
time: 23ms
memory: 141368kb

input:

5
139
2287 2214
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:

695
695 604 694 693 534 546 121 438 694 366 692 452 688 652 691 677 174 690 82 689 695 203 204 176 175 673 171 107 672 694 134 551 688 617 681 678 694 170 683 679 687 693 169 686 676 169 685 242 552 684 179 380 537 168 641 167 166 588 686 683 630 674 693 556 165 551 682 81 693 79 550 164 163 661 692...

result:

ok ok

Test #43:

score: 22
Accepted
time: 75ms
memory: 168996kb

input:

5
85
99108 97396
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:

48829
34923 47337 29755 33449 46384 32759 14378 205 38007 23328 21449 41514 34521 7559 4246 35117 20155 4797 21772 39335 22063 26116 20364 28087 42997 24373 39936 43587 28252 43957 29357 41805 40549 35298 30808 28607 24913 30809 2449 28806 13360 13032 23527 6704 2234 1417 10093 3330 19990 43471 3473...

result:

ok ok

Test #44:

score: 22
Accepted
time: 64ms
memory: 159292kb

input:

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

output:

126
101 40 126 125 124 123 122 95 121 120 119 118 119 117 116 115 101 114 113 112 100 103 111 110 109 120 120 108 107 106 105 104 37 103 102 101 100 99 119 98 97 96 124 95 94 93 92 121 4 91 90 122 89 116 88 87 99 86 85 84 83 82 81 102 80 79 78 77 76 106 75 74 123 8 35 73 72 71 70 69 97 68 67 66 65 6...

result:

ok ok

Test #45:

score: 22
Accepted
time: 42ms
memory: 158840kb

input:

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

output:

10182
287 10182 10181 288 10180 10179 10178 10177 10176 289 10165 290 291 230 7747 10182 183 8160 10181 10118 231 249 10180 250 7546 232 10179 251 10175 292 293 252 10130 10129 253 10178 233 234 10174 235 10128 10164 193 10173 10172 10171 254 294 255 236 10163 295 10127 10162 194 10126 195 10170 256...

result:

ok ok

Test #46:

score: 22
Accepted
time: 43ms
memory: 172184kb

input:

5
1256
83133 86248
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:

31782
5555 30851 23936 15041 15139 31531 3598 20743 19556 26190 21919 12445 29960 5621 9522 16847 26625 29460 22805 3306 12056 25303 14427 4877 15445 11550 10311 13328 2083 31156 9875 9612 13849 18103 16666 19234 30318 17189 12199 20118 26678 20742 27056 19972 19744 25283 17937 29763 23881 30452 590...

result:

ok ok

Test #47:

score: 22
Accepted
time: 29ms
memory: 147700kb

input:

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

output:

4114
4114 4113 4112 4111 4110 4109 4108 2 4107 4106 4105 4104 4103 3 4102 4101 4100 4 4099 4098 4097 3522 4096 4095 4094 4093 4092 4091 4090 3859 3060 4089 3500 4088 4087 4086 4085 3057 4084 4083 4082 4081 4006 4080 4114 3494 4079 4078 3053 3860 4077 4076 934 4075 4074 5 6 4073 4072 4071 4070 4069 4...

result:

ok ok

Test #48:

score: 22
Accepted
time: 38ms
memory: 146976kb

input:

5
443
9541 12325
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:

2862
2102 1264 1412 2063 2507 664 2443 1987 1613 1603 503 1977 2010 2172 83 1220 2426 569 2057 1768 2433 900 2325 2791 2673 633 549 1467 2158 1480 2030 122 2015 534 2064 2707 2815 30 1642 2425 1186 1278 1429 136 1825 912 741 1012 2726 1668 395 669 563 2806 2796 343 1934 1008 2479 1167 599 813 172 80...

result:

ok ok

Subtask #6:

score: 32
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Dependency #5:

100%
Accepted

Test #49:

score: 32
Accepted
time: 215ms
memory: 332428kb

input:

6
178
497927 412086
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:

120
15 46 48 7 117 19 58 53 70 61 91 103 94 10 67 76 39 23 40 51 30 28 102 93 58 29 59 19 29 107 59 96 102 92 44 83 116 46 104 67 113 71 51 30 64 111 66 30 110 57 112 38 69 71 61 43 8 72 87 109 86 4 88 112 34 99 22 87 44 48 78 111 36 60 46 56 78 62 117 102 113 59 83 9 115 95 101 36 90 50 39 84 70 24...

result:

ok ok

Test #50:

score: 32
Accepted
time: 313ms
memory: 319320kb

input:

6
3234
454553 464302
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:

232572
201217 74545 121309 60239 186598 67768 49600 2750 190435 85836 195318 228110 16092 162524 200448 197861 173047 85256 228239 84187 127214 52361 102025 192369 202471 186460 147704 47885 173111 57415 108455 139344 173644 104281 200178 143475 46513 205149 146722 182407 225473 219527 175232 123091...

result:

ok ok

Test #51:

score: 32
Accepted
time: 568ms
memory: 221552kb

input:

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

output:

347915
347915 347914 347913 347912 347911 347910 347909 344275 347908 347907 347906 347905 347904 347903 347902 347901 347900 347899 347898 347897 347896 347895 347894 347893 347892 347891 347890 347602 347889 347888 347887 347886 347885 347884 347883 347563 347882 92843 347881 347880 347879 347878 ...

result:

ok ok

Test #52:

score: 32
Accepted
time: 302ms
memory: 181472kb

input:

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

output:

80099
2 49101 80099 80098 49107 49113 49117 80097 49119 75439 80096 49120 49122 49127 80095 79756 49130 78904 49132 3 80094 80093 80092 49135 80091 49142 4 80090 49147 49152 5 49156 49157 49158 49161 79875 49162 49163 80089 77050 80088 49166 6 80087 49176 49178 49179 79506 80086 49181 34722 51207 49...

result:

ok ok

Test #53:

score: 32
Accepted
time: 305ms
memory: 214120kb

input:

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

output:

8376
8376 8375 8374 464 6883 6970 7341 3890 2730 3870 7777 3454 2119 2086 8373 201 5948 2615 195 6125 334 4140 4792 1722 792 8270 6988 511 8372 7987 4693 4359 6063 3277 962 2416 4613 8371 7786 6406 8370 8369 7833 5924 8368 4795 3073 2668 456 4287 3162 7737 2385 8367 783 7082 5734 4028 2402 3874 1088...

result:

ok ok

Test #54:

score: 32
Accepted
time: 192ms
memory: 206464kb

input:

6
6213
156426 135199
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:

62086
48411 5853 26359 52704 23543 44663 40250 7202 15184 54932 33325 49353 40879 55661 21207 34345 41143 54639 35761 57113 35424 36826 41138 27710 30210 46590 23595 7597 14847 54813 12775 34497 42917 20542 20817 55952 14936 16773 20160 3095 58921 60921 8148 26732 21601 36851 55834 25997 22731 53422...

result:

ok ok

Test #55:

score: 32
Accepted
time: 105ms
memory: 142048kb

input:

6
394
1424 1766
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:

604
604 603 127 602 604 600 599 601 394 598 600 602 122 601 104 598 501 593 104 121 120 597 596 603 595 564 594 72 593 603 592 591 590 166 589 575 588 600 576 548 590 587 122 260 303 335 586 365 417 573 211 598 603 584 264 600 151 357 585 584 588 119 583 118 404 473 601 575 582 581 580 579 602 578 4...

result:

ok ok

Test #56:

score: 32
Accepted
time: 107ms
memory: 142000kb

input:

6
400
1210 2471
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:

1521
1521 1520 1519 10 1518 1517 1516 429 3 1515 1514 103 1472 1513 428 1512 1511 1510 1509 1466 892 427 1508 426 1507 7 425 849 1519 196 1510 1506 1505 1504 1518 428 427 1466 1503 1502 379 1501 1500 426 1499 1498 425 1497 1516 1496 430 424 1495 423 1494 1493 8 1492 184 1517 1491 1490 1489 432 1502 ...

result:

ok ok

Test #57:

score: 32
Accepted
time: 103ms
memory: 140788kb

input:

6
428
1031 1178
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:

747
586 747 746 160 745 744 743 463 160 13 159 158 159 157 158 742 741 740 156 162 739 676 155 738 154 157 737 736 735 153 734 156 733 732 152 742 743 151 731 730 729 728 727 162 164 726 155 251 725 695 724 723 154 165 153 152 719 722 150 165 721 745 720 719 149 735 733 718 151 717 716 715 719 148 7...

result:

ok ok

Test #58:

score: 32
Accepted
time: 111ms
memory: 143000kb

input:

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

output:

344
2 69 344 343 342 341 70 340 71 339 72 338 337 336 73 335 3 334 333 332 331 330 74 144 75 329 328 327 326 76 4 325 324 77 78 323 79 322 321 80 81 320 82 83 319 318 317 84 316 85 315 314 313 312 311 310 309 86 87 308 307 88 306 305 304 89 147 90 91 92 93 5 303 302 301 94 95 96 97 300 98 99 344 6 2...

result:

ok ok

Test #59:

score: 32
Accepted
time: 94ms
memory: 140460kb

input:

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

output:

730
730 729 720 729 728 727 726 725 724 723 33 717 400 722 606 721 720 338 52 719 680 718 5 382 722 700 203 717 716 396 715 637 619 407 371 266 332 428 714 713 618 328 712 711 710 606 87 432 709 17 423 708 18 707 616 158 721 569 563 241 522 375 408 584 383 366 627 706 705 704 372 201 704 703 188 2 5...

result:

ok ok

Test #60:

score: 32
Accepted
time: 312ms
memory: 320188kb

input:

6
2736
454986 470122
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:

204856
113431 45643 121269 28666 85047 43231 63490 199661 189730 99806 165404 80314 135596 69823 32243 98068 162183 169579 152955 182996 8051 120525 73268 35092 23503 140590 115899 99374 174857 17406 112491 136844 180560 86571 56437 174501 58026 118866 23687 110006 30367 127315 95847 203868 111109 6...

result:

ok ok