QOJ.ac

QOJ

Límite de tiempo: 2.0 s Límite de memoria: 256 MB Puntuación total: 100 Hackeable ✓
Estadísticas

In the Cartesian coordinate system, a point $(x, y)$ is called a lattice point if and only if $x \in \mathbb{Z}, y \in \mathbb{Z}$, where $\mathbb{Z}$ denotes the set of integers. If the four vertices of a square in the plane are all lattice points, we call this square a lattice square.

Xiao Yu loves lattice squares. He places an $n \times m$ canvas on the Cartesian coordinate system, where the region covered by the canvas can be represented as $\{(x, y) \mid 0 \le x \le n, 0 \le y \le m\}$.

Now, Xiao Yu wants to pick a lattice point $(a, b)$ on the canvas, where $0 \le a \le n, 0 \le b \le m$, and asks you: how many distinct lattice squares can be drawn within the canvas such that $(a, b)$ is one of their vertices?

Since Xiao Yu has too many queries, you decide to directly provide the answers for all $(a, b)$ where $0 \le a \le n, 0 \le b \le m$. Please output an $(n + 1) \times (m + 1)$ matrix as your answer.

Note: The squares within the canvas must have all their vertices located within the canvas region. Two lattice squares are considered the same if and only if their sets of vertices are identical.

Input

The input contains one line with two integers $n, m$ ($1 \le n, m \le 10^5, n \times m \le 3 \times 10^5$), representing the size of the canvas.

Output

Output $n + 1$ lines, each containing $m + 1$ integers, with the integers in each line separated by spaces. The integer at the $j$-th position of the $i$-th line ($0 \le i \le n, 0 \le j \le m$) represents the number of distinct lattice squares that can be drawn within the canvas having $(i, j)$ as one of their vertices.

Examples

Input 1

1 1

Output 1

1 1
1 1

Input 2

2 2

Output 2

2 3 2
3 4 3
2 3 2

Input 3

4 5

Output 3

4 8 10 10 8 4
7 11 13 13 11 7
8 12 14 14 12 8
7 11 13 13 11 7
4 8 10 10 8 4

Note

Note that according to the problem statement, the sides of the lattice squares are not necessarily parallel to the coordinate axes.

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.