CF1344C Quantifier Question
Description
Logical quantifiers are very useful tools for expressing claims about a set. For this problem, let's focus on the set of real numbers specifically. The set of real numbers includes zero and negatives. There are two kinds of quantifiers: universal ( $ \forall $ ) and existential ( $ \exists $ ). You can read more about them here.
The universal quantifier is used to make a claim that a statement holds for all real numbers. For example:
- $ \forall x,xx-1 $ is read as: for all real numbers $ x $ , $ x $ is greater than $ x-1 $ . This statement is true.
The existential quantifier is used to make a claim that there exists some real number for which the statement holds. For example:
- $ \exists x,xx-1 $ is read as: there exists a real number $ x $ such that $ x $ is greater than $ x-1 $ . This statement is true.
Moreover, these quantifiers can be nested. For example:
- $ \forall x,\exists y,x
Input Format
The first line contains two integers $ n $ and $ m $ ( $ 2\le n\le 2\cdot 10^5 $ ; $ 1\le m\le 2\cdot 10^5 $ ) — the number of variables and the number of inequalities in the formula, respectively.
The next $ m $ lines describe the formula. The $ i $ -th of these lines contains two integers $ j_i $ , $ k_i $ ( $ 1\le j_i,k_i\le n $ , $ j_i\ne k_i $ ).
Output Format
If there is no assignment of quantifiers for which the statement is true, output a single integer $ -1 $ .
Otherwise, on the first line output an integer, the maximum possible number of universal quantifiers.
On the next line, output a string of length $ n $ , where the $ i $ -th character is "A" if $ Q_i $ should be a universal quantifier ( $ \forall $ ), or "E" if $ Q_i $ should be an existential quantifier ( $ \exists $ ). All letters should be upper-case. If there are multiple solutions where the number of universal quantifiers is maximum, print any.
Explanation/Hint
For the first test, the statement $ \forall x_1, \exists x_2, x_1