AtCoder Beginner Contest 210
F
Coprime Solitaire
AtCoder
⌀ 2632
原题
← E→
翻译中…

Problem Statement

翻译中…

We have $N$ cards arranged in a row on a table. For each $i = 1, 2, \ldots, N$, the $i$-th card has an integer $A_i$ written on the front and an integer $B_i$ written on the back. Initially, every card is placed face up.

翻译中…

Takahashi will choose any number of cards he likes (possibly zero) and flip them. Then, he will be happy if the following condition is satisfied:

翻译中…
  • for every pair of integers $(i, j)$ such that $1 \leq i \lt j \leq N$, the integers visible on the $i$-th and $j$-th cards are coprime.
翻译中…

Determine whether it is possible for Takahashi to be happy.

翻译中…

Constraints

翻译中…
  • $1 \leq N \leq 3 \times 10^4$
  • $1 \leq A_i, B_i \leq 2 \times 10^6$
  • All values in input are integers.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N
A_1 B_1
A_2 B_2
\vdots
A_N B_N

翻译中…

Output

翻译中…

If it is possible for Takahashi to be happy, print Yes; otherwise, print No.

翻译中…

样例

Input #1
3
2 5
10 9
4 8
Output #1
Yes
Initially, we see integers $2$, $10$, and $4$. If we flip the first and second cards, we will see $5$, $9$, and $4$, which will make Takahashi happy. Thus, we should print `Yes`.
Input #2
2
10 100
1000 10000
Output #2
No
There is no way to flip cards to make Takahashi happy, so we should print `No`.
题目信息
题号
abc210_f
时间限制
3 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。