QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#259054#1255. Convex Sets On Graphchenxinyang2006AC ✓145ms109344kbC++145.2kb2023-11-20 16:07:532023-11-20 16:07:53

Judging History

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

  • [2023-11-20 16:07:53]
  • 评测
  • 测评结果:AC
  • 用时:145ms
  • 内存:109344kb
  • [2023-11-20 16:07:53]
  • 提交

answer

#include <bits/stdc++.h>
#define rep(i,j,k) for(int i=(j);i<=(k);i++)
#define per(i,j,k) for(int i=(j);i>=(k);i--)
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define db double
#define ldb long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mkp make_pair
#define eb emplace_back
#define SZ(S) (int)S.size()
#define mod 998244353
//#define mod 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3f
using namespace std;

template <class T>
void chkmax(T &x,T y){
    if(x < y) x = y;
}

template <class T>
void chkmin(T &x,T y){
    if(x > y) x = y;
}

inline int popcnt(int x){
    return __builtin_popcount(x);
}

inline int ctz(int x){
    return __builtin_ctz(x);
}

template <int P>
class mod_int
{
    using Z = mod_int;

private:
    static int mo(int x) { return x < 0 ? x + P : x; }

public:
    int x;
    int val() const { return x; }
    mod_int() : x(0) {}
    template <class T>
    mod_int(const T &x_) : x(x_ >= 0 && x_ < P ? static_cast<int>(x_) : mo(static_cast<int>(x_ % P))) {}
    bool operator==(const Z &rhs) const { return x == rhs.x; }
    bool operator!=(const Z &rhs) const { return x != rhs.x; }
    Z operator-() const { return Z(x ? P - x : 0); }
    Z pow(long long k) const
    {
        Z res = 1, t = *this;
        while (k)
        {
            if (k & 1)
                res *= t;
            if (k >>= 1)
                t *= t;
        }
        return res;
    }
    Z &operator++()
    {
        x < P - 1 ? ++x : x = 0;
        return *this;
    }
    Z &operator--()
    {
        x ? --x : x = P - 1;
        return *this;
    }
    Z operator++(int)
    {
        Z ret = x;
        x < P - 1 ? ++x : x = 0;
        return ret;
    }
    Z operator--(int)
    {
        Z ret = x;
        x ? --x : x = P - 1;
        return ret;
    }
    Z inv() const { return pow(P - 2); }
    Z &operator+=(const Z &rhs)
    {
        (x += rhs.x) >= P && (x -= P);
        return *this;
    }
    Z &operator-=(const Z &rhs)
    {
        (x -= rhs.x) < 0 && (x += P);
        return *this;
    }
    Z operator-()
    {
        return -x;
    }
    Z &operator*=(const Z &rhs)
    {
        x = 1ULL * x * rhs.x % P;
        return *this;
    }
    Z &operator/=(const Z &rhs) { return *this *= rhs.inv(); }
#define setO(T, o)                                  \
    friend T operator o(const Z &lhs, const Z &rhs) \
    {                                               \
        Z res = lhs;                                \
        return res o## = rhs;                       \
    }
    setO(Z, +) setO(Z, -) setO(Z, *) setO(Z, /)
#undef setO
    
    friend istream& operator>>(istream& is, mod_int& x)
    {
        long long tmp;
        is >> tmp;
        x = tmp;
        return is;
    }
    friend ostream& operator<<(ostream& os, const mod_int& x)
    {
        os << x.val();
        return os;
    }
};

using Z = mod_int<mod>;
Z power(Z p,ll k){
    Z ans = 1;
    while(k){
        if(k % 2 == 1) ans *= p;
        p *= p;
        k /= 2;
    }
    return ans;
}
Z fact[1000005],ifac[1000005],inv[1000005];

Z C(int N,int M){
    if(N < M || M < 0) return 0;
    return fact[N] * ifac[M] * ifac[N - M];
}

void init(int L){
    fact[0] = 1;
    rep(i,1,L) fact[i] = fact[i - 1] * i;
    ifac[L] = 1 / fact[L];
    per(i,L - 1,0) ifac[i] = ifac[i + 1] * (i + 1);
    rep(i,1,L) inv[i] = ifac[i] * fact[i - 1];
}
int n,m;

int cnt;
int head[300005];
struct eg{
    int to,nxt;
}edge[600005];

void make(int u,int v){
    edge[++cnt].to = v;
    edge[cnt].nxt = head[u];
    head[u] = cnt;
}

int dfn[300005],low[300005],N;
vector <int> sta,scc[300005];
void tarjan(int u){
    dfn[u] = low[u] = ++cnt;
    sta.eb(u);
    for(int i = head[u];i;i = edge[i].nxt){
        int v = edge[i].to;
        if(!dfn[v]){
//            printf("%d->%d\n",u,v);
            tarjan(v);
            chkmin(low[u],low[v]);
            if(low[v] < dfn[u]) continue;
            ++N;
            while(1){
                int p = sta.back();
                sta.pop_back();
                scc[N].eb(p);
                if(p == v) break;
            }
            scc[N].eb(u);
        }else{
            chkmin(low[u],dfn[v]);
        }
    }
}

vector <int> G[600005];
Z dp[600005],ans;
void dfs(int u,int f){
    dp[u] = 1;
    for(int v:G[u]){
        if(v == f) continue;
        dfs(v,u);
        dp[u] *= dp[v] + 1;
    }
    if(u > n){
        ans += dp[u];
        return;
    }

    dp[u]--;
    ans += dp[u];
    for(int v:G[u]) if(v != f) ans -= dp[v];
}

int main(){
//    freopen("test.in","r",stdin);
    scanf("%d%d",&n,&m);
    rep(i,1,m){
        int u,v;
        scanf("%d%d",&u,&v);
        make(u,v);make(v,u);
    }
    cnt = 0;
    tarjan(1);
//    rep(u,1,n) printf("node %d dfn %d low %d\n",u,dfn[u],low[u]);
    rep(c,1,N){
        for(int u:scc[c]){
//            printf("%d ",u);
            G[u].eb(n + c);
            G[n + c].eb(u);
        }
//        printf("\n");
    }
    dfs(1,0);
    ans += n + 1;
    printf("%d\n",ans.val());
	return 0;
}

詳細信息

Test #1:

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

input:

3 2
1 2
2 3

output:

7

result:

ok answer is '7'

Test #2:

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

input:

3 3
1 2
2 3
3 1

output:

5

result:

ok answer is '5'

Test #3:

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

input:

3 2
1 3
3 2

output:

7

result:

ok answer is '7'

Test #4:

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

input:

7 10
1 2
2 3
3 4
1 5
1 6
4 7
3 6
4 6
6 7
1 3

output:

11

result:

ok answer is '11'

Test #5:

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

input:

7 10
1 2
2 3
2 4
4 5
1 6
4 7
2 7
1 3
1 4
1 7

output:

14

result:

ok answer is '14'

Test #6:

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

input:

2 1
2 1

output:

4

result:

ok answer is '4'

Test #7:

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

input:

1 0

output:

2

result:

ok answer is '2'

Test #8:

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

input:

4 3
1 2
1 3
1 4

output:

12

result:

ok answer is '12'

Test #9:

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

input:

4 3
1 2
1 4
2 3

output:

11

result:

ok answer is '11'

Test #10:

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

input:

4 3
1 3
1 4
2 3

output:

11

result:

ok answer is '11'

Test #11:

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

input:

4 4
1 2
1 3
1 4
2 3

output:

8

result:

ok answer is '8'

Test #12:

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

input:

4 3
1 2
1 3
2 4

output:

11

result:

ok answer is '11'

Test #13:

score: 0
Accepted
time: 7ms
memory: 43060kb

input:

4 3
1 3
1 4
2 4

output:

11

result:

ok answer is '11'

Test #14:

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

input:

4 4
1 2
1 3
1 4
2 4

output:

8

result:

ok answer is '8'

Test #15:

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

input:

4 3
1 2
2 3
2 4

output:

12

result:

ok answer is '12'

Test #16:

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

input:

4 3
1 3
2 3
2 4

output:

11

result:

ok answer is '11'

Test #17:

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

input:

4 4
1 2
1 3
2 3
2 4

output:

8

result:

ok answer is '8'

Test #18:

score: 0
Accepted
time: 8ms
memory: 43132kb

input:

4 3
1 4
2 3
2 4

output:

11

result:

ok answer is '11'

Test #19:

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

input:

4 4
1 2
1 4
2 3
2 4

output:

8

result:

ok answer is '8'

Test #20:

score: 0
Accepted
time: 8ms
memory: 45068kb

input:

4 4
1 3
1 4
2 3
2 4

output:

6

result:

ok answer is '6'

Test #21:

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

input:

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

output:

6

result:

ok answer is '6'

Test #22:

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

input:

4 3
1 2
1 3
3 4

output:

11

result:

ok answer is '11'

Test #23:

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

input:

4 3
1 2
1 4
3 4

output:

11

result:

ok answer is '11'

Test #24:

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

input:

4 4
1 2
1 3
1 4
3 4

output:

8

result:

ok answer is '8'

Test #25:

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

input:

4 3
1 2
2 3
3 4

output:

11

result:

ok answer is '11'

Test #26:

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

input:

4 3
1 3
2 3
3 4

output:

12

result:

ok answer is '12'

Test #27:

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

input:

4 4
1 2
1 3
2 3
3 4

output:

8

result:

ok answer is '8'

Test #28:

score: 0
Accepted
time: 8ms
memory: 43072kb

input:

4 3
1 4
2 3
3 4

output:

11

result:

ok answer is '11'

Test #29:

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

input:

4 4
1 2
1 4
2 3
3 4

output:

6

result:

ok answer is '6'

Test #30:

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

input:

4 4
1 3
1 4
2 3
3 4

output:

8

result:

ok answer is '8'

Test #31:

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

input:

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

output:

6

result:

ok answer is '6'

Test #32:

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

input:

4 3
1 2
2 4
3 4

output:

11

result:

ok answer is '11'

Test #33:

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

input:

4 3
1 3
2 4
3 4

output:

11

result:

ok answer is '11'

Test #34:

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

input:

4 4
1 2
1 3
2 4
3 4

output:

6

result:

ok answer is '6'

Test #35:

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

input:

4 3
1 4
2 4
3 4

output:

12

result:

ok answer is '12'

Test #36:

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

input:

4 4
1 2
1 4
2 4
3 4

output:

8

result:

ok answer is '8'

Test #37:

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

input:

4 4
1 3
1 4
2 4
3 4

output:

8

result:

ok answer is '8'

Test #38:

score: 0
Accepted
time: 8ms
memory: 43216kb

input:

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

output:

6

result:

ok answer is '6'

Test #39:

score: 0
Accepted
time: 7ms
memory: 43140kb

input:

4 4
1 2
2 3
2 4
3 4

output:

8

result:

ok answer is '8'

Test #40:

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

input:

4 4
1 3
2 3
2 4
3 4

output:

8

result:

ok answer is '8'

Test #41:

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

input:

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

output:

6

result:

ok answer is '6'

Test #42:

score: 0
Accepted
time: 6ms
memory: 43132kb

input:

4 4
1 4
2 3
2 4
3 4

output:

8

result:

ok answer is '8'

Test #43:

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

input:

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

output:

6

result:

ok answer is '6'

Test #44:

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

input:

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

output:

6

result:

ok answer is '6'

Test #45:

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

input:

4 6
1 2
1 3
1 4
2 3
2 4
3 4

output:

6

result:

ok answer is '6'

Test #46:

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

input:

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

output:

13

result:

ok answer is '13'

Test #47:

score: 0
Accepted
time: 7ms
memory: 43216kb

input:

5 4
1 2
1 3
2 4
4 5

output:

16

result:

ok answer is '16'

Test #48:

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

input:

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

output:

59

result:

ok answer is '59'

Test #49:

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

input:

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

output:

181

result:

ok answer is '181'

Test #50:

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

input:

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

output:

9

result:

ok answer is '9'

Test #51:

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

input:

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

output:

7

result:

ok answer is '7'

Test #52:

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

input:

30000 30000
1 2
1 3
1 23
1 119
1 151
1 409
1 496
1 1171
1 2504
1 6068
1 9018
1 11788
2 4
2 6
2 36
2 1083
2 6711
2 12030
3 7
3 11
3 12
3 2887
3 19957
4 5
4 10
4 57
4 212
4 239
4 254
4 986
4 2909
4 3864
4 4212
4 5676
5 14
5 16
5 22
5 29
5 73
5 103
5 135
5 141
5 260
5 457
5 1232
5 2285
5 2696
5 3355
5 ...

output:

744360127

result:

ok answer is '744360127'

Test #53:

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

input:

30000 29999
1 2
1 4
1 9
1 18
1 948
1 1791
1 2345
1 2844
2 3
2 20
2 2655
2 2685
2 2761
3 5
3 7
3 8
3 12
3 17
3 659
3 6401
3 10752
3 13585
4 6
4 13
4 22
4 79
4 101
4 219
4 268
4 5283
4 12158
4 14159
5 10
5 11
5 36
5 55
5 122
5 759
5 1929
5 9804
6 187
6 1411
6 4864
6 5799
6 11486
6 16185
7 15
7 16
7 19...

output:

194335383

result:

ok answer is '194335383'

Test #54:

score: 0
Accepted
time: 7ms
memory: 43092kb

input:

245 29890
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 60
1 6...

output:

247

result:

ok answer is '247'

Test #55:

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

input:

300 30000
1 2
1 3
1 8
1 12
1 13
1 14
1 19
1 21
1 25
1 26
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 41
1 42
1 45
1 46
1 49
1 50
1 51
1 53
1 59
1 60
1 61
1 65
1 67
1 69
1 70
1 71
1 72
1 74
1 75
1 76
1 77
1 78
1 80
1 81
1 82
1 83
1 85
1 86
1 88
1 89
1 91
1 95
1 96
1 97
1 98
1 99
1 100
1 ...

output:

302

result:

ok answer is '302'

Test #56:

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

input:

246 30000
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 60
1 6...

output:

248

result:

ok answer is '248'

Test #57:

score: 0
Accepted
time: 8ms
memory: 44664kb

input:

10000 30000
1 2
1 4
1 5
1 6
1 10
1 46
1 1342
1 3845
1 5127
1 5253
1 8993
2 3
2 23
2 36
2 52
2 67
2 136
2 188
2 243
2 268
2 279
2 411
2 629
2 2481
2 3715
2 7602
2 8068
2 9673
3 40
3 124
3 172
3 342
3 631
3 662
3 1034
3 1250
3 1259
3 1360
3 1665
3 2109
3 2601
3 5693
3 5870
3 6508
3 9651
4 7
4 11
4 72
...

output:

738718813

result:

ok answer is '738718813'

Test #58:

score: 0
Accepted
time: 6ms
memory: 43292kb

input:

1000 30000
1 2
1 3
1 5
1 6
1 9
1 18
1 29
1 39
1 44
1 55
1 124
1 132
1 135
1 147
1 167
1 198
1 200
1 244
1 246
1 274
1 348
1 356
1 369
1 393
1 395
1 426
1 463
1 524
1 529
1 551
1 560
1 570
1 591
1 592
1 604
1 606
1 610
1 661
1 668
1 670
1 674
1 679
1 686
1 705
1 718
1 730
1 750
1 799
1 812
1 830
1 83...

output:

1002

result:

ok answer is '1002'

Test #59:

score: 0
Accepted
time: 7ms
memory: 43132kb

input:

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

output:

19

result:

ok answer is '19'

Test #60:

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

input:

300000 300000
1 2
1 3
1 7
1 14
1 80
1 156
1 722
1 851
1 1333
1 1781
1 8043
1 76874
1 82589
1 134059
2 4
2 9
2 27
2 31
2 265
2 894
2 3273
2 23497
2 156327
3 5
3 6
3 97
3 147
3 161
3 319
3 613
3 17862
3 120928
4 61
4 260
4 2229
4 4511
4 5782
4 22706
4 69845
4 85424
4 155292
5 8
5 10
5 11
5 15
5 135
5 ...

output:

784858481

result:

ok answer is '784858481'

Test #61:

score: 0
Accepted
time: 133ms
memory: 75696kb

input:

300000 299999
1 2
1 3
1 4
1 19
1 109
1 154
1 277
1 1047
1 1567
1 8606
1 58906
1 64583
1 189714
1 241489
1 286176
2 5
2 6
2 12
2 49
2 83
2 228
2 372
2 463
2 675
2 1105
2 2946
2 13775
2 29279
2 56774
2 272662
3 8
3 17
3 50
3 176
3 2125
3 5313
3 6548
3 38236
3 66241
3 89903
3 204809
4 20
4 28
4 77
4 17...

output:

73674682

result:

ok answer is '73674682'

Test #62:

score: 0
Accepted
time: 35ms
memory: 47248kb

input:

775 299925
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 60
1 ...

output:

777

result:

ok answer is '777'

Test #63:

score: 0
Accepted
time: 29ms
memory: 47088kb

input:

800 300000
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 55
1 56
1 57
1 58
1 59
1 60
1 61
1 ...

output:

802

result:

ok answer is '802'

Test #64:

score: 0
Accepted
time: 28ms
memory: 47240kb

input:

776 300000
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 60
1 ...

output:

778

result:

ok answer is '778'

Test #65:

score: 0
Accepted
time: 48ms
memory: 61056kb

input:

100000 300000
1 2
1 4
1 6
1 8
1 10
1 11
1 56
1 128
1 134
1 149
1 1938
1 2636
1 5207
1 12105
1 18188
1 20191
1 34306
1 55511
1 56814
1 58370
1 73016
1 75120
1 78178
1 89650
2 3
2 9
2 14
2 22
2 99
2 435
2 865
2 35286
2 55578
2 77902
2 86626
2 89075
3 5
3 13
3 23
3 68
3 96
3 147
3 689
3 4002
3 4368
3 7...

output:

508903263

result:

ok answer is '508903263'

Test #66:

score: 0
Accepted
time: 35ms
memory: 48412kb

input:

10000 300000
1 2
1 9
1 46
1 49
1 132
1 236
1 373
1 629
1 778
1 825
1 951
1 1035
1 1333
1 1574
1 1736
1 2110
1 2235
1 2300
1 2760
1 2886
1 3111
1 3149
1 3283
1 3511
1 3968
1 4219
1 4306
1 4851
1 4956
1 5254
1 5726
1 5881
1 6096
1 6699
1 6910
1 7287
1 7305
1 7807
1 7962
1 8071
1 8134
1 8139
1 8526
1 8...

output:

10002

result:

ok answer is '10002'

Test #67:

score: 0
Accepted
time: 33ms
memory: 46668kb

input:

1000 300000
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 11
1 12
1 14
1 16
1 17
1 18
1 21
1 24
1 25
1 26
1 27
1 28
1 31
1 34
1 35
1 36
1 37
1 40
1 41
1 42
1 43
1 47
1 49
1 50
1 51
1 52
1 54
1 55
1 60
1 61
1 62
1 64
1 68
1 69
1 72
1 75
1 78
1 81
1 83
1 84
1 87
1 88
1 89
1 90
1 92
1 96
1 97
1 98
1 100
1 101
1 102
1 ...

output:

1002

result:

ok answer is '1002'

Test #68:

score: 0
Accepted
time: 47ms
memory: 46976kb

input:

775 299925
386 558
760 764
266 613
557 747
24 368
455 687
256 352
289 400
489 587
115 158
108 281
190 214
293 716
304 731
117 164
290 654
372 375
142 336
489 718
245 399
246 495
584 677
204 263
379 595
67 722
20 644
151 675
155 164
113 420
174 427
667 741
224 614
688 689
279 287
177 200
488 579
50 6...

output:

777

result:

ok answer is '777'

Test #69:

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

input:

6 9
4 6
1 2
2 3
1 5
1 3
1 4
3 6
3 4
4 5

output:

8

result:

ok answer is '8'

Test #70:

score: 0
Accepted
time: 42ms
memory: 47448kb

input:

1338 299043
185 280
6 434
447 1310
159 486
347 688
54 830
299 363
250 1158
212 1098
433 1102
72 735
215 382
510 1313
408 751
177 888
158 1004
879 1012
216 474
531 586
156 655
143 515
37 1326
255 1230
267 307
60 591
228 1094
166 175
261 1264
282 1022
111 929
331 866
232 1298
927 1124
417 882
775 957
...

output:

1340

result:

ok answer is '1340'

Test #71:

score: 0
Accepted
time: 32ms
memory: 47368kb

input:

1095 299756
82 328
198 226
230 574
34 842
168 687
277 772
595 929
524 930
478 700
630 1002
455 1061
620 689
26 303
861 875
221 935
939 1061
267 994
61 431
292 607
269 925
355 500
122 437
639 683
160 997
310 658
511 1044
65 643
981 1036
31 1072
701 992
170 741
17 392
521 673
863 1094
202 745
170 725
...

output:

1099

result:

ok answer is '1099'

Test #72:

score: 0
Accepted
time: 51ms
memory: 73076kb

input:

200001 299999
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:

78478424

result:

ok answer is '78478424'

Test #73:

score: 0
Accepted
time: 54ms
memory: 73128kb

input:

200001 299999
200001 200000
200000 199999
199999 199998
199998 199997
199997 199996
199996 199995
199995 199994
199994 199993
199993 199992
199992 199991
199991 199990
199990 199989
199989 199988
199988 199987
199987 199986
199986 199985
199985 199984
199984 199983
199983 199982
199982 199981
199981...

output:

78478424

result:

ok answer is '78478424'

Test #74:

score: 0
Accepted
time: 68ms
memory: 71508kb

input:

200001 299999
153281 180117
180117 111295
111295 169234
169234 169877
169877 150276
150276 122865
122865 10968
10968 69558
69558 168830
168830 16865
16865 47507
47507 89231
89231 199657
199657 118035
118035 67168
67168 143671
143671 133752
133752 192407
192407 19033
19033 3951
3951 62468
62468 12207...

output:

78478424

result:

ok answer is '78478424'

Test #75:

score: 0
Accepted
time: 54ms
memory: 73180kb

input:

200001 300000
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:

538461389

result:

ok answer is '538461389'

Test #76:

score: 0
Accepted
time: 43ms
memory: 72824kb

input:

200001 300000
200001 200000
200000 199999
199999 199998
199998 199997
199997 199996
199996 199995
199995 199994
199994 199993
199993 199992
199992 199991
199991 199990
199990 199989
199989 199988
199988 199987
199987 199986
199986 199985
199985 199984
199984 199983
199983 199982
199982 199981
199981...

output:

538461389

result:

ok answer is '538461389'

Test #77:

score: 0
Accepted
time: 64ms
memory: 71944kb

input:

200001 300000
25308 168155
168155 6093
6093 111775
111775 153790
153790 120592
120592 54450
54450 129380
129380 31320
31320 158894
158894 105631
105631 120833
120833 100011
100011 88104
88104 21763
21763 77260
77260 129405
129405 127327
127327 27337
27337 65469
65469 55578
55578 31258
31258 18356
18...

output:

538461389

result:

ok answer is '538461389'

Test #78:

score: 0
Accepted
time: 48ms
memory: 61260kb

input:

160001 300000
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:

105784741

result:

ok answer is '105784741'

Test #79:

score: 0
Accepted
time: 54ms
memory: 61296kb

input:

160001 300000
160001 160000
160000 159999
159999 159998
159998 159997
159997 159996
159996 159995
159995 159994
159994 159993
159993 159992
159992 159991
159991 159990
159990 159989
159989 159988
159988 159987
159987 159986
159986 159985
159985 159984
159984 159983
159983 159982
159982 159981
159981...

output:

147088679

result:

ok answer is '147088679'

Test #80:

score: 0
Accepted
time: 63ms
memory: 61432kb

input:

160001 300000
100814 81998
81998 47964
47964 15162
15162 99833
99833 91815
91815 91064
91064 44409
44409 7755
7755 43827
43827 97797
97797 96617
96617 128251
128251 116798
116798 61949
61949 14165
14165 35036
35036 12130
12130 55984
55984 119544
119544 15032
15032 153671
153671 9090
9090 56365
56365...

output:

535533414

result:

ok answer is '535533414'

Test #81:

score: 0
Accepted
time: 53ms
memory: 61216kb

input:

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

output:

875682510

result:

ok answer is '875682510'

Test #82:

score: 0
Accepted
time: 44ms
memory: 55092kb

input:

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

output:

871559933

result:

ok answer is '871559933'

Test #83:

score: 0
Accepted
time: 39ms
memory: 55184kb

input:

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

output:

810684438

result:

ok answer is '810684438'

Test #84:

score: 0
Accepted
time: 46ms
memory: 55028kb

input:

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

output:

124111382

result:

ok answer is '124111382'

Test #85:

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

input:

300000 299999
6533 65589
119951 118217
270776 99408
51041 127254
237726 54399
31124 21544
58715 84487
151817 285934
145452 216045
127155 237820
243129 201499
256041 150176
174319 104773
41587 47046
76752 291101
134171 2947
173948 123465
129722 162464
31393 297757
266417 28478
89187 118299
253236 141...

output:

79154116

result:

ok answer is '79154116'

Test #86:

score: 0
Accepted
time: 90ms
memory: 96948kb

input:

300000 300000
22073 165630
61637 70257
248748 2412
241970 228465
28518 257307
211365 152915
13646 202596
117592 206538
237657 175158
29511 13254
264704 18520
19536 270965
287049 216771
180118 267066
257027 198355
21167 160999
287846 223478
171261 182678
225779 218914
267447 213583
961 18255
216187 2...

output:

300002

result:

ok answer is '300002'

Test #87:

score: 0
Accepted
time: 68ms
memory: 71072kb

input:

200000 300000
175387 148289
783 148543
124338 185832
51686 59428
77074 180633
142923 84355
187120 141069
177227 148963
2071 50055
238 187473
67236 70515
37334 164729
47102 175641
100314 62497
149021 2630
13189 147305
152944 2325
171914 131698
54628 160734
67201 19894
9033 71426
118815 28834
102066 8...

output:

200004

result:

ok answer is '200004'

Test #88:

score: 0
Accepted
time: 59ms
memory: 71284kb

input:

200000 300000
150031 115202
98687 87391
171564 143067
78791 5304
87510 76642
126106 93734
79444 198001
190408 162598
126020 163778
198834 97156
29233 99429
80142 198623
139130 171966
143120 170204
96310 82862
103012 148539
67782 95552
21009 183646
133951 189600
42925 73790
8288 22440
46773 69360
147...

output:

200002

result:

ok answer is '200002'

Test #89:

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

input:

299500 300000
263701 115587
189575 145996
108082 31462
113900 70108
34217 277109
274448 119438
94572 1423
257609 49388
18749 227188
51557 295685
212383 9474
175089 6482
110011 16321
21015 275608
225924 277904
55710 100221
144730 99699
82976 83873
62376 19828
22630 93713
237916 133952
47013 240491
23...

output:

1291437

result:

ok answer is '1291437'

Test #90:

score: 0
Accepted
time: 85ms
memory: 79644kb

input:

299500 300000
25734 242925
130686 256148
35916 8636
250757 163883
132221 36006
147533 282456
157152 184823
15067 163808
10316 224722
244887 72564
172381 204409
259879 233199
110581 253051
113319 238397
106452 27236
206903 2157
170704 126967
219289 102616
264073 271404
17361 279682
250394 89721
17044...

output:

299502

result:

ok answer is '299502'

Test #91:

score: 0
Accepted
time: 48ms
memory: 55760kb

input:

150000 299997
92094 109674
92094 60677
85418 134072
85418 81590
43060 59996
43060 83360
111117 107108
111117 22312
111117 40091
111117 80432
43038 91125
43038 22682
43038 42872
43038 148377
49842 4295
49842 141343
49842 129895
49842 30916
86892 103979
86892 61522
86892 13851
86892 2497
9449 141276
9...

output:

150002

result:

ok answer is '150002'

Test #92:

score: 0
Accepted
time: 42ms
memory: 53928kb

input:

128571 299994
25421 126045
25421 34013
8915 101430
8915 13235
15355 79240
15355 79831
1399 27359
1399 86662
1399 70394
1399 125078
1399 74253
1399 125102
27359 86662
27359 104
27359 122228
27359 37537
27359 44825
86662 125329
86662 84971
86662 25901
86662 64551
120331 1752
120331 3861
120331 118073
...

output:

128573

result:

ok answer is '128573'

Test #93:

score: 0
Accepted
time: 40ms
memory: 47352kb

input:

812 299999
305 271
646 590
731 702
163 741
574 653
351 579
507 197
144 514
19 249
237 157
274 256
71 669
604 421
549 711
126 67
737 65
579 646
564 794
748 530
130 263
806 243
778 338
698 254
548 368
163 733
329 157
783 333
41 365
320 237
330 713
736 636
340 663
286 54
403 381
454 370
753 241
600 360...

output:

814

result:

ok answer is '814'

Test #94:

score: 0
Accepted
time: 48ms
memory: 50824kb

input:

100128 299043
79234 23268
94196 79234
27908 89001
49484 82437
31011 28621
60780 50608
28645 76585
67016 97084
21601 88699
24031 59986
85683 6239
14077 3047
55953 23660
19275 97722
12987 39559
67560 52844
68311 2147
61477 12883
13221 2633
77916 79614
84059 94815
53775 2436
55861 23660
56704 25848
649...

output:

100130

result:

ok answer is '100130'

Test #95:

score: 0
Accepted
time: 48ms
memory: 49816kb

input:

75609 300000
21109 64924
65990 30766
29450 23140
1874 26970
61356 8886
47972 46048
3935 12623
15551 19436
33068 16355
51314 26489
7161 32779
58561 63829
67316 45145
23318 48644
31243 11254
24604 21256
43250 73108
74633 61406
32487 61297
35985 54733
11046 11374
8874 64903
47653 58020
51353 42888
6437...

output:

75611

result:

ok answer is '75611'

Test #96:

score: 0
Accepted
time: 44ms
memory: 49804kb

input:

75062 299999
40121 25852
55099 10458
27392 35815
16407 32044
2742 64851
52966 33942
56690 6529
43635 23068
28261 36597
2981 1848
45963 42778
28555 37390
27631 38736
11516 54296
38970 8621
29002 64964
22123 12783
58312 22667
26142 12361
9255 38405
10703 37252
28621 39572
25913 57130
48904 34341
50834...

output:

75064

result:

ok answer is '75064'

Test #97:

score: 0
Accepted
time: 40ms
memory: 46688kb

input:

825 300000
452 76
792 281
427 718
620 327
250 314
585 639
32 551
41 277
677 642
688 335
435 32
656 462
293 174
481 27
641 631
473 703
14 760
806 669
377 542
285 365
184 229
226 324
663 744
402 415
234 478
595 598
411 210
16 150
64 766
629 598
505 454
97 487
575 589
683 299
628 73
576 208
453 511
224...

output:

827

result:

ok answer is '827'

Test #98:

score: 0
Accepted
time: 49ms
memory: 53088kb

input:

149769 298764
138835 89874
7539 48630
114161 87287
112486 30105
95348 107903
130506 58267
2472 89893
13536 64757
88725 114678
41131 69200
74208 146634
37872 91112
137839 67816
89226 123894
34837 67546
108041 136343
126459 73504
94214 38092
138344 84062
68856 18108
13167 18178
116244 92749
101909 129...

output:

149771

result:

ok answer is '149771'

Test #99:

score: 0
Accepted
time: 54ms
memory: 52932kb

input:

133993 300000
14434 20265
101250 98678
86320 50456
63089 23159
58934 73819
13425 123868
59180 42714
70776 109361
3492 124088
96599 84442
17926 110939
74042 84879
71588 105526
60342 43358
110440 9084
94700 32072
80594 49667
68335 17747
2949 19944
90941 26534
10098 100932
121520 89903
71294 55833
3211...

output:

133995

result:

ok answer is '133995'

Test #100:

score: 0
Accepted
time: 59ms
memory: 61352kb

input:

150001 299999
142770 57520
131266 35305
20701 109984
133429 114690
106248 19354
29914 1305
132547 66441
95381 39470
81714 31322
120685 114518
102708 24508
99132 126088
99101 53362
108551 123828
44831 130222
61362 73361
20671 115843
102861 96673
6089 62292
17598 99424
149511 23517
87407 89753
137566 ...

output:

150003

result:

ok answer is '150003'

Test #101:

score: 0
Accepted
time: 63ms
memory: 64172kb

input:

150001 299999
78245 116764
86464 4866
86464 50191
15236 143100
80771 22238
68702 17274
86464 87336
40369 89746
86464 120069
86464 8102
86464 135348
86464 122118
138784 21816
86464 142386
52800 62250
82766 37698
32350 35769
59684 10615
142272 62612
86464 41771
6367 43619
85736 53608
86464 102736
8646...

output:

150003

result:

ok answer is '150003'

Test #102:

score: 0
Accepted
time: 68ms
memory: 67064kb

input:

150001 299999
71336 85994
118608 25700
462 4739
117895 77646
14528 143177
94216 61934
55857 58791
104469 139899
147376 69718
137893 132560
104266 22296
143784 69326
46926 24038
120880 109171
6662 148852
10490 101912
39709 144060
75891 47450
133316 16981
97206 111578
70153 75802
15886 18618
30601 538...

output:

150003

result:

ok answer is '150003'

Test #103:

score: 0
Accepted
time: 43ms
memory: 46068kb

input:

1538 279999
627 665
941 1139
629 1153
159 497
1104 421
1292 1127
30 1196
1526 772
157 649
1254 1178
635 472
897 716
129 589
1281 67
652 934
843 1146
43 63
507 1036
736 320
264 171
392 841
17 359
239 1173
722 1253
447 1176
1156 1048
527 193
88 494
410 259
518 457
439 29
409 412
1161 893
243 1271
939 ...

output:

1540

result:

ok answer is '1540'

Test #104:

score: 0
Accepted
time: 42ms
memory: 46748kb

input:

1538 279999
1010 84
1033 41
877 230
784 403
722 1234
367 125
1528 90
1310 388
348 656
1064 485
753 183
37 490
544 998
16 1324
1509 928
1538 6
1445 621
236 108
554 1467
488 334
614 202
912 105
537 593
1321 1438
1146 308
562 618
143 536
825 892
1006 1093
958 1245
439 1412
979 67
1537 485
191 1159
1290...

output:

1540

result:

ok answer is '1540'

Test #105:

score: 0
Accepted
time: 39ms
memory: 47412kb

input:

1538 279999
770 389
313 1147
612 91
1152 219
1015 505
18 1185
793 646
247 1437
208 257
1062 58
1458 350
1106 788
67 443
970 282
842 548
440 1398
919 682
833 1231
865 310
710 108
837 42
169 693
292 819
1301 614
1261 633
1026 968
711 1039
789 471
432 234
9 855
886 738
287 577
165 1455
1255 1213
987 48...

output:

1540

result:

ok answer is '1540'

Test #106:

score: 0
Accepted
time: 39ms
memory: 47516kb

input:

1886 296998
1034 42
837 836
1187 1105
171 1597
663 1510
555 1537
1199 419
718 780
619 601
634 383
1458 741
632 1622
17 1297
1801 1728
575 793
191 1551
1817 599
309 1013
1588 562
1703 1699
828 922
224 7
1277 1042
629 1575
1474 724
750 740
24 1474
1511 84
386 717
1266 412
1615 699
997 18
197 1547
1678...

output:

1888

result:

ok answer is '1888'

Test #107:

score: 0
Accepted
time: 45ms
memory: 47324kb

input:

1886 296998
62 563
81 791
408 683
1345 129
1099 1869
168 989
1566 676
581 288
845 1516
725 134
700 1427
1644 151
1707 326
683 1732
304 30
1743 203
1109 1692
571 9
498 1269
1716 202
454 481
473 1804
888 1341
1755 1314
1582 158
1509 1314
842 1623
392 1372
314 871
232 1002
1647 829
1543 856
1015 1131
4...

output:

1888

result:

ok answer is '1888'

Test #108:

score: 0
Accepted
time: 45ms
memory: 47408kb

input:

1886 296998
1465 1194
993 439
1493 703
1582 591
79 1395
1856 1414
1871 487
1493 100
686 964
761 1849
968 1121
442 71
215 1159
677 82
1011 1115
920 1626
1778 725
1195 1191
856 769
1671 508
1871 601
1564 202
1743 1684
439 1231
1460 932
1200 1796
874 928
461 1033
1490 367
1584 1537
578 317
1820 261
166...

output:

1888

result:

ok answer is '1888'

Test #109:

score: 0
Accepted
time: 116ms
memory: 75364kb

input:

290000 300000
1 2
1 7
1 10
1 18
1 20
1 22
1 33
1 203
1 385
1 1446
1 2395
1 5219
1 13436
1 33911
1 46039
1 56600
1 70399
1 213828
1 249388
2 3
2 4
2 5
2 6
2 169
2 207
2 979
2 1215
2 1293
2 2877
2 4726
2 6423
2 75386
3 8
3 9
3 299
3 864
3 1224
3 2419
3 3840
3 9266
3 55617
3 105386
4 13
4 47
4 86
4 169...

output:

917405209

result:

ok answer is '917405209'

Test #110:

score: 0
Accepted
time: 124ms
memory: 75476kb

input:

290001 300000
1 2
1 4
1 5
1 25
1 99
1 116
1 146
1 149
1 170
1 223
1 7819
1 9127
1 12229
1 14179
2 3
2 15
2 39
2 75
2 892
2 1416
2 1544
2 1579
2 7349
2 21920
3 11
3 31
3 38
3 45
3 198
3 763
3 1113
3 1717
3 1980
3 3332
3 5927
3 6697
3 33724
3 44078
3 46913
3 83780
3 274479
4 6
4 8
4 9
4 20
4 29
4 79
4...

output:

672238865

result:

ok answer is '672238865'

Test #111:

score: 0
Accepted
time: 118ms
memory: 75360kb

input:

290002 300000
1 2
1 3
1 13
1 14
1 188
1 199
1 320
1 418
1 909
1 5373
1 10476
1 27477
1 59088
2 4
2 6
2 21
2 70
2 91
2 132
2 226
2 9526
3 5
3 145
3 537
3 592
3 883
3 9397
3 17460
4 11
4 19
4 49
4 178
4 681
4 5237
4 21749
4 48286
4 60200
4 186318
4 271229
5 8
5 9
5 40
5 55
5 61
5 108
5 794
5 5893
5 67...

output:

490974543

result:

ok answer is '490974543'

Test #112:

score: 0
Accepted
time: 125ms
memory: 75304kb

input:

290003 300000
1 2
1 3
1 4
1 7
1 484
1 15390
2 5
2 6
2 19
2 22
2 31
2 52
2 60
2 134
2 189
2 628
2 1846
2 3564
3 111
3 151
3 200
3 343
3 395
3 1187
3 4301
3 5821
3 5828
3 5946
3 6028
3 39646
3 53738
3 76333
3 91701
4 61
4 1129
4 164489
5 8
5 14
5 16
5 30
5 47
5 59
5 69
5 121
5 332
5 340
5 1134
5 2840
...

output:

717929310

result:

ok answer is '717929310'

Test #113:

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

input:

290004 300000
1 2
1 3
1 5
1 13
1 35
1 42
1 119
1 6605
1 7357
1 67799
1 92199
1 152999
2 4
2 17
2 26
2 39
2 49
2 2444
2 27971
2 87780
3 10
3 24
3 212
3 350
3 2925
3 21807
3 109050
4 6
4 8
4 16
4 32
4 44
4 59
4 511
4 2261
4 4274
4 33328
4 80029
4 140377
4 142255
5 7
5 12
5 51
5 8906
5 14196
5 20154
5 ...

output:

388526499

result:

ok answer is '388526499'

Test #114:

score: 0
Accepted
time: 123ms
memory: 75360kb

input:

290005 300000
1 2
1 4
1 9
1 53
1 126
1 216
1 873
1 1409
1 1820
1 181296
2 3
2 15
2 23
2 31
2 259
2 261
2 680
2 2548
2 44017
2 134729
3 5
3 10
3 16
3 30
3 32
3 95
3 377
3 623
3 1883
3 2328
3 3839
3 5440
3 7967
3 8936
3 14428
3 255037
4 6
4 140
4 201
4 250
4 352
4 2387
4 3633
4 5368
4 12086
4 32527
4 ...

output:

83240220

result:

ok answer is '83240220'

Test #115:

score: 0
Accepted
time: 120ms
memory: 75532kb

input:

290006 300000
1 2
1 6
1 179
1 243
1 332
1 490
1 1403
1 2035
1 2198
1 5186
1 22539
1 35636
1 40118
1 232008
2 3
2 5
2 9
2 13
2 32
2 142
2 734
2 797
2 3867
2 4778
2 6382
2 20007
2 48221
2 272150
3 4
3 22
3 33
3 58
3 86
3 92
3 1072
3 3919
3 5073
3 20476
3 33836
3 132823
3 278866
4 7
4 15
4 17
4 41
4 29...

output:

985574599

result:

ok answer is '985574599'

Test #116:

score: 0
Accepted
time: 121ms
memory: 75276kb

input:

290007 300000
1 2
1 3
1 12
1 62
1 182
1 187
1 284
1 1463
1 84182
1 117788
1 233048
1 243222
2 4
2 29
2 172
2 200
2 1734
2 1975
2 4562
2 7392
2 11078
2 14958
2 44968
2 102650
2 112753
3 9
3 20
3 130
3 727
3 1962
3 2210
3 2334
3 32836
3 58862
3 162147
3 279172
4 5
4 6
4 341
4 761
4 2518
4 3624
4 4737
...

output:

616835454

result:

ok answer is '616835454'

Test #117:

score: 0
Accepted
time: 117ms
memory: 75388kb

input:

290008 300000
1 2
1 3
1 14
1 32
1 57
1 76
1 147
1 201
1 305
1 3872
1 4323
1 8205
1 18599
2 237
2 394
2 1389
2 3741
2 4429
2 8647
2 30920
3 4
3 5
3 6
3 11
3 23
3 74
3 75
3 80
3 85
3 451
3 2093
3 2521
3 199503
4 9
4 36
4 1989
4 37876
5 7
5 8
5 18
5 34
5 41
5 549
5 932
5 10887
5 20854
5 26547
5 64963
5...

output:

99099656

result:

ok answer is '99099656'

Test #118:

score: 0
Accepted
time: 102ms
memory: 75368kb

input:

290009 300000
1 2
1 3
1 5
1 6
1 15
1 43
1 56
1 102
1 127
1 209
1 247
1 273
1 7031
1 22191
1 24711
1 28451
1 74165
1 161154
2 4
2 12
2 42
2 422
2 528
2 1642
2 2370
2 52567
3 14
3 49
3 219
3 393
3 32839
4 7
4 11
4 22
4 28
4 72
4 462
4 1287
4 1372
4 79232
4 113625
5 9
5 10
5 119
5 147
5 389
5 713
5 793...

output:

728441448

result:

ok answer is '728441448'

Test #119:

score: 0
Accepted
time: 29ms
memory: 47196kb

input:

1000 300000
1 2
1 3
1 4
1 5
1 6
1 7
1 9
1 10
1 11
1 13
1 14
1 15
1 16
1 18
1 20
1 23
1 25
1 27
1 30
1 31
1 34
1 35
1 36
1 39
1 40
1 41
1 42
1 43
1 44
1 46
1 47
1 49
1 52
1 54
1 55
1 61
1 62
1 63
1 64
1 65
1 66
1 67
1 68
1 72
1 73
1 74
1 78
1 79
1 80
1 81
1 83
1 84
1 85
1 86
1 90
1 92
1 95
1 96
1 97
...

output:

1002

result:

ok answer is '1002'

Test #120:

score: 0
Accepted
time: 34ms
memory: 47472kb

input:

1001 300000
1 2
1 3
1 5
1 6
1 8
1 10
1 11
1 12
1 14
1 15
1 16
1 17
1 18
1 20
1 21
1 24
1 25
1 27
1 31
1 33
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 50
1 51
1 53
1 55
1 57
1 61
1 63
1 64
1 65
1 67
1 69
1 72
1 75
1 76
1 79
1 80
1 81
1 83
1 87
1 88
1 89
1 90
1 92
1 93
1 9...

output:

1003

result:

ok answer is '1003'

Test #121:

score: 0
Accepted
time: 32ms
memory: 46664kb

input:

1002 300000
1 2
1 3
1 4
1 6
1 9
1 10
1 11
1 14
1 15
1 17
1 19
1 20
1 21
1 22
1 23
1 25
1 27
1 29
1 30
1 32
1 33
1 38
1 42
1 44
1 45
1 47
1 48
1 52
1 53
1 54
1 55
1 56
1 57
1 59
1 60
1 61
1 65
1 67
1 70
1 72
1 75
1 76
1 77
1 78
1 79
1 80
1 82
1 86
1 90
1 91
1 92
1 94
1 95
1 96
1 99
1 100
1 101
1 102
...

output:

1004

result:

ok answer is '1004'

Test #122:

score: 0
Accepted
time: 26ms
memory: 47404kb

input:

1003 300000
1 2
1 3
1 4
1 6
1 8
1 9
1 10
1 12
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 23
1 25
1 28
1 29
1 31
1 32
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 44
1 46
1 47
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 58
1 59
1 60
1 62
1 64
1 65
1 66
1 71
1 74
1 76
1 77
1 78
1 79
1 80
1 82
1 83
1 86
1 87
1 88...

output:

1005

result:

ok answer is '1005'

Test #123:

score: 0
Accepted
time: 22ms
memory: 47312kb

input:

1004 300000
1 2
1 3
1 4
1 5
1 8
1 9
1 11
1 12
1 13
1 14
1 16
1 17
1 18
1 23
1 24
1 25
1 26
1 27
1 29
1 31
1 32
1 40
1 42
1 45
1 46
1 47
1 48
1 50
1 51
1 53
1 54
1 56
1 58
1 59
1 60
1 62
1 63
1 64
1 65
1 66
1 68
1 69
1 70
1 71
1 73
1 76
1 77
1 78
1 80
1 83
1 85
1 87
1 88
1 91
1 92
1 95
1 96
1 99
1 10...

output:

1006

result:

ok answer is '1006'

Test #124:

score: 0
Accepted
time: 28ms
memory: 47388kb

input:

1005 300000
1 2
1 3
1 4
1 5
1 6
1 8
1 9
1 10
1 11
1 12
1 17
1 18
1 19
1 21
1 22
1 25
1 27
1 29
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 42
1 43
1 45
1 47
1 49
1 50
1 51
1 53
1 54
1 57
1 59
1 60
1 62
1 66
1 67
1 69
1 71
1 73
1 74
1 75
1 76
1 77
1 78
1 79
1 81
1 82
1 83
1 85
1 86
1 87
1 89
1 90
...

output:

1007

result:

ok answer is '1007'

Test #125:

score: 0
Accepted
time: 34ms
memory: 46156kb

input:

1006 300000
1 2
1 3
1 6
1 10
1 14
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 26
1 27
1 29
1 30
1 31
1 33
1 35
1 36
1 39
1 40
1 42
1 43
1 46
1 48
1 52
1 53
1 54
1 56
1 59
1 60
1 63
1 65
1 66
1 70
1 71
1 73
1 80
1 81
1 83
1 85
1 87
1 91
1 92
1 93
1 96
1 99
1 103
1 106
1 108
1 109
1 110
1 115
1 117...

output:

1008

result:

ok answer is '1008'

Test #126:

score: 0
Accepted
time: 22ms
memory: 46664kb

input:

1007 300000
1 2
1 3
1 4
1 5
1 6
1 8
1 9
1 11
1 12
1 14
1 15
1 17
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 28
1 29
1 30
1 32
1 33
1 34
1 36
1 42
1 45
1 47
1 49
1 50
1 51
1 52
1 53
1 55
1 56
1 57
1 58
1 60
1 65
1 67
1 68
1 69
1 70
1 71
1 72
1 73
1 75
1 77
1 80
1 82
1 84
1 87
1 88
1 89
1 91
1 94
1 97
...

output:

1009

result:

ok answer is '1009'

Test #127:

score: 0
Accepted
time: 35ms
memory: 47412kb

input:

1008 300000
1 2
1 3
1 5
1 6
1 7
1 9
1 10
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 20
1 23
1 24
1 25
1 26
1 27
1 28
1 30
1 33
1 36
1 37
1 38
1 40
1 41
1 42
1 43
1 47
1 48
1 49
1 50
1 53
1 54
1 55
1 56
1 58
1 59
1 61
1 64
1 65
1 66
1 67
1 68
1 69
1 70
1 71
1 73
1 74
1 76
1 77
1 78
1 79
1 81
1 83
1 84
1 86...

output:

1010

result:

ok answer is '1010'

Test #128:

score: 0
Accepted
time: 28ms
memory: 47276kb

input:

1009 300000
1 2
1 3
1 4
1 6
1 8
1 9
1 11
1 13
1 15
1 16
1 17
1 19
1 20
1 22
1 24
1 25
1 26
1 27
1 28
1 32
1 33
1 34
1 35
1 37
1 42
1 43
1 44
1 45
1 47
1 48
1 50
1 51
1 52
1 54
1 55
1 56
1 58
1 59
1 62
1 64
1 66
1 67
1 71
1 72
1 74
1 75
1 77
1 78
1 79
1 80
1 81
1 82
1 86
1 87
1 90
1 91
1 92
1 93
1 94...

output:

1011

result:

ok answer is '1011'