跳到主要内容
图灵 OJTURING / ONLINE JUDGE

#F1018. Permutations

    ID: 1024 传统题 2000ms 256MiB 尝试: 0 已通过: 0 难度: (无) 上传者: 标签>待分类整理状态难度待定难度共享题库Codeforces英文题面题目来源题面语言

Permutations

题目描述

D. Permutations
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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 ai and bi means that he is allowed to place integers bi at position ai.

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, nmmin(n2,500000))− the number of elements in the permutation. Then follow m lines, each containing some valid pair (ai,bi) (1≤ai,bin). 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».

Examples
Input
2 3
1 1
1 2
2 2
Output
NO
YES
NO
Input
3 3
1 1
2 2
3 3
Output
NO
NO
NO
Input
3 7
3 3
3 1
1 3
1 1
2 2
1 2
2 1
Output
YES
NO
NO
NO
YES
NO
NO

题目来源:fps-www.educg.net-codeforce-1-2833.xml.zip;FPS 共享题包,题包内第 467 题。保留原作者与原赛事署名。