QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#669428#9488. Do Not Turn Backbulijiojiodibuliduo#AC ✓21ms8484kbC++175.2kb2024-10-23 18:35:222024-10-23 18:35:23

Judging History

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

  • [2024-10-23 18:35:23]
  • 评测
  • 测评结果:AC
  • 用时:21ms
  • 内存:8484kb
  • [2024-10-23 18:35:22]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef basic_string<int> BI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}()); 
const ll mod=998244353;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

namespace linear_seq {
	const int N=10010;
	ll res[N],base[N],_c[N],_md[N];

	vector<int> Md;
	void mul(ll *a,ll *b,int k) {
		rep(i,0,k+k) _c[i]=0;
		rep(i,0,k) if (a[i]) rep(j,0,k) _c[i+j]=(_c[i+j]+a[i]*b[j])%mod;
		for (int i=k+k-1;i>=k;i--) if (_c[i])
			rep(j,0,SZ(Md)) _c[i-k+Md[j]]=(_c[i-k+Md[j]]-_c[i]*_md[Md[j]])%mod;
		rep(i,0,k) a[i]=_c[i];
	}
	int solve(ll n,VI a,VI b) { // a 系数 b 初值 b[n+1]=a[0]*b[n]+...
		ll ans=0,pnt=0;
		int k=SZ(a);
		assert(SZ(a)==SZ(b));
		rep(i,0,k) _md[k-1-i]=-a[i];_md[k]=1;
		Md.clear();
		rep(i,0,k) if (_md[i]!=0) Md.push_back(i);
		rep(i,0,k) res[i]=base[i]=0;
		res[0]=1;
		while ((1ll<<pnt)<=n) pnt++;
		for (int p=pnt;p>=0;p--) {
			mul(res,res,k);
			if ((n>>p)&1) {
				for (int i=k-1;i>=0;i--) res[i+1]=res[i];res[0]=0;
				rep(j,0,SZ(Md)) res[Md[j]]=(res[Md[j]]-res[k]*_md[Md[j]])%mod;
			}
		}
		rep(i,0,k) ans=(ans+res[i]*b[i])%mod;
		if (ans<0) ans+=mod;
		return ans;
	}
	VI BM(VI s) {
		VI C(1,1),B(1,1);
		int L=0,m=1,b=1;
		rep(n,0,SZ(s)) {
			ll d=0;
			rep(i,0,L+1) d=(d+(ll)C[i]*s[n-i])%mod;
			if (d==0) ++m;
			else if (2*L<=n) {
				VI T=C;
				ll c=mod-d*powmod(b,mod-2)%mod;
				while (SZ(C)<SZ(B)+m) C.pb(0);
				rep(i,0,SZ(B)) C[i+m]=(C[i+m]+c*B[i])%mod;
				L=n+1-L; B=T; b=d; m=1;
			} else {
				ll c=mod-d*powmod(b,mod-2)%mod;
				while (SZ(C)<SZ(B)+m) C.pb(0);
				rep(i,0,SZ(B)) C[i+m]=(C[i+m]+c*B[i])%mod;
				++m;
			}
		}
		return C;
	}
	int gao(VI a,ll n) {
		VI c=BM(a);
		c.erase(c.begin());
		rep(i,0,SZ(c)) c[i]=(mod-c[i])%mod;
		return solve(n,c,VI(a.begin(),a.begin()+SZ(c)));
	}
};

template<int MOD, int RT> struct mint {
	static const int mod = MOD;
	static constexpr mint rt() { return RT; } // primitive root for FFT
	int v; explicit operator int() const { return v; } // explicit -> don't silently convert to int
	mint():v(0) {}
	mint(ll _v) { v = int((-MOD < _v && _v < MOD) ? _v : _v % MOD);
		if (v < 0) v += MOD; }
	bool operator==(const mint& o) const {
		return v == o.v; }
	friend bool operator!=(const mint& a, const mint& b) { 
		return !(a == b); }
	friend bool operator<(const mint& a, const mint& b) { 
		return a.v < b.v; }
   
	mint& operator+=(const mint& o) { 
		if ((v += o.v) >= MOD) v -= MOD; 
		return *this; }
	mint& operator-=(const mint& o) { 
		if ((v -= o.v) < 0) v += MOD; 
		return *this; }
	mint& operator*=(const mint& o) { 
		v = int((ll)v*o.v%MOD); return *this; }
	mint& operator/=(const mint& o) { return (*this) *= inv(o); }
	friend mint pow(mint a, ll p) {
		mint ans = 1; assert(p >= 0);
		for (; p; p /= 2, a *= a) if (p&1) ans *= a;
		return ans; }
	friend mint inv(const mint& a) { assert(a.v != 0); 
		return pow(a,MOD-2); }
		
	mint operator-() const { return mint(-v); }
	mint& operator++() { return *this += 1; }
	mint& operator--() { return *this -= 1; }
	friend mint operator+(mint a, const mint& b) { return a += b; }
	friend mint operator-(mint a, const mint& b) { return a -= b; }
	friend mint operator*(mint a, const mint& b) { return a *= b; }
	friend mint operator/(mint a, const mint& b) { return a /= b; }
};

const int MOD=998244353; 
using mi = mint<MOD,5>; // 5 is primitive root for both common mods

namespace simp {
	vector<mi> fac,ifac,invn;
	void check(int x) {
		if (fac.empty()) {
			fac={mi(1),mi(1)};
			ifac={mi(1),mi(1)};
			invn={mi(0),mi(1)};
		}
		while (SZ(fac)<=x) {
			int n=SZ(fac),m=SZ(fac)*2;
			fac.resize(m);
			ifac.resize(m);
			invn.resize(m);
			for (int i=n;i<m;i++) {
				fac[i]=fac[i-1]*mi(i);
				invn[i]=mi(MOD-MOD/i)*invn[MOD%i];
				ifac[i]=ifac[i-1]*invn[i];
			}
		}
	}
	mi gfac(int x) {
		assert(x>=0);
		check(x); return fac[x];
	}
	mi ginv(int x) {
		assert(x>0);
		check(x); return invn[x];
	}
	mi gifac(int x) {
		assert(x>=0);
		check(x); return ifac[x];
	}
	mi binom(int n,int m) {
		if (m < 0 || m > n) return mi(0);
		return gfac(n)*gifac(m)*gifac(n - m);
	}
	mi binombf(int n,int m) {
		if (m < 0 || m > n) return mi(0);
		if (m>n-m) m=n-m;
		mi p=1,q=1;
		for (int i=1;i<=m;i++) p=p*(n+1-i),q=q*i;
		return p/q;
	}
}

const int N=1010;
int n,m,k;
VI e[N];
mi dp[N][N];
int main() {
	scanf("%d%d%d",&n,&m,&k);
	rep(i,0,m) {
		int u,v;
		scanf("%d%d",&u,&v);
		e[u].pb(v);
		e[v].pb(u);
	}
	dp[0][1]=1;
	VI ret;
	ret.pb((int)dp[0][n]);
	rep(i,1,1001) {
		rep(u,1,n+1) {
			for (auto v:e[u]) dp[i][u]+=dp[i-1][v];
			if (i>=3) dp[i][u]-=dp[i-2][u]*(SZ(e[u])-1);
			else if (i>=2) dp[i][u]-=dp[i-2][u]*SZ(e[u]);
		}
		ret.pb((int)dp[i][n]);
	}
	printf("%d\n",linear_seq::gao(ret,k));
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 7852kb

input:

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

output:

2

result:

ok "2"

Test #2:

score: 0
Accepted
time: 0ms
memory: 8144kb

input:

11 11 2023
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
1 11

output:

1

result:

ok "1"

Test #3:

score: 0
Accepted
time: 2ms
memory: 7824kb

input:

7 21 1000000000
1 2
1 3
1 4
1 5
1 6
1 7
2 3
2 4
2 5
2 6
2 7
3 4
3 5
3 6
3 7
4 5
4 6
4 7
5 6
5 7
6 7

output:

405422475

result:

ok "405422475"

Test #4:

score: 0
Accepted
time: 2ms
memory: 8108kb

input:

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

output:

843326021

result:

ok "843326021"

Test #5:

score: 0
Accepted
time: 0ms
memory: 7852kb

input:

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

output:

69651169

result:

ok "69651169"

Test #6:

score: 0
Accepted
time: 2ms
memory: 7856kb

input:

14 79 33554431
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
2 3
2 4
2 5
2 6
2 7
2 8
2 11
2 12
2 14
3 5
3 6
3 7
3 8
3 9
3 10
3 11
3 12
3 13
3 14
4 5
4 6
4 7
4 8
4 9
4 11
4 12
5 6
5 7
5 10
5 11
5 12
5 13
5 14
6 7
6 8
6 9
6 10
6 11
6 12
6 13
6 14
7 8
7 9
7 10
7 11
7 12
7 13
7 14
8 10
8 11
8...

output:

793621538

result:

ok "793621538"

Test #7:

score: 0
Accepted
time: 2ms
memory: 7800kb

input:

15 92 439487671
1 2
1 3
1 5
1 7
1 8
1 9
1 10
1 11
1 13
1 14
1 15
2 3
2 4
2 5
2 6
2 7
2 8
2 9
2 10
2 11
2 12
2 13
2 14
2 15
3 4
3 5
3 6
3 7
3 8
3 9
3 10
3 11
3 12
3 13
3 14
3 15
4 5
4 6
4 7
4 8
4 9
4 10
4 11
4 12
4 13
4 14
4 15
5 7
5 8
5 10
5 11
5 12
5 13
5 14
6 7
6 8
6 9
6 10
6 11
6 12
6 13
6 14
6 1...

output:

196201187

result:

ok "196201187"

Test #8:

score: 0
Accepted
time: 0ms
memory: 7828kb

input:

5 10 230391930
1 2
1 3
1 4
1 5
2 3
2 4
2 5
3 4
3 5
4 5

output:

552614127

result:

ok "552614127"

Test #9:

score: 0
Accepted
time: 0ms
memory: 7828kb

input:

5 8 268435455
1 2
1 3
1 4
2 3
2 4
2 5
3 4
4 5

output:

666456772

result:

ok "666456772"

Test #10:

score: 0
Accepted
time: 2ms
memory: 7884kb

input:

6 13 67108863
1 2
1 3
1 4
1 5
2 4
2 5
2 6
3 4
3 5
3 6
4 5
4 6
5 6

output:

317571510

result:

ok "317571510"

Test #11:

score: 0
Accepted
time: 0ms
memory: 7836kb

input:

7 18 67108863
1 2
1 3
1 4
1 5
1 6
1 7
2 3
2 4
2 5
2 6
2 7
3 5
3 6
4 5
4 6
4 7
5 6
6 7

output:

921436359

result:

ok "921436359"

Test #12:

score: 0
Accepted
time: 2ms
memory: 7852kb

input:

11 43 115349891
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
2 3
2 6
2 7
2 8
2 9
2 11
3 4
3 5
3 8
3 9
3 10
4 5
4 6
4 7
4 8
4 9
4 11
5 6
5 7
5 9
5 10
5 11
6 7
6 9
6 10
6 11
7 8
7 9
7 10
7 11
8 9
8 11
9 10
9 11

output:

853336717

result:

ok "853336717"

Test #13:

score: 0
Accepted
time: 0ms
memory: 7924kb

input:

14 78 758166229
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
2 3
2 4
2 5
2 6
2 7
2 8
2 10
2 11
2 14
3 5
3 6
3 7
3 8
3 9
3 10
3 11
4 5
4 6
4 7
4 8
4 9
4 10
4 11
4 13
4 14
5 6
5 7
5 8
5 9
5 10
5 11
5 13
5 14
6 7
6 8
6 9
6 10
6 11
6 12
6 14
7 8
7 9
7 10
7 11
7 12
7 13
7 14
8 9
8 10
8 11
8 1...

output:

949739691

result:

ok "949739691"

Test #14:

score: 0
Accepted
time: 2ms
memory: 7936kb

input:

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

output:

0

result:

ok "0"

Test #15:

score: 0
Accepted
time: 1ms
memory: 8196kb

input:

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

output:

1

result:

ok "1"

Test #16:

score: 0
Accepted
time: 2ms
memory: 7884kb

input:

99 98 33554431
46 94
29 46
29 75
50 75
50 61
6 61
6 10
10 49
38 49
38 86
37 86
37 66
31 66
31 71
41 71
41 67
22 67
22 52
52 62
62 74
74 89
53 89
53 91
69 91
40 69
40 97
45 97
9 45
9 18
18 23
23 25
25 43
43 92
3 92
3 5
5 28
28 58
19 58
17 19
17 80
4 80
4 56
24 56
21 24
1 21
1 95
51 95
36 51
36 96
20 ...

output:

0

result:

ok "0"

Test #17:

score: 0
Accepted
time: 2ms
memory: 8128kb

input:

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

output:

1

result:

ok "1"

Test #18:

score: 0
Accepted
time: 0ms
memory: 7872kb

input:

91 91 68838384
35 46
29 46
29 75
50 75
50 61
6 61
6 10
10 49
38 49
38 86
37 86
37 66
31 66
31 71
41 71
41 67
22 67
22 52
52 62
62 74
74 89
53 89
53 91
69 91
40 69
40 79
45 79
9 45
9 18
18 23
23 25
25 43
12 43
3 12
3 5
5 28
28 58
19 58
17 19
17 80
4 80
4 56
24 56
21 24
1 21
1 64
51 64
36 51
36 47
20 ...

output:

1

result:

ok "1"

Test #19:

score: 0
Accepted
time: 2ms
memory: 7868kb

input:

92 92 860263916
30 45
45 60
60 66
66 78
15 78
9 15
9 14
14 35
35 37
37 85
24 85
24 65
64 65
10 64
10 53
32 53
22 32
22 51
51 80
80 92
77 92
43 77
33 43
33 39
39 82
6 82
2 6
2 88
40 88
40 58
25 58
25 72
72 91
7 91
7 8
8 57
48 57
21 48
21 68
68 79
55 79
12 55
12 38
1 38
1 90
63 90
13 63
13 44
44 54
47...

output:

1

result:

ok "1"

Test #20:

score: 0
Accepted
time: 19ms
memory: 7940kb

input:

91 4095 412854823
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
...

output:

309435713

result:

ok "309435713"

Test #21:

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

input:

92 4186 67108863
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:

445773689

result:

ok "445773689"

Test #22:

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

input:

93 4278 536870911
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
...

output:

664971360

result:

ok "664971360"

Test #23:

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

input:

94 4371 531304381
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
...

output:

33852961

result:

ok "33852961"

Test #24:

score: 0
Accepted
time: 2ms
memory: 8108kb

input:

10 38 187055368
1 2
1 3
1 5
1 6
1 8
1 9
1 10
2 3
2 4
2 5
2 6
2 7
2 8
2 9
2 10
3 4
3 5
3 6
3 7
3 8
3 9
3 10
4 5
4 6
4 7
4 8
4 9
5 7
5 8
5 9
5 10
6 7
6 8
6 9
6 10
7 8
7 10
8 10

output:

174346166

result:

ok "174346166"

Test #25:

score: 0
Accepted
time: 0ms
memory: 7900kb

input:

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

output:

898454226

result:

ok "898454226"

Test #26:

score: 0
Accepted
time: 5ms
memory: 7864kb

input:

46 843 103688348
1 2
1 3
1 4
1 5
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 33
1 34
1 35
1 36
1 37
1 38
1 41
1 42
1 43
1 44
1 45
2 3
2 4
2 5
2 6
2 7
2 9
2 10
2 11
2 12
2 13
2 14
2 15
2 16
2 18
2 19
2 20
2 22
2 23
2 26
2...

output:

804037438

result:

ok "804037438"

Test #27:

score: 0
Accepted
time: 10ms
memory: 7944kb

input:

81 2612 536870911
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 21
1 22
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
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 49
1 50
1 51
1 52
1 53
1 55
1 56
1 57
1 58
1 59
1 60
1 61
1 63
1 64
1 65
...

output:

439960927

result:

ok "439960927"

Test #28:

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

input:

98 3845 134217727
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 13
1 15
1 16
1 17
1 18
1 20
1 21
1 22
1 23
1 24
1 26
1 27
1 30
1 32
1 33
1 34
1 35
1 38
1 40
1 41
1 42
1 44
1 45
1 46
1 48
1 49
1 50
1 51
1 52
1 53
1 56
1 57
1 58
1 59
1 60
1 61
1 62
1 63
1 64
1 65
1 66
1 67
1 68
1 69
1 71
1 72
1 74
1 75
...

output:

687576024

result:

ok "687576024"

Test #29:

score: 0
Accepted
time: 4ms
memory: 7816kb

input:

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

output:

245031029

result:

ok "245031029"

Test #30:

score: 0
Accepted
time: 3ms
memory: 8184kb

input:

53 1106 268435455
1 2
1 3
1 4
1 5
1 6
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 38
1 39
1 40
1 41
1 42
1 43
1 44
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
2 3
2 4
2 5
2 6
2 7
2 9
2 10
2 11
2 13
2 14
...

output:

437352844

result:

ok "437352844"

Test #31:

score: 0
Accepted
time: 5ms
memory: 7884kb

input:

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

output:

287707534

result:

ok "287707534"

Test #32:

score: 0
Accepted
time: 9ms
memory: 8484kb

input:

66 1737 67108863
1 2
1 3
1 5
1 6
1 7
1 8
1 9
1 10
1 12
1 13
1 15
1 16
1 17
1 18
1 21
1 22
1 23
1 24
1 25
1 26
1 31
1 32
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 45
1 46
1 47
1 49
1 50
1 51
1 53
1 54
1 55
1 56
1 57
1 58
1 59
1 60
1 61
1 62
1 63
1 64
1 66
2 4
2 5
2 6
2 7
2 8
2 9
2 10
2 11
2...

output:

655903832

result:

ok "655903832"

Test #33:

score: 0
Accepted
time: 3ms
memory: 8144kb

input:

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

output:

3611745

result:

ok "3611745"

Test #34:

score: 0
Accepted
time: 19ms
memory: 7912kb

input:

100 4950 536870911
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...

output:

77654284

result:

ok "77654284"

Test #35:

score: 0
Accepted
time: 14ms
memory: 8216kb

input:

100 3962 536870911
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 12
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 35
1 36
1 37
1 38
1 39
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 51
1 53
1 54
1 55
1 56
1 57
1 58
1 60
1 61
1 62
1 63
1 64
1 65
1 67...

output:

277610741

result:

ok "277610741"

Test #36:

score: 0
Accepted
time: 21ms
memory: 8268kb

input:

99 3919 536870911
1 2
1 3
1 4
1 5
1 7
1 9
1 10
1 11
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 23
1 24
1 25
1 27
1 28
1 29
1 32
1 33
1 34
1 36
1 37
1 38
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 56
1 57
1 58
1 59
1 60
1 62
1 63
1 64
1 65
1 66
1 67
1 68
1 70
1 7...

output:

377999899

result:

ok "377999899"

Extra Test:

score: 0
Extra Test Passed