eolymp
bolt
Try our new interface for solving problems
Problems

Chocolate bars

Chocolate bars

Probably everyone knows that chocolate is good for the human brain. Therefore, participants in the National Olympiad of the country brought to Olympia to tour a lot of chocolate bars that great ideas come to them faster. But brought the chocolate was too much, and after the tour in the office of the remaining \textbf{N} rectangular tiles, which consisted of cloves \textbf{1×1}. Two participants agreed to eat a piece of chocolate that was left, but given the fact that during the tour they have eaten enough chocolate, it was decided to do it in quite an unusual way to play, the following rules. Participants perform certain operations with chocolate bars in turn: first the first, then second, again the first and so on When his party chooses a course of a chocolate bar, with kootoroy he will perform one of the following: \begin{enumerate} \item Break the tile into two; fault line should run parallel to the tile and between the lobules. \item Break off and eat an arbitrary "line" or "column " tiles, which is not extreme. \item Break off and eat all the slices of the tiles that are on the edge, but to then remain on the tile at least one segment (the minimum size of tiles, with kootoroy can be performed such an operation - \textbf{3×3}). \end{enumerate} None of these operations can not be done with the tile of \textbf{1×1}, so all of these tiles remain tothe end of game . Loses one member, who in their course will not do any of the above operations. Write a program that according to information on a bar of chocolate left over after the tour, determines the number of options the first move of the first participant to guarantee him a win, subject to a winning strategy in the future. \includegraphics{https://static.e-olymp.com/content/c5/c5b4924db077b7048dc33580422f0f6c0d3e25e9.gif} \InputFile The first line contains an integer \textbf{N }(\textbf{1 }≤ \textbf{N }≤ \textbf{100}) - number of chocolate bars. The second line contains \textbf{N }pairs of integers, each \textbf{i}-th of which specifies the length and width of the \textbf{i}-th tile. The length and width not less than \textbf{1 }and not exceed \textbf{100}. \OutputFile In a single line of output file should contain an integer - the number of options the first move to the first participant that guarantee him vyigrash, subject them to an optimal strategy in the future.
Time limit 1 second
Memory limit 64 MiB
Input example #1
1
3 3
Output example #1
3

Example description: Winning moves of the first participant in the following: surgery (3), surgery (2) with the second string, and the operation (2) with the second column.

Author Bogdan Yakovenko
Source 2004 XVII All-Ukrainian Informatics Olympiad, Kharkov, March 28 - April 3, Round 1