QOJ.ac

QOJ

Limite de temps : 5 s Limite de mémoire : 1024 MB Points totaux : 100 Hackable ✓

#17935. How many points is the taste of the chocolate?

Statistiques

Coco runs a factory that produces rectangular chocolates of size $R \times C$. The chocolate is divided into $1 \times 1$ unit chocolates, and the flavor of each unit chocolate can be represented by a single integer $t$.

According to recent research, the total flavor of the chocolate is the sum of the XOR results of all unit chocolates belonging to every possible polyomino (a shape formed by connecting multiple unit chocolates edge-to-edge) that can be obtained by cutting the chocolate. Coco is curious about the total flavor score of the chocolates produced in her factory. Let's help Coco solve her curiosity.

Input

The first line contains the values of $R$ and $C$. ($1 \le R \times C \le 29$)

The next $R$ lines contain the flavor values of each unit chocolate. The $j$-th number in the $i$-th line represents the flavor of the unit chocolate located at the $i$-th row from the top and the $j$-th column from the left. The flavor of a unit chocolate is between $1$ and $10^6$ inclusive.

Output

Output the total flavor value of the given chocolate on a single line.

Examples

Input 1

1 4
1 2 4 8

Output 1

72

Input 2

2 3
1 1 1
1 1 1

Output 2

22

Note

The XOR of two non-negative integers $a$ and $b$ is written as $a \oplus b$, and its definition is as follows:

  • When $a$ and $b$ are represented in binary with the same length, the $i$-th digit of the binary representation of $a \oplus b$ is $0$ if the $i$-th digits of $a$ and $b$ are the same, and $1$ if they are different. If the lengths of the binary representations differ, leading zeros are added to the shorter one until they are equal before performing the calculation.

In programming languages such as C, C++, and Python, the XOR of $a$ and $b$ is represented as a ^ b.

The XOR of multiple non-negative integers $a_1, a_2, \cdots, a_n$ is the result of calculating the XOR sequentially from the beginning, i.e., $((a_1 \oplus a_2) \oplus \cdots) \oplus a_n$.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.