Codeforces Round 382 (Div. 1)
D
Permutations
Codeforces
2800
原题
← CE →
翻译中…

Ostap Bender is worried that people started to forget that he is the Great Combinator. Now he wants to show them his skills in combinatorics. Now he studies the permutations of length $*n*$. He has a list of $*m*$ valid pairs, pair $*a*_{*i*}$ and $*b*_{*i*}$ means that he is allowed to place integers $*b*_{*i*}$ at position $*a*_{*i*}$.

翻译中…

He knows that the number of permutations that use only valid pairs is odd. Now, for each pair he wants to find out, will the number of valid permutations be odd if he removes this pair (and only it) from the list.

翻译中…

Input

翻译中…

The first line contains two integers $*n*$ and $*m*$ ($1 ≤ *n* ≤ 2000$, $*n* ≤ *m* ≤ *min*(*n*^{2}, 500 000)$) — the number of elements in the permutation. Then follow $*m*$ lines, each containing some valid pair $(*a*_{*i*}, *b*_{*i*})$ ($1 ≤ *a*_{*i*}, *b*_{*i*} ≤ *n*$). It's guaranteed that no pair occurs in the input twice and that the total number of valid permutations (i.e. using only allowed pairs position-elements) is odd.

翻译中…

Output

翻译中…

Print $*m*$ lines, one line for each valid pair. The $*i*$-th line should contain "YES" if after Ostap removes the $*i*$-th pair (and only it) the remaining number of valid permutations is odd. Otherwise, print «NO».

翻译中…

样例

Input #1
2 3
1 1
1 2
2 2
Output #1
NO
YES
NO
InputCopy OutputCopy
Input #2
3 3
1 1
2 2
3 3
Output #2
NO
NO
NO
InputCopy OutputCopy
Input #3
3 7
3 3
3 1
1 3
1 1
2 2
1 2
2 1
Output #3
YES
NO
NO
NO
YES
NO
NO
InputCopy OutputCopy
题目信息
题号
736D
时间限制
2 s
内存限制
256 MB
标签
数学
矩阵

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