Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/matritsa-paskal-uchburchagi

Pascal's triangle

Medium 1000 ms 128 MB 61%
Share

A positive integer $n$ is given. Print the first $n$ rows of Pascal's triangle. Row $i$ has $i$ numbers; the numbers at the edges are $1$, and every inner number is the sum of the two neighbours above it:

$$P_{i,j} = P_{i-1,j-1} + P_{i-1,j}$$

Pascal's triangle made of binomial coefficients

Input

One positive integer $n$.

Output

$n$ lines: line $i$ contains $i$ space-separated integers.

Note

$1 \le n \le 60$

Examples

Input #1
5
Output #1
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
Input #2
1
Output #2
1

Sign in to submit a solution

Signing up is free and takes a minute.