Tree Ming and Hong are playing a simple game called nim game. They have nn piles of stones numbered 11 to nn ,the ii-th pile of stones has a_iai stones. There are n - 1n−1 bidirectional roads in total. For any two piles, there is a unique path from…
We call a string as a 0689-string if this string only consists of digits '0', '6', '8' and '9'. Given a 0689-string $s$ of length $n$, one must do the following operation exactly once: select a non-empty substring of $s$ and rotate it 180 degrees. Mo…
BaoBao has just found a grid with $n$ rows and $m$ columns in his left pocket, where the cell in the $j$-th column of the $i$-th row (indicated by $(i, j)$) contains an arrow (pointing either upwards, downwards, leftwards or rightwards) and an intege…