QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#780408#1195. One-Way ConveyorsvwxyzAC ✓440ms35776kbPython317.8kb2024-11-25 10:46:352024-11-25 10:46:42

Judging History

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

  • [2024-11-25 10:46:42]
  • 评测
  • 测评结果:AC
  • 用时:440ms
  • 内存:35776kb
  • [2024-11-25 10:46:35]
  • 提交

answer

class Graph:
    def __init__(self,V,edges=None,graph=None,directed=False,weighted=False,inf=float("inf")):
        self.V=V
        self.directed=directed
        self.weighted=weighted
        self.inf=inf
        if graph!=None:
            self.graph=graph
            """
            self.edges=[]
            for i in range(self.V):
                if self.weighted:
                    for j,d in self.graph[i]:
                        if self.directed or not self.directed and i<=j:
                            self.edges.append((i,j,d))
                else:
                    for j in self.graph[i]:
                        if self.directed or not self.directed and i<=j:
                            self.edges.append((i,j))
            """
        else:
            self.edges=edges
            self.graph=[[] for i in range(self.V)]
            if weighted:
                for i,j,d in self.edges:
                    self.graph[i].append((j,d))
                    if not self.directed:
                        self.graph[j].append((i,d))
            else:
                for i,j in self.edges:
                    self.graph[i].append(j)
                    if not self.directed:
                        self.graph[j].append(i)

    def SIV_DFS(self,s,bipartite_graph=False,cycle_detection=False,directed_acyclic=False,euler_tour=False,linked_components=False,lowlink=False,parents=False,postorder=False,preorder=False,subtree_size=False,topological_sort=False,unweighted_dist=False,weighted_dist=False):
        seen=[False]*self.V
        finished=[False]*self.V
        if directed_acyclic or cycle_detection or topological_sort:
            dag=True
        if euler_tour:
            et=[]
        if linked_components:
            lc=[]
        if lowlink:
            order=[None]*self.V
            ll=[None]*self.V
            idx=0
        if parents or cycle_detection or lowlink or subtree_size:
            ps=[None]*self.V
        if postorder or topological_sort:
            post=[]
        if preorder:
            pre=[]
        if subtree_size:
            ss=[1]*self.V
        if unweighted_dist or bipartite_graph:
            uwd=[self.inf]*self.V
            uwd[s]=0
        if weighted_dist:
            wd=[self.inf]*self.V
            wd[s]=0
        stack=[(s,0)] if self.weighted else [s]
        while stack:
            if self.weighted:
                x,d=stack.pop()
            else:
                x=stack.pop()
            if not seen[x]:
                seen[x]=True
                stack.append((x,d) if self.weighted else x)
                if euler_tour:
                    et.append(x)
                if linked_components:
                    lc.append(x)
                if lowlink:
                    order[x]=idx
                    ll[x]=idx
                    idx+=1
                if preorder:
                    pre.append(x)
                for y in self.graph[x]:
                    if self.weighted:
                        y,d=y
                    if not seen[y]:
                        stack.append((y,d) if self.weighted else y)
                        if parents or cycle_detection or lowlink or subtree_size:
                            ps[y]=x
                        if unweighted_dist or bipartite_graph:
                            uwd[y]=uwd[x]+1
                        if weighted_dist:
                            wd[y]=wd[x]+d
                    elif not finished[y]:
                        if (directed_acyclic or cycle_detection or topological_sort) and dag:
                            dag=False
                            if cycle_detection:
                                cd=(y,x)
            elif not finished[x]:
                finished[x]=True
                if euler_tour:
                    et.append(~x)
                if lowlink:
                    bl=True
                    for y in self.graph[x]:
                        if self.weighted:
                            y,d=y
                        if ps[x]==y and bl:
                            bl=False
                            continue
                        ll[x]=min(ll[x],order[y])
                    if x!=s:
                        ll[ps[x]]=min(ll[ps[x]],ll[x])
                if postorder or topological_sort:
                    post.append(x)
                if subtree_size:
                    for y in self.graph[x]:
                        if self.weighted:
                            y,d=y
                        if y==ps[x]:
                            continue
                        ss[x]+=ss[y]
        if bipartite_graph:
            bg=[[],[]]
            for tpl in self.edges:
                x,y=tpl[:2] if self.weighted else tpl
                if uwd[x]==self.inf or uwd[y]==self.inf:
                    continue
                if not uwd[x]%2^uwd[y]%2:
                    bg=False
                    break
            else:
                for x in range(self.V):
                    if uwd[x]==self.inf:
                        continue
                    bg[uwd[x]%2].append(x)
        retu=()
        if bipartite_graph:
            retu+=(bg,)
        if cycle_detection:
            if dag:
                cd=[]
            else:
                y,x=cd
                cd=self.Route_Restoration(y,x,ps)
            retu+=(cd,)
        if directed_acyclic:
            retu+=(dag,)
        if euler_tour:
            retu+=(et,)
        if linked_components:
            retu+=(lc,)
        if lowlink:
            retu=(ll,)
        if parents:
            retu+=(ps,)
        if postorder:
            retu+=(post,)
        if preorder:
            retu+=(pre,)
        if subtree_size:
            retu+=(ss,)
        if topological_sort:
            if dag:
                tp_sort=post[::-1]
            else:
                tp_sort=[]
            retu+=(tp_sort,)
        if unweighted_dist:
            retu+=(uwd,)
        if weighted_dist:
            retu+=(wd,)
        if len(retu)==1:
            retu=retu[0]
        return retu

    def MIV_DFS(self,initial_vertices=None,bipartite_graph=False,cycle_detection=False,directed_acyclic=False,euler_tour=False,linked_components=False,lowlink=False,parents=False,postorder=False,preorder=False,subtree_size=False,topological_sort=False,unweighted_dist=False,weighted_dist=False):
        if initial_vertices==None:
            initial_vertices=[s for s in range(self.V)]
        seen=[False]*self.V
        finished=[False]*self.V
        if bipartite_graph:
            bg=[None]*self.V
            cnt=-1
        if directed_acyclic or cycle_detection or topological_sort:
            dag=True
        if euler_tour:
            et=[]
        if linked_components:
            lc=[]
        if lowlink:
            order=[None]*self.V
            ll=[None]*self.V
            idx=0
        if parents or cycle_detection or lowlink or subtree_size:
            ps=[None]*self.V
        if postorder or topological_sort:
            post=[]
        if preorder:
            pre=[]
        if subtree_size:
            ss=[1]*self.V
        if bipartite_graph or unweighted_dist:
            uwd=[self.inf]*self.V
        if weighted_dist:
            wd=[self.inf]*self.V
        for s in initial_vertices:
            if seen[s]:
                continue
            if bipartite_graph:
                cnt+=1
                bg[s]=(cnt,0)
            if linked_components:
                lc.append([])
            if bipartite_graph or unweighted_dist:
                uwd[s]=0
            if weighted_dist:
                wd[s]=0
            stack=[(s,0)] if self.weighted else [s]
            while stack:
                if self.weighted:
                    x,d=stack.pop()
                else:
                    x=stack.pop()
                if not seen[x]:
                    seen[x]=True
                    stack.append((x,d) if self.weighted else x)
                    if euler_tour:
                        et.append(x)
                    if linked_components:
                        lc[-1].append(x)
                    if lowlink:
                        order[x]=idx
                        ll[x]=idx
                        idx+=1
                    if preorder:
                        pre.append(x)
                    for y in self.graph[x]:
                        if self.weighted:
                            y,d=y
                        if not seen[y]:
                            stack.append((y,d) if self.weighted else y)
                            if bipartite_graph:
                                bg[y]=(cnt,bg[x][1]^1)
                            if parents or cycle_detection or lowlink or subtree_size:
                                ps[y]=x
                            if unweighted_dist or bipartite_graph:
                                uwd[y]=uwd[x]+1
                            if weighted_dist:
                                wd[y]=wd[x]+d
                        elif not finished[y]:
                            if directed_acyclic and dag:
                                dag=False
                                if cycle_detection:
                                    cd=(y,x)
                elif not finished[x]:
                    finished[x]=True
                    if euler_tour:
                        et.append(~x)
                    if lowlink:
                        bl=True
                        for y in self.graph[x]:
                            if self.weighted:
                                y,d=y
                            if ps[x]==y and bl:
                                bl=False
                                continue
                            ll[x]=min(ll[x],order[y])
                        if x!=s:
                            ll[ps[x]]=min(ll[ps[x]],ll[x])
                    if postorder or topological_sort:
                        post.append(x)
                    if subtree_size:
                        for y in self.graph[x]:
                            if self.weighted:
                                y,d=y
                            if y==ps[x]:
                                continue
                            ss[x]+=ss[y]
        if bipartite_graph:
            bg_=bg
            bg=[[[],[]] for i in range(cnt+1)]
            for tpl in self.edges:
                i,j=tpl[:2] if self.weighted else tpl
                if not bg_[i][1]^bg_[j][1]:
                    bg[bg_[i][0]]=False
            for x in range(self.V):
                if bg[bg_[x][0]]:
                    bg[bg_[x][0]][bg_[x][1]].append(x)
        retu=()
        if bipartite_graph:
            retu+=(bg,)
        if cycle_detection:
            if dag:
                cd=[]
            else:
                y,x=cd
                cd=self.Route_Restoration(y,x,ps)
            retu+=(cd,)
        if directed_acyclic:
            retu+=(dag,)
        if euler_tour:
            retu+=(et,)
        if linked_components:
            retu+=(lc,)
        if lowlink:
            retu=(ll,)
        if parents:
            retu+=(ps,)
        if postorder:
            retu+=(post,)
        if preorder:
            retu+=(pre,)
        if subtree_size:
            retu+=(ss,)
        if topological_sort:
            if dag:
                tp_sort=post[::-1]
            else:
                tp_sort=[]
            retu+=(tp_sort,)
        if unweighted_dist:
            retu+=(uwd,)
        if weighted_dist:
            retu+=(wd,)
        if len(retu)==1:
            retu=retu[0]
        return retu

    def TECCD(self):
        lowlink,preorder=self.MIV_DFS(lowlink=True,preorder=True)
        order=[None]*self.V
        for x in range(self.V):
            order[preorder[x]]=x
        edges=[]
        for e in self.edges:
            if self.weighted:
                x,y,d=e
            else:
                x,y=e
            if order[x]>=lowlink[y] and order[y]>=lowlink[x]:
                edges.append((x,y))
        teccd=Graph(self.V,edges=edges).MIV_DFS(linked_components=True)
        return teccd

    def Build_LCA(self,s,segment_tree=False):
        self.lca_segment_tree=segment_tree
        if self.lca_segment_tree:
            self.lca_euler_tour,self.lca_parents,depth=self.SIV_DFS(s,euler_tour=True,parents=True,unweighted_dist=True)
            self.lca_dfs_in_index=[None]*self.V
            self.lca_dfs_out_index=[None]*self.V
            for i,x in enumerate(self.lca_euler_tour):
                if x>=0:
                    self.lca_dfs_in_index[x]=i
                else:
                    self.lca_dfs_out_index[~x]=i
            self.ST=Segment_Tree(2*self.V,lambda x,y:min(x,y),self.V)
            lst=[None]*(2*self.V)
            for i in range(2*self.V-1):
                if self.lca_euler_tour[i]>=0:
                    lst[i]=depth[self.lca_euler_tour[i]]
                else:
                    lst[i]=depth[self.lca_parents[~self.lca_euler_tour[i]]]
            lst[2*self.V-1]=-1
            self.ST.Build(lst)
        else:
            self.lca_parents,self.lca_depth=self.SIV_DFS(s,parents=True,unweighted_dist=True)
            self.lca_PD=Path_Doubling(self.V,self.lca_parents)
            self.lca_PD.Build_Next(self.V)

    def LCA(self,a,b):
        if self.lca_segment_tree:
            m=min(self.lca_dfs_in_index[a],self.lca_dfs_in_index[b])
            M=max(self.lca_dfs_in_index[a],self.lca_dfs_in_index[b])
            x=self.lca_euler_tour[self.ST.Fold_Index(m,M+1)]
            if x>=0:
                lca=x
            else:
                lca=self.lca_parents[~x]
        else:
            if self.lca_depth[a]>self.lca_depth[b]:
                a,b=b,a
            b=self.lca_PD.Permutation_Doubling(b,self.lca_depth[b]-self.lca_depth[a])
            if a!=b:
                for k in range(self.lca_PD.k-1,-1,-1):
                    if self.lca_PD.permutation_doubling[k][a]!=self.lca_PD.permutation_doubling[k][b]:
                        a,b=self.lca_PD.permutation_doubling[k][a],self.lca_PD.permutation_doubling[k][b]
                a,b=self.lca_PD.permutation_doubling[0][a],self.lca_PD.permutation_doubling[0][b]
            lca=a
        return lca

class Path_Doubling:
    def __init__(self,N,permutation,lst=None,f=None,e=None):
        self.N=N
        self.permutation=permutation
        self.lst=lst
        self.f=f
        self.e=e

    def Build_Next(self,K=None):
        if K==None:
            K=self.N
        self.k=K.bit_length()
        self.permutation_doubling=[[None]*self.N for k in range(self.k)]
        for n in range(self.N):
            self.permutation_doubling[0][n]=self.permutation[n]
        if self.lst!=None:
            self.doubling=[[None]*self.N for k in range(self.k)]
            for n in range(self.N):
                self.doubling[0][n]=self.lst[n]
        for k in range(1,self.k):
            for n in range(self.N):
                if self.permutation_doubling[k-1][n]!=None:
                    self.permutation_doubling[k][n]=self.permutation_doubling[k-1][self.permutation_doubling[k-1][n]]
                    if self.f!=None:
                        self.doubling[k][n]=self.f(self.doubling[n][k-1],self.doubling[k-1][self.permutation_doubling[k-1][n]])

    def Permutation_Doubling(self,N,K):
        if K<0 or 1<<self.k<=K:
            return None
        for k in range(self.k):
            if K>>k&1 and N!=None:
                N=self.permutation_doubling[k][N]
        return N

    def Doubling(self,N,K):
        if K<0:
            return self.e
        retu=self.e
        for k in range(self.k):
            if K>>k&1:
                if self.permutation_doubling[k][N]==None:
                    return None
                retu=self.f(retu,self.doubling[k][N])
                N=self.permutation_doubling[k][N]
        return N,retu

    def Bisect(self,x,is_ok):
        if not is_ok(x):
            return -1,None
        K=0
        for k in range(self.k-1,-1,-1):
            if is_ok(self.permutation_doubling[k][x]):
                K|=1<<k
                x=self.permutation_doubling[k][x]
        return K,x

N,M=map(int,input().split())
edges=[]
for m in range(M):
    x,y=map(int,input().split())
    x-=1;y-=1
    edges.append((x,y))
G=Graph(N,edges=edges)
P=G.TECCD()
idx=[None]*N
for i,lst in enumerate(P):
    for x in lst:
        idx[x]=i
E=[]
for x,y in edges:
    if idx[x]!=idx[y]:
        E.append((idx[x],idx[y]))
le=len(P)
Tree=Graph(le,edges=E)
Tree.Build_LCA(0)
up=[0]*N
down=[0]*N
K=int(input())
for k in range(K):
    a,b=map(int,input().split())
    a-=1;b-=1
    a=idx[a]
    b=idx[b]
    if a!=b:
        lca=Tree.LCA(a,b)
        up[a]+=1
        up[lca]-=1
        down[b]+=1
        down[lca]-=1
Tree_parents,Tree_tour=Tree.SIV_DFS(0,parents=True,postorder=True)
for x in Tree_tour:
    if Tree_parents[x]!=None:
        up[Tree_parents[x]]+=up[x]
        down[Tree_parents[x]]+=down[x]
for x in range(1,N):
    if up[x] and down[x]:
        print("No")
        exit()
parents,tour=G.SIV_DFS(0,parents=True,preorder=True)
tour_idx=[None]*N
for i,x in enumerate(tour):
    tour_idx[x]=i
ans_lst=[]
for x,y in edges:
    if idx[x]==idx[y]:
        if parents[x]==y:
            ans_lst.append((y,x))
        elif parents[y]==x:
            ans_lst.append((x,y))
        elif tour_idx[x]<tour_idx[y]:
            ans_lst.append((y,x))
        else:
            ans_lst.append((x,y))
    else:
        if Tree_parents[idx[x]]==idx[y]:
            x,y=y,x
        if up[idx[y]]:
            ans_lst.append((y,x))
        else:
            ans_lst.append((x,y))
print("Yes")
for x,y in ans_lst:
    print(x+1,y+1)

詳細信息

Test #1:

score: 100
Accepted
time: 10ms
memory: 10620kb

input:

3 2
1 2
2 3
3
1 2
1 3
2 3

output:

Yes
1 2
2 3

result:

ok OK!

Test #2:

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

input:

3 2
1 2
2 3
3
1 2
1 3
3 2

output:

No

result:

ok OK!

Test #3:

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

input:

4 4
1 2
1 3
1 4
2 3
7
1 2
1 3
1 4
2 1
2 3
3 1
3 2

output:

Yes
2 1
1 3
1 4
3 2

result:

ok OK!

Test #4:

score: 0
Accepted
time: 161ms
memory: 24964kb

input:

9990 47670
134 2450
4227 9100
1861 9948
120 8957
1161 4767
76 1714
5207 5838
2726 8974
2489 8619
2379 4933
3675 9554
344 3215
1654 6168
5630 6614
3247 5202
4456 5373
4380 6605
2626 4064
2194 6332
2749 9719
360 5059
7967 8835
5433 6494
497 6638
5945 9063
7576 7879
3550 4107
83 2891
3107 6917
2089 689...

output:

No

result:

ok OK!

Test #5:

score: 0
Accepted
time: 167ms
memory: 14752kb

input:

3219 13421
762 2133
1106 2880
2287 2476
313 992
741 1903
811 2050
1468 2184
3031 3037
403 1855
1060 1415
1792 2804
772 2956
140 2281
808 1953
895 1731
1217 1551
1264 1885
749 1082
1564 2824
1549 1741
1966 2730
112 2825
158 2625
2128 2917
128 3032
644 3194
1634 2743
1545 1961
2402 2680
2663 2814
1040...

output:

No

result:

ok OK!

Test #6:

score: 0
Accepted
time: 94ms
memory: 17372kb

input:

8013 18891
6127 6374
3969 4617
215 2699
268 6282
167 5415
1318 6256
3994 6192
4325 7186
1785 4188
6570 7153
772 5901
9 5190
873 6509
161 7476
2960 2966
4598 7170
1157 3798
758 4508
1446 5205
445 5989
686 5479
669 4711
6254 6860
1722 7020
463 3494
5063 7309
2231 6762
1208 4304
4789 5081
3925 6248
107...

output:

No

result:

ok OK!

Test #7:

score: 0
Accepted
time: 219ms
memory: 24680kb

input:

9968 46595
3655 5544
5747 9340
6020 9528
5789 9882
4609 8832
1969 5167
2610 8012
324 9387
694 3647
3667 8483
4202 4963
2643 8104
1139 9679
1407 7022
9031 9944
5183 8744
3341 3858
326 2610
414 1317
657 7942
4702 5671
2072 3200
3074 3597
26 3728
288 7757
144 9580
1374 2065
2683 8068
1341 6526
2140 257...

output:

Yes
3655 5544
5747 9340
6020 9528
9882 5789
8832 4609
5167 1969
8012 2610
9387 324
3647 694
3667 8483
4202 4963
2643 8104
1139 9679
7022 1407
9031 9944
5183 8744
3341 3858
326 2610
1317 414
657 7942
5671 4702
3200 2072
3597 3074
26 3728
288 7757
9580 144
1374 2065
2683 8068
1341 6526
2140 2570
698 1...

result:

ok OK!

Test #8:

score: 0
Accepted
time: 24ms
memory: 11148kb

input:

273 1157
172 181
175 181
180 224
42 164
196 252
126 183
32 225
44 138
55 203
71 193
97 180
190 217
229 259
49 221
53 71
32 125
122 168
98 147
209 261
6 245
36 214
134 253
205 223
25 168
167 236
35 164
71 87
7 170
13 36
116 132
147 165
167 254
122 179
83 97
78 172
107 127
12 59
15 242
48 201
225 269
...

output:

Yes
181 172
181 175
180 224
164 42
196 252
183 126
225 32
138 44
203 55
71 193
180 97
217 190
229 259
221 49
71 53
32 125
122 168
98 147
261 209
6 245
214 36
253 134
205 223
25 168
167 236
35 164
87 71
7 170
13 36
116 132
165 147
167 254
179 122
83 97
78 172
107 127
59 12
15 242
201 48
225 269
179 1...

result:

ok OK!

Test #9:

score: 0
Accepted
time: 60ms
memory: 16292kb

input:

7563 11902
923 6491
841 5346
4236 6858
382 7479
3348 6098
1908 5546
564 6550
4767 6536
5181 7272
979 4282
3250 4044
4296 4678
57 5608
1172 3104
849 4089
1936 2337
4111 5978
2091 4188
5286 5313
3866 4426
6111 6585
970 2002
1477 2355
3425 4650
2892 2912
2554 6195
2830 6120
384 3107
4271 5234
629 1319
...

output:

Yes
923 6491
5346 841
4236 6858
382 7479
3348 6098
5546 1908
564 6550
6536 4767
7272 5181
979 4282
3250 4044
4296 4678
57 5608
1172 3104
849 4089
2337 1936
5978 4111
4188 2091
5313 5286
4426 3866
6585 6111
2002 970
2355 1477
3425 4650
2912 2892
6195 2554
6120 2830
384 3107
5234 4271
1319 629
6565 47...

result:

ok OK!

Test #10:

score: 0
Accepted
time: 243ms
memory: 17292kb

input:

8925 13782
1859 2185
5433 7565
6107 7778
1699 5422
2247 5228
3048 6500
996 8342
1063 7629
5648 6266
1827 3051
761 1875
8268 8811
1770 5354
400 8680
1877 7156
2037 3933
1393 6095
904 3022
5109 8078
6775 8153
1612 4288
484 1918
4339 4349
3907 6395
2832 5106
4928 6441
1572 6969
1255 4539
5433 8335
1760...

output:

No

result:

ok OK!

Test #11:

score: 0
Accepted
time: 153ms
memory: 11164kb

input:

492 1768
205 271
267 353
385 421
212 383
87 98
294 385
9 153
166 245
7 55
58 320
409 449
223 423
19 389
90 245
105 392
290 317
121 252
245 317
384 395
3 419
62 254
103 157
295 452
335 358
125 491
14 399
181 257
127 226
334 374
88 207
111 345
147 177
45 405
276 327
127 338
4 241
26 380
54 228
127 235...

output:

No

result:

ok OK!

Test #12:

score: 0
Accepted
time: 183ms
memory: 13540kb

input:

4057 7108
1230 1841
801 3026
1133 2581
319 2719
2986 3702
582 2859
1744 2119
1157 2900
397 3175
2015 3372
2757 3841
1666 1982
988 2371
644 3898
1645 2196
72 2485
689 3637
10 131
170 3108
2987 3354
1666 3705
670 2169
3420 4015
1161 2926
186 1468
667 2299
2639 4009
1221 3004
3955 3961
1816 3089
662 23...

output:

No

result:

ok OK!

Test #13:

score: 0
Accepted
time: 77ms
memory: 17560kb

input:

8853 14008
985 5627
4689 8520
1797 2206
5193 6884
688 7678
3401 8581
5909 8027
5687 7559
3985 6113
179 5352
304 7414
1703 6835
4757 5769
4581 7750
4282 7835
1759 7538
1712 4620
473 6863
1830 8262
3885 4152
459 5868
2777 6144
6716 7265
3103 6296
4516 7641
555 829
5696 6672
2468 8016
1542 4604
5455 69...

output:

Yes
985 5627
8520 4689
1797 2206
5193 6884
7678 688
8581 3401
5909 8027
7559 5687
3985 6113
5352 179
7414 304
1703 6835
4757 5769
4581 7750
4282 7835
1759 7538
1712 4620
6863 473
8262 1830
4152 3885
5868 459
2777 6144
6716 7265
3103 6296
7641 4516
555 829
6672 5696
2468 8016
1542 4604
5455 6976
6907...

result:

ok OK!

Test #14:

score: 0
Accepted
time: 140ms
memory: 20388kb

input:

8426 29348
2004 5877
6189 7733
3413 4009
5325 8070
6622 8102
1108 4909
3956 5682
1299 2475
6692 7065
1960 3899
2353 2830
1694 8139
4008 4939
1660 1913
460 5353
5184 7672
5982 7533
5048 6901
35 1974
2595 6944
3646 5337
5299 6012
1559 1914
658 6185
693 4233
7688 7702
1332 8407
2392 6380
670 7007
845 1...

output:

Yes
5877 2004
7733 6189
4009 3413
5325 8070
6622 8102
4909 1108
3956 5682
2475 1299
6692 7065
1960 3899
2830 2353
1694 8139
4939 4008
1660 1913
5353 460
5184 7672
5982 7533
6901 5048
1974 35
6944 2595
3646 5337
6012 5299
1559 1914
658 6185
4233 693
7688 7702
8407 1332
6380 2392
670 7007
845 1675
122...

result:

ok OK!

Test #15:

score: 0
Accepted
time: 60ms
memory: 14988kb

input:

3999 12704
211 3682
1145 2790
1018 3100
2567 3422
1024 3401
1536 3565
657 3681
1021 3089
1565 3368
696 2032
866 1326
1440 3867
607 3929
1580 3088
1270 3253
1085 2590
877 2611
540 2119
2343 2898
403 2358
901 1356
1651 2914
901 2236
2883 3721
741 859
2172 2975
451 1422
663 1082
56 1277
956 2839
1189 2...

output:

Yes
3682 211
1145 2790
3100 1018
2567 3422
3401 1024
1536 3565
3681 657
1021 3089
3368 1565
696 2032
866 1326
1440 3867
607 3929
1580 3088
1270 3253
1085 2590
877 2611
2119 540
2343 2898
2358 403
1356 901
1651 2914
2236 901
3721 2883
859 741
2172 2975
451 1422
663 1082
56 1277
956 2839
2987 1189
230...

result:

ok OK!

Test #16:

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

input:

10000 70476
2931 5105
4305 5213
5236 6651
2684 5925
3273 7088
7514 7628
3463 3517
2752 7151
763 1751
3603 7655
6963 8831
7886 8872
1443 5160
5771 8328
5164 7431
3903 6396
6633 7356
5312 8917
3950 9909
4610 9606
214 2538
3404 6702
2404 9265
1385 7715
1093 3309
1230 8937
2818 9891
2281 3294
2789 5594
...

output:

Yes
2931 5105
5213 4305
5236 6651
5925 2684
3273 7088
7514 7628
3517 3463
2752 7151
1751 763
7655 3603
8831 6963
7886 8872
1443 5160
8328 5771
5164 7431
6396 3903
7356 6633
8917 5312
9909 3950
9606 4610
214 2538
3404 6702
9265 2404
7715 1385
1093 3309
8937 1230
2818 9891
2281 3294
5594 2789
3579 782...

result:

ok OK!

Test #17:

score: 0
Accepted
time: 382ms
memory: 35776kb

input:

8056 89618
3568 7248
5153 6239
1935 4969
53 3914
6016 7700
912 4039
3518 7847
2444 4847
529 3953
883 1516
2302 8005
92 6599
1252 6829
967 1646
435 3489
109 7308
3393 5250
127 1868
2498 7444
2625 6290
3238 7684
4989 5718
1878 6411
3115 6232
3487 5760
7451 7614
4070 6102
3106 7521
444 6947
1847 2470
3...

output:

Yes
7248 3568
6239 5153
4969 1935
53 3914
6016 7700
912 4039
3518 7847
2444 4847
529 3953
1516 883
8005 2302
6599 92
6829 1252
967 1646
3489 435
7308 109
5250 3393
127 1868
7444 2498
6290 2625
3238 7684
4989 5718
6411 1878
3115 6232
3487 5760
7451 7614
6102 4070
3106 7521
444 6947
1847 2470
5608 335...

result:

ok OK!

Test #18:

score: 0
Accepted
time: 222ms
memory: 25352kb

input:

6678 50741
2438 2575
4259 6116
3096 3605
309 1672
3666 3689
6368 6420
2645 3109
514 2946
1762 5892
3302 4748
1714 3930
416 5773
5881 6344
132 3287
106 1385
1192 6202
1871 5614
1741 2037
85 2227
2202 5460
176 1178
3064 6310
3547 4129
2790 3741
4650 5146
988 4177
1412 2752
3455 5618
1949 2068
632 2863...

output:

Yes
2438 2575
6116 4259
3605 3096
309 1672
3666 3689
6420 6368
2645 3109
2946 514
5892 1762
3302 4748
3930 1714
416 5773
5881 6344
3287 132
1385 106
6202 1192
1871 5614
2037 1741
85 2227
2202 5460
1178 176
6310 3064
4129 3547
2790 3741
5146 4650
4177 988
1412 2752
3455 5618
1949 2068
2863 632
5514 3...

result:

ok OK!

Test #19:

score: 0
Accepted
time: 92ms
memory: 12592kb

input:

1534 6122
382 786
741 744
234 331
39 1179
235 660
910 1480
511 785
900 1191
486 686
1096 1421
94 192
92 1122
729 1447
407 1259
565 759
1131 1384
624 857
178 640
748 860
237 1045
241 485
727 1341
88 1087
754 1440
515 1166
364 1047
956 1322
82 961
60 791
667 1161
198 526
885 938
331 1427
1038 1289
568...

output:

Yes
382 786
741 744
331 234
1179 39
235 660
910 1480
511 785
1191 900
686 486
1096 1421
94 192
1122 92
729 1447
1259 407
759 565
1384 1131
857 624
178 640
860 748
237 1045
241 485
727 1341
88 1087
1440 754
515 1166
1047 364
1322 956
82 961
791 60
667 1161
526 198
885 938
331 1427
1038 1289
568 835
1...

result:

ok OK!

Test #20:

score: 0
Accepted
time: 81ms
memory: 16152kb

input:

6200 15044
2947 5918
2354 5694
2338 3113
4427 4643
1244 2270
1077 2041
1472 2599
1601 3665
1774 5273
664 5573
1797 5265
1312 5196
4866 5803
1544 4331
594 5200
258 1331
1586 1711
1021 2593
307 2836
997 2904
2920 5815
2081 5780
2106 3971
2777 3758
2853 5717
366 985
2258 3592
2389 5933
2422 2843
2078 3...

output:

Yes
5918 2947
2354 5694
3113 2338
4643 4427
2270 1244
1077 2041
1472 2599
1601 3665
1774 5273
664 5573
1797 5265
5196 1312
5803 4866
4331 1544
594 5200
1331 258
1711 1586
2593 1021
2836 307
2904 997
2920 5815
2081 5780
3971 2106
2777 3758
2853 5717
985 366
3592 2258
5933 2389
2843 2422
2078 3178
547...

result:

ok OK!

Test #21:

score: 0
Accepted
time: 213ms
memory: 23748kb

input:

9961 42952
1145 3373
8143 8193
2128 9569
27 5554
144 4783
6315 9422
253 425
5852 6984
3179 3257
5068 7475
2326 5222
1909 5486
1956 8111
2685 9643
3760 6255
1019 5112
4414 4728
4741 8480
2976 7299
1837 4248
2212 4642
5344 9447
6452 9074
4917 9481
132 8681
1562 2225
4077 9137
2151 8626
3710 4808
2012 ...

output:

No

result:

ok OK!

Test #22:

score: 0
Accepted
time: 248ms
memory: 14040kb

input:

4640 8539
1190 2891
166 2489
446 1583
1695 3140
788 2314
2554 3511
798 3938
2209 4123
2021 3901
2404 3464
1569 2657
2290 4282
1548 3942
223 2867
1349 4270
1099 1939
764 868
563 2556
1947 2144
2065 4461
2154 3589
706 1097
3536 3738
310 1901
229 876
972 1320
600 3858
376 557
3049 3510
965 2779
790 158...

output:

No

result:

ok OK!

Test #23:

score: 0
Accepted
time: 70ms
memory: 10988kb

input:

545 835
50 267
333 542
96 160
12 68
266 441
20 222
330 417
408 541
204 453
196 298
72 393
170 328
445 509
231 444
196 526
136 233
97 377
20 400
438 489
97 253
195 359
53 190
137 252
53 373
27 268
18 185
17 91
224 504
407 468
23 80
35 538
171 510
202 343
165 258
445 537
179 393
79 394
359 438
329 399...

output:

No

result:

ok OK!

Test #24:

score: 0
Accepted
time: 74ms
memory: 17424kb

input:

8838 13732
7281 7530
5516 6730
1304 3568
6152 6340
1921 4022
6240 8808
3016 8378
1409 4656
1820 6098
1243 5707
4310 6149
5415 5990
810 7997
589 5582
2147 2526
4710 8109
2421 7006
1841 4073
1038 2335
373 5910
4242 6163
2958 5132
5156 6013
2231 6570
2638 6466
6643 7803
1880 7261
4144 5095
445 5262
199...

output:

Yes
7530 7281
5516 6730
3568 1304
6152 6340
4022 1921
8808 6240
3016 8378
1409 4656
6098 1820
5707 1243
4310 6149
5990 5415
7997 810
5582 589
2147 2526
8109 4710
2421 7006
1841 4073
2335 1038
5910 373
4242 6163
2958 5132
5156 6013
2231 6570
2638 6466
7803 6643
1880 7261
5095 4144
5262 445
2483 1994
...

result:

ok OK!

Test #25:

score: 0
Accepted
time: 81ms
memory: 17432kb

input:

8164 13019
935 2152
2238 5638
1279 5799
2558 7242
6570 7682
119 4527
2379 2905
2683 3531
2117 6717
134 4841
4924 5705
2015 6312
3038 7637
1473 7086
4513 8022
2442 7546
2704 3406
2931 6125
71 897
1442 5794
4550 6416
5091 6516
221 1194
4312 4879
1126 6975
3975 5369
1376 4455
572 1816
3490 8134
2387 60...

output:

Yes
935 2152
2238 5638
5799 1279
2558 7242
7682 6570
119 4527
2379 2905
2683 3531
6717 2117
4841 134
5705 4924
6312 2015
7637 3038
1473 7086
8022 4513
2442 7546
3406 2704
6125 2931
897 71
5794 1442
6416 4550
6516 5091
1194 221
4312 4879
6975 1126
5369 3975
4455 1376
572 1816
8134 3490
6015 2387
3312...

result:

ok OK!

Test #26:

score: 0
Accepted
time: 60ms
memory: 15644kb

input:

6443 10243
484 1945
5630 5799
4552 6202
4033 5271
3357 4683
974 5909
1310 5607
3503 4273
721 4320
4372 4711
3818 4025
1821 2782
8 5408
1867 5572
142 1753
2315 4948
1185 5047
4940 5233
1238 5996
1309 3483
3283 3882
1366 4025
4019 5049
268 4547
483 6111
453 766
5398 5959
3033 5477
58 1950
3325 3763
25...

output:

Yes
484 1945
5799 5630
6202 4552
4033 5271
3357 4683
5909 974
5607 1310
4273 3503
4320 721
4711 4372
3818 4025
2782 1821
8 5408
5572 1867
142 1753
2315 4948
1185 5047
5233 4940
1238 5996
1309 3483
3882 3283
4025 1366
5049 4019
4547 268
6111 483
453 766
5398 5959
5477 3033
58 1950
3763 3325
2527 3414...

result:

ok OK!

Test #27:

score: 0
Accepted
time: 191ms
memory: 18128kb

input:

9364 20205
2847 3723
2332 6026
1231 2542
897 6496
4290 5694
2334 3791
7901 8176
2407 7884
1890 3564
686 2477
1032 3859
8283 8745
105 7215
1788 4223
674 6862
1512 8322
1482 6302
3644 5189
6416 7325
4110 8497
5355 7339
278 3199
747 1241
3970 7568
989 5093
958 6388
4675 5304
7904 9129
6164 9019
4220 49...

output:

No

result:

ok OK!

Test #28:

score: 0
Accepted
time: 107ms
memory: 11060kb

input:

640 947
179 310
246 549
57 559
444 528
246 510
71 283
363 464
117 464
306 309
444 478
52 215
114 377
176 246
420 559
18 283
283 564
143 310
552 619
283 495
415 419
283 460
82 280
17 135
394 465
82 433
3 444
211 310
195 591
493 630
125 253
102 521
132 172
102 215
215 431
92 126
168 362
386 559
246 43...

output:

No

result:

ok OK!

Test #29:

score: 0
Accepted
time: 203ms
memory: 14176kb

input:

5101 7617
3179 4473
2381 4406
264 1538
1496 3356
3655 4392
3435 5036
3010 4599
1025 4272
4073 4392
2131 4112
230 2725
3379 4571
77 2926
2458 3004
243 4934
307 1850
3549 3775
728 742
1105 2901
2099 4986
2157 4811
426 895
2226 4645
651 2781
804 3052
561 4392
474 3227
22 3256
2484 3740
2425 3608
630 31...

output:

No

result:

ok OK!

Test #30:

score: 0
Accepted
time: 98ms
memory: 19376kb

input:

9495 22437
659 2686
189 3206
2686 5140
4350 8162
1248 7355
1527 7151
509 9467
3604 6563
1451 7134
2933 9085
2392 4791
4809 6818
1455 6065
7790 8524
6435 8291
4629 4987
2212 3016
5880 7328
565 7287
2416 5748
3233 4845
2791 5561
4030 7690
4651 4998
33 9086
4469 9102
345 2713
838 7751
814 9298
2077 375...

output:

Yes
659 2686
189 3206
5140 2686
4350 8162
1248 7355
7151 1527
9467 509
6563 3604
1451 7134
9085 2933
4791 2392
6818 4809
1455 6065
7790 8524
6435 8291
4987 4629
2212 3016
7328 5880
565 7287
5748 2416
3233 4845
2791 5561
7690 4030
4651 4998
9086 33
4469 9102
2713 345
7751 838
9298 814
2077 3754
9381 ...

result:

ok OK!

Test #31:

score: 0
Accepted
time: 25ms
memory: 11596kb

input:

672 2622
233 647
531 672
167 301
163 204
11 18
2 102
56 488
29 168
13 506
351 531
69 386
389 643
105 335
43 267
126 536
119 284
172 182
42 165
52 392
2 257
219 322
220 288
251 615
308 665
319 347
339 607
569 657
306 554
369 383
160 332
198 465
170 662
145 177
500 654
270 408
333 537
512 528
386 655
...

output:

Yes
647 233
531 672
301 167
204 163
18 11
2 102
488 56
168 29
506 13
531 351
386 69
389 643
105 335
43 267
126 536
119 284
182 172
165 42
392 52
2 257
322 219
220 288
615 251
665 308
319 347
339 607
569 657
306 554
383 369
332 160
198 465
170 662
177 145
500 654
408 270
537 333
512 528
386 655
475 2...

result:

ok OK!

Test #32:

score: 0
Accepted
time: 84ms
memory: 17056kb

input:

6725 18041
2450 4115
482 1547
4104 5536
4008 4678
3322 4911
111 2471
2065 4707
341 705
1500 5852
165 1828
2162 3369
884 2056
4207 5466
1538 6604
2405 5901
636 2265
958 6475
1973 2885
1074 6131
2974 5222
3393 4143
4432 4703
1753 2662
1389 5845
6096 6685
1025 6696
2743 4555
2064 5831
1593 5692
3715 59...

output:

Yes
4115 2450
482 1547
4104 5536
4678 4008
4911 3322
2471 111
4707 2065
341 705
1500 5852
165 1828
2162 3369
884 2056
5466 4207
6604 1538
2405 5901
636 2265
958 6475
1973 2885
1074 6131
5222 2974
3393 4143
4703 4432
1753 2662
5845 1389
6685 6096
1025 6696
2743 4555
5831 2064
5692 1593
5925 3715
6186...

result:

ok OK!

Test #33:

score: 0
Accepted
time: 171ms
memory: 18180kb

input:

10000 9999
4827 6339
476 2906
3272 9823
3823 7017
309 2978
794 3837
437 7624
7644 7787
1441 4639
3346 4707
3616 7657
2066 5490
1040 7588
2420 4454
3507 4114
764 4601
2195 6334
489 7341
3084 3096
1695 7914
361 9696
3285 3525
4495 6868
349 2044
1374 9003
3734 9160
1885 2149
416 6752
6600 9719
8626 884...

output:

No

result:

ok OK!

Test #34:

score: 0
Accepted
time: 319ms
memory: 15360kb

input:

6451 6450
1410 5169
2175 4341
1056 2980
379 6419
3081 3174
334 3285
4938 5435
2917 4760
5160 6258
5541 6198
870 5260
1934 5630
1470 1812
2243 4554
3690 5325
82 5119
5303 5560
1680 2861
454 5334
158 5926
3318 4681
3753 5089
2519 4686
365 5021
1451 1896
1447 2946
3861 6022
4175 4542
1530 5759
1278 298...

output:

No

result:

ok OK!

Test #35:

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

input:

9380 9379
977 7363
5790 6220
1491 5068
3469 4382
4104 8306
787 1798
2000 5495
658 9342
3764 7860
3677 4821
3193 6786
5620 7850
9374 9376
939 7480
3855 4360
2866 7059
342 6496
7540 8966
2287 9271
1229 1700
4959 6423
2177 8496
153 4908
2267 8715
7417 7495
1523 5532
2612 8499
1746 3880
6824 7171
5560 6...

output:

No

result:

ok OK!

Test #36:

score: 0
Accepted
time: 77ms
memory: 19172kb

input:

10000 9999
2414 5520
7317 8346
2800 4741
1728 3389
412 6320
5689 9612
3614 9580
5427 7278
6903 9593
535 1750
1733 3512
3598 3886
1214 4844
1852 5927
2351 9269
8277 9851
4262 7030
130 4207
2874 3419
3564 4925
3931 7858
8401 8837
64 195
5201 9993
3628 6722
2743 5915
1536 6617
6383 6943
1190 6904
8273 ...

output:

Yes
2414 5520
8346 7317
4741 2800
3389 1728
412 6320
9612 5689
9580 3614
5427 7278
6903 9593
1750 535
3512 1733
3886 3598
4844 1214
5927 1852
9269 2351
9851 8277
7030 4262
130 4207
2874 3419
3564 4925
7858 3931
8837 8401
64 195
5201 9993
3628 6722
2743 5915
6617 1536
6383 6943
6904 1190
8916 8273
17...

result:

ok OK!

Test #37:

score: 0
Accepted
time: 23ms
memory: 12292kb

input:

1888 1887
1355 1401
608 1574
806 1115
131 1880
857 1026
268 1050
20 217
1063 1526
797 1763
1423 1731
329 1391
421 631
131 1492
705 737
163 168
453 836
914 1567
677 1831
289 1562
1001 1828
657 1723
596 1373
1312 1473
19 1738
231 771
376 1098
293 1232
1389 1536
169 244
784 1353
967 1564
477 1863
1808 ...

output:

Yes
1401 1355
608 1574
806 1115
131 1880
857 1026
268 1050
20 217
1526 1063
1763 797
1731 1423
1391 329
421 631
131 1492
705 737
163 168
453 836
1567 914
1831 677
1562 289
1828 1001
657 1723
596 1373
1473 1312
19 1738
231 771
376 1098
1232 293
1536 1389
169 244
1353 784
1564 967
477 1863
1808 1872
1...

result:

ok OK!

Test #38:

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

input:

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

output:

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

result:

ok OK!

Test #39:

score: 0
Accepted
time: 144ms
memory: 16008kb

input:

10000 10000
628 9691
2470 3054
461 8198
1859 5407
674 2080
3141 5461
1633 7779
1276 1404
3532 5399
428 1140
1532 5434
4415 9126
3176 7371
213 7531
8427 9657
3994 9806
1778 2362
1829 4715
5056 8675
5477 7966
471 2420
2098 5548
3080 9573
7529 8371
6669 7586
277 4470
2769 2786
6662 6936
2839 6913
1461 ...

output:

Yes
9691 628
2470 3054
8198 461
1859 5407
674 2080
3141 5461
7779 1633
1404 1276
3532 5399
428 1140
1532 5434
4415 9126
7371 3176
7531 213
8427 9657
9806 3994
1778 2362
4715 1829
5056 8675
5477 7966
2420 471
2098 5548
9573 3080
7529 8371
7586 6669
4470 277
2786 2769
6936 6662
2839 6913
8128 1461
385...

result:

ok OK!

Test #40:

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

input:

4992 4992
918 4909
2359 2915
1144 4961
3134 3302
4164 4691
1707 1816
2129 2417
179 2813
3618 4639
3082 4257
1487 2477
560 4202
1940 3672
1214 3125
1365 2202
1815 2008
740 2200
235 1411
2960 4801
2879 3769
1256 4334
406 3790
273 811
897 1960
1398 2592
2128 4115
563 3729
1497 3509
723 727
985 4320
286...

output:

Yes
4909 918
2359 2915
1144 4961
3302 3134
4691 4164
1816 1707
2417 2129
2813 179
3618 4639
4257 3082
2477 1487
560 4202
1940 3672
3125 1214
2202 1365
2008 1815
2200 740
235 1411
2960 4801
3769 2879
1256 4334
406 3790
273 811
1960 897
2592 1398
2128 4115
3729 563
3509 1497
723 727
985 4320
4149 2864...

result:

ok OK!

Test #41:

score: 0
Accepted
time: 66ms
memory: 12996kb

input:

4619 4619
2943 2996
1204 2384
917 3819
629 2055
4088 4442
3851 4232
1916 3632
2228 4524
2336 2355
310 2728
1242 4010
1158 3656
596 4523
1793 1864
303 835
368 2353
3764 3991
349 1366
1339 2854
1190 3830
1700 3136
3298 3510
789 3898
3642 3832
25 3672
2922 2937
594 942
716 3116
2903 3174
12 1491
201 22...

output:

Yes
2943 2996
1204 2384
3819 917
629 2055
4088 4442
4232 3851
1916 3632
2228 4524
2355 2336
2728 310
4010 1242
1158 3656
4523 596
1793 1864
835 303
368 2353
3991 3764
349 1366
1339 2854
3830 1190
1700 3136
3298 3510
3898 789
3832 3642
3672 25
2937 2922
942 594
3116 716
3174 2903
1491 12
2270 201
388...

result:

ok OK!

Test #42:

score: 0
Accepted
time: 130ms
memory: 17476kb

input:

9999 13331
449 7258
3047 8308
2716 4492
2065 2191
190 2301
1556 6198
2754 6965
3398 3638
2746 7701
6662 7460
1853 4753
195 5712
459 1387
5845 8825
7275 9618
2904 8934
3179 3416
1250 5746
442 5144
1482 4564
846 1484
7023 7580
221 6579
760 1649
1272 5424
4765 6883
5001 5010
1698 7087
1370 3063
2366 68...

output:

Yes
449 7258
8308 3047
2716 4492
2191 2065
2301 190
1556 6198
2754 6965
3398 3638
7701 2746
6662 7460
4753 1853
195 5712
1387 459
5845 8825
9618 7275
8934 2904
3179 3416
5746 1250
442 5144
1482 4564
846 1484
7580 7023
221 6579
1649 760
1272 5424
6883 4765
5010 5001
7087 1698
3063 1370
6858 2366
9892...

result:

ok OK!

Test #43:

score: 0
Accepted
time: 418ms
memory: 19884kb

input:

10000 9999
2642 7796
1117 8765
8977 9000
1347 9654
8951 9097
4771 7011
7340 8322
2325 2378
2732 9952
4193 7610
2810 7634
2682 5275
1357 9755
253 2089
3559 7503
5862 8187
2357 4656
2436 7702
202 5523
6454 9747
3290 5300
682 2710
5938 7463
180 6567
7473 9070
5889 7290
1033 3442
2738 3852
2706 5591
723...

output:

Yes
2642 7796
8765 1117
9000 8977
9654 1347
9097 8951
4771 7011
7340 8322
2378 2325
9952 2732
7610 4193
7634 2810
5275 2682
9755 1357
253 2089
3559 7503
8187 5862
2357 4656
7702 2436
202 5523
9747 6454
3290 5300
682 2710
7463 5938
6567 180
9070 7473
5889 7290
1033 3442
3852 2738
2706 5591
5487 723
1...

result:

ok OK!

Test #44:

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

input:

10000 9999
1815 4865
3448 5010
1349 8159
255 9768
827 4641
2062 5643
3060 9813
2125 3848
3872 9305
1061 9020
4436 6351
18 3806
7605 9245
2441 3144
1256 4585
1696 6229
5568 8017
817 3274
1897 6920
808 4285
918 9635
1047 8502
3240 7261
809 5860
2310 8627
2293 9336
8159 8641
5594 7898
1170 6847
4826 56...

output:

No

result:

ok OK!

Test #45:

score: 0
Accepted
time: 388ms
memory: 18688kb

input:

10000 9999
4642 7435
4082 9787
5339 9571
351 7140
7036 7503
2033 4144
4061 4239
1675 6124
2005 2875
439 7909
3234 9060
930 2357
5652 6254
68 7346
3070 4247
7434 9065
3256 5161
2503 9161
1136 2661
2161 7350
3264 4602
4043 5734
5495 9740
135 8037
1995 2385
256 1302
4650 5811
5787 8033
382 6892
4264 85...

output:

No

result:

ok OK!

Test #46:

score: 0
Accepted
time: 279ms
memory: 19064kb

input:

10000 9999
928 2841
3599 3604
4981 8844
6046 6976
6759 8393
3429 6644
3469 8467
2967 7255
1890 6186
2733 8401
154 4255
587 1618
6735 6973
2473 8327
2406 5032
4260 8575
7277 9519
3259 5261
1074 8809
6699 7127
3078 6728
8886 8918
4184 4355
15 9011
8191 9076
3969 8492
4570 6584
4673 6311
3821 4805
2404...

output:

No

result:

ok OK!

Test #47:

score: 0
Accepted
time: 143ms
memory: 11980kb

input:

1693 1692
246 620
272 686
737 789
42 598
101 345
346 480
635 1561
1269 1361
41 1235
509 1199
892 1333
204 287
1155 1630
515 721
537 1153
1289 1490
66 264
657 1341
66 583
851 1204
734 884
813 1631
99 1145
1002 1336
356 783
1058 1086
206 901
444 1289
50 233
132 1567
917 1685
462 1016
551 944
419 579
1...

output:

No

result:

ok OK!

Test #48:

score: 0
Accepted
time: 291ms
memory: 12328kb

input:

1952 1951
1249 1687
1073 1425
382 1173
512 1902
1474 1817
1008 1251
194 1939
1263 1286
907 956
289 1296
47 1844
562 1714
535 1861
1108 1458
1382 1651
526 1425
395 1558
1278 1580
1324 1899
994 1475
480 734
321 810
566 1695
903 1126
655 1652
720 1431
171 807
1124 1749
1160 1718
1703 1804
859 1105
658 ...

output:

No

result:

ok OK!

Test #49:

score: 0
Accepted
time: 92ms
memory: 19632kb

input:

10000 9999
6413 9706
2861 8717
7529 7848
1660 6073
1716 2608
3635 4168
9458 9801
8492 8690
2825 7003
2312 2840
1288 5551
3577 4177
1576 9025
604 7894
4089 8798
2274 9939
1213 7822
7459 9686
8625 8746
5240 5350
1186 7991
3768 7390
4748 5312
4815 6317
1359 2256
407 8277
1228 1319
2718 6714
756 8001
11...

output:

Yes
6413 9706
2861 8717
7529 7848
1660 6073
1716 2608
4168 3635
9801 9458
8690 8492
2825 7003
2312 2840
1288 5551
3577 4177
1576 9025
604 7894
8798 4089
2274 9939
7822 1213
9686 7459
8625 8746
5350 5240
7991 1186
3768 7390
4748 5312
4815 6317
1359 2256
8277 407
1319 1228
6714 2718
8001 756
4514 1163...

result:

ok OK!

Test #50:

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

input:

2087 2086
1592 1770
583 1534
268 1819
1461 1692
477 1277
170 1003
717 1851
206 567
67 682
1648 1975
557 1841
74 1324
348 1729
658 766
636 1883
74 284
110 1212
188 962
347 1359
253 1581
124 1634
1210 1216
907 1023
69 454
1594 1887
1188 1413
134 347
1044 1911
1435 1467
632 1621
777 778
885 1035
878 10...

output:

Yes
1592 1770
1534 583
1819 268
1461 1692
477 1277
170 1003
1851 717
206 567
67 682
1648 1975
1841 557
74 1324
348 1729
658 766
636 1883
284 74
110 1212
962 188
347 1359
253 1581
1634 124
1210 1216
907 1023
69 454
1594 1887
1413 1188
134 347
1044 1911
1467 1435
1621 632
778 777
885 1035
878 1041
126...

result:

ok OK!

Test #51:

score: 0
Accepted
time: 61ms
memory: 16616kb

input:

6679 6678
3957 4518
2868 3018
2013 3479
1116 4294
2748 3297
1389 2938
3879 5158
2689 6232
4498 6362
3400 4546
2268 5052
1342 2117
3166 5785
4758 5183
1547 1662
1746 2498
3568 4538
4949 5539
4680 6483
4315 6126
3217 5762
1880 4753
1669 2257
242 4027
1633 2700
1823 2991
1562 2109
4797 5978
4414 4589
1...

output:

Yes
3957 4518
3018 2868
3479 2013
4294 1116
3297 2748
1389 2938
3879 5158
6232 2689
4498 6362
4546 3400
2268 5052
2117 1342
3166 5785
4758 5183
1547 1662
2498 1746
3568 4538
4949 5539
6483 4680
4315 6126
3217 5762
1880 4753
1669 2257
242 4027
1633 2700
1823 2991
2109 1562
4797 5978
4414 4589
2776 16...

result:

ok OK!

Test #52:

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

input:

316 49770
68 243
185 280
38 163
44 76
158 228
53 164
175 284
2 38
95 256
224 233
159 202
87 106
23 272
134 238
220 270
102 190
24 185
244 283
121 134
23 127
38 232
183 308
10 32
99 159
152 249
217 283
58 226
132 184
107 316
97 197
159 249
12 214
41 168
127 270
11 47
275 280
169 198
100 259
40 167
16...

output:

Yes
243 68
280 185
163 38
76 44
158 228
53 164
175 284
2 38
95 256
224 233
202 159
87 106
23 272
238 134
220 270
190 102
185 24
283 244
134 121
127 23
232 38
183 308
32 10
99 159
249 152
283 217
226 58
184 132
316 107
197 97
249 159
214 12
168 41
127 270
11 47
280 275
169 198
100 259
167 40
271 163
...

result:

ok OK!

Test #53:

score: 0
Accepted
time: 62ms
memory: 12848kb

input:

144 10296
59 134
9 93
12 138
42 89
4 11
65 67
39 52
1 73
116 119
109 115
123 127
60 99
74 87
5 36
7 9
125 140
17 26
1 5
40 135
92 115
91 106
10 104
24 61
17 140
14 134
16 138
34 121
48 94
44 67
26 105
91 121
69 72
71 92
30 32
104 126
96 112
11 81
102 135
68 74
70 87
13 125
24 108
85 113
56 140
94 13...

output:

Yes
134 59
93 9
138 12
42 89
11 4
67 65
52 39
73 1
119 116
109 115
123 127
99 60
74 87
36 5
7 9
140 125
17 26
5 1
40 135
115 92
91 106
10 104
61 24
17 140
134 14
138 16
121 34
48 94
67 44
105 26
91 121
72 69
71 92
30 32
104 126
112 96
11 81
102 135
68 74
70 87
13 125
108 24
85 113
140 56
94 137
37 2...

result:

ok OK!

Test #54:

score: 0
Accepted
time: 198ms
memory: 18968kb

input:

280 39060
25 210
94 113
87 150
40 63
137 208
145 263
151 157
141 156
37 217
158 236
42 108
99 210
37 94
249 279
6 83
139 149
109 279
126 266
4 273
164 221
52 265
57 145
53 234
6 32
177 182
89 248
205 215
130 245
52 65
34 188
94 252
9 125
18 190
263 279
52 87
202 248
51 188
116 136
211 261
203 271
10...

output:

Yes
210 25
113 94
87 150
63 40
137 208
145 263
157 151
156 141
217 37
236 158
108 42
210 99
94 37
249 279
83 6
149 139
109 279
126 266
273 4
164 221
52 265
145 57
53 234
32 6
177 182
248 89
215 205
245 130
65 52
34 188
252 94
125 9
18 190
263 279
87 52
248 202
188 51
136 116
211 261
271 203
113 104
...

result:

ok OK!

Test #55:

score: 0
Accepted
time: 92ms
memory: 18116kb

input:

10000 9999
4919 8827
5890 6318
1970 7571
5763 7013
3073 7217
3557 8856
9566 9621
5761 7365
4683 9083
400 5663
7795 9148
7348 9260
467 6824
6527 9347
995 7454
4551 9038
881 6842
9173 9562
6929 7569
323 1604
1057 9626
2987 9249
5429 6175
4160 7548
6371 9543
8422 8493
31 7534
3797 9268
5981 8630
2083 6...

output:

No

result:

ok OK!

Test #56:

score: 0
Accepted
time: 324ms
memory: 13516kb

input:

4075 4074
2508 3565
24 3820
411 3744
1291 2978
58 1276
607 964
1391 2036
543 1704
1244 3027
1186 1419
2800 3871
75 3018
2399 3824
1925 3455
1654 2378
1190 1263
1766 3447
204 3882
1816 2263
1383 3151
1181 3324
1628 3478
2208 3889
1172 2792
42 1561
351 869
358 2730
2384 2665
2201 2866
369 1073
380 347...

output:

No

result:

ok OK!

Test #57:

score: 0
Accepted
time: 113ms
memory: 11664kb

input:

1532 1531
26 1237
592 1414
215 756
398 583
499 1164
187 284
514 597
1017 1449
721 1396
677 1364
450 585
679 1062
275 1343
365 1532
406 703
821 1157
84 1419
371 938
1228 1525
281 877
901 979
107 857
931 1378
158 784
246 1280
334 363
667 964
726 1268
806 1173
1235 1527
173 459
55 1495
436 467
358 922
...

output:

No

result:

ok OK!

Test #58:

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

input:

10000 9999
5278 9934
2960 7297
6184 8511
1366 9955
1309 6626
262 5974
5759 9392
5241 7102
3401 9956
2188 4143
6885 8533
1404 1690
4564 9908
39 8358
7366 8563
2685 9509
2533 4385
1856 5706
299 9253
5664 6760
1124 9601
3036 7721
8588 9580
5203 8410
8591 9676
5090 9502
1696 6992
6332 8002
2676 8344
384...

output:

Yes
5278 9934
7297 2960
8511 6184
9955 1366
1309 6626
262 5974
9392 5759
7102 5241
9956 3401
4143 2188
8533 6885
1404 1690
9908 4564
39 8358
8563 7366
9509 2685
4385 2533
1856 5706
9253 299
6760 5664
9601 1124
7721 3036
8588 9580
8410 5203
9676 8591
5090 9502
1696 6992
8002 6332
8344 2676
3845 6639
...

result:

ok OK!

Test #59:

score: 0
Accepted
time: 16ms
memory: 10892kb

input:

235 234
71 131
24 226
128 203
79 219
130 223
230 231
34 162
42 120
140 151
153 227
43 59
5 89
101 213
142 212
51 161
96 156
28 159
60 76
29 51
100 227
9 212
191 217
35 171
17 57
40 85
12 156
201 230
133 140
34 77
145 180
111 127
105 232
58 90
152 167
61 102
202 212
108 219
200 207
7 128
11 27
67 189...

output:

Yes
71 131
226 24
128 203
219 79
223 130
230 231
34 162
120 42
140 151
227 153
59 43
5 89
213 101
142 212
51 161
156 96
159 28
60 76
29 51
227 100
9 212
217 191
171 35
17 57
85 40
12 156
230 201
140 133
77 34
145 180
111 127
105 232
58 90
167 152
61 102
212 202
219 108
207 200
128 7
27 11
67 189
185...

result:

ok OK!

Test #60:

score: 0
Accepted
time: 18ms
memory: 11416kb

input:

828 827
188 540
439 527
91 552
129 563
26 180
316 528
571 708
258 499
684 703
5 639
484 748
472 611
221 286
731 775
162 341
31 711
224 284
67 674
232 453
445 817
364 671
136 203
183 746
787 788
296 352
150 661
537 819
321 407
28 176
342 494
333 637
89 444
430 772
365 458
129 695
478 824
389 429
31 5...

output:

Yes
188 540
439 527
91 552
563 129
180 26
316 528
708 571
499 258
684 703
5 639
748 484
611 472
286 221
731 775
341 162
31 711
284 224
674 67
453 232
817 445
671 364
203 136
183 746
788 787
352 296
150 661
819 537
321 407
176 28
342 494
333 637
444 89
430 772
458 365
129 695
824 478
389 429
31 516
3...

result:

ok OK!

Test #61:

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

input:

10000 9999
3833 9061
1500 3833
3833 8568
3833 7555
2422 3833
3833 7639
3833 9143
3833 7985
3833 8819
1810 3833
1060 3833
3833 4095
3833 9572
2664 3833
3833 5126
3833 6670
204 3833
3833 8793
3045 3833
3833 9593
3833 8503
3833 6829
3833 5958
756 3833
3341 3833
3833 6440
3833 4920
3833 8418
3833 7001
2...

output:

No

result:

ok OK!

Test #62:

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

input:

242 241
8 177
177 230
171 177
96 177
177 203
53 177
177 229
24 177
101 177
177 196
175 177
21 177
75 177
146 177
127 177
88 177
38 177
110 177
177 178
147 177
177 185
83 177
48 177
159 177
120 177
157 177
71 177
153 177
177 235
20 177
177 190
177 186
164 177
90 177
177 231
113 177
149 177
100 177
12...

output:

No

result:

ok OK!

Test #63:

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

input:

1004 1003
422 645
422 513
422 561
362 422
422 761
284 422
422 629
326 422
422 745
422 884
422 700
422 505
417 422
35 422
422 430
102 422
139 422
181 422
422 473
279 422
422 425
422 952
422 438
422 906
395 422
422 461
422 732
422 822
422 520
422 979
16 422
422 574
28 422
10 422
422 827
422 910
104 42...

output:

No

result:

ok OK!

Test #64:

score: 0
Accepted
time: 81ms
memory: 19588kb

input:

10000 9999
1789 2113
2113 9349
2113 2830
2113 8373
2113 7243
2113 3364
2113 7115
2113 3686
2113 5446
2113 9678
2113 3971
2113 4432
2113 8856
2113 6846
2113 3435
2113 4573
648 2113
2113 7881
2113 7353
2113 8271
2113 4296
2113 3627
2113 2262
2113 7759
2113 9826
2113 5525
2113 2752
1407 2113
2113 9888
...

output:

Yes
2113 1789
2113 9349
2113 2830
2113 8373
2113 7243
2113 3364
2113 7115
2113 3686
2113 5446
2113 9678
2113 3971
2113 4432
2113 8856
2113 6846
2113 3435
2113 4573
2113 648
2113 7881
2113 7353
2113 8271
2113 4296
2113 3627
2113 2262
7759 2113
2113 9826
2113 5525
2113 2752
2113 1407
2113 9888
2113 13...

result:

ok OK!

Test #65:

score: 0
Accepted
time: 50ms
memory: 15776kb

input:

5972 5971
1245 3480
1245 3590
1245 3080
1245 1813
1245 5610
1155 1245
1245 4672
1245 4608
1196 1245
1245 3250
1245 5402
1245 5569
1245 4786
1245 1535
1245 5082
1245 2399
1245 2626
1245 1464
1245 1758
1245 5040
1245 1757
1245 1715
1245 4458
1245 3700
1245 2038
1245 3223
1245 4108
1245 4090
1245 4424
...

output:

Yes
1245 3480
1245 3590
1245 3080
1245 1813
1245 5610
1245 1155
1245 4672
1245 4608
1245 1196
1245 3250
1245 5402
1245 5569
1245 4786
1245 1535
1245 5082
1245 2399
1245 2626
1245 1464
1245 1758
1245 5040
1245 1757
1245 1715
1245 4458
1245 3700
1245 2038
1245 3223
1245 4108
1245 4090
1245 4424
1245 1...

result:

ok OK!

Test #66:

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

input:

4331 4330
2776 3764
3764 3770
2923 3764
2167 3764
2310 3764
1027 3764
482 3764
686 3764
3695 3764
2091 3764
3013 3764
798 3764
3764 4241
213 3764
1768 3764
3764 4098
3764 4057
2416 3764
3668 3764
352 3764
1859 3764
373 3764
991 3764
3533 3764
512 3764
3346 3764
1275 3764
2517 3764
3383 3764
2703 376...

output:

Yes
3764 2776
3764 3770
3764 2923
3764 2167
3764 2310
3764 1027
3764 482
3764 686
3764 3695
3764 2091
3764 3013
3764 798
3764 4241
3764 213
3764 1768
3764 4098
3764 4057
3764 2416
3764 3668
3764 352
3764 1859
3764 373
3764 991
3764 3533
3764 512
3764 3346
3764 1275
3764 2517
3764 3383
3764 2703
3764...

result:

ok OK!