Preparando MOJI

Permutations

2000ms 262144K

Description:

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, n ≤ m ≤ min(n2, 500 000)) — the number of elements in the permutation. Then follow m lines, each containing some valid pair (ai, bi) (1 ≤ ai, bi ≤ 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».

Sample Input:

2 3
1 1
1 2
2 2

Sample Output:

NO
YES
NO

Sample Input:

3 3
1 1
2 2
3 3

Sample Output:

NO
NO
NO

Sample Input:

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

Sample Output:

YES
NO
NO
NO
YES
NO
NO

Informação

Codeforces

Provedor Codeforces

Código CF736D

Tags

mathmatrices

Submetido 0

BOUA! 0

Taxa de BOUA's 0%

Datas 09/05/2023 09:10:34

Relacionados

Nada ainda