cho.sh
Notes
Loading...

Alphabet Diamond

Time limit

2s

Memory limit

128 MB

Problem

An alphabet-diamond tile has side length 2N - 1. Let the center of one tile be (N - 1, N - 1). For a coordinate (r, c) inside the tile, compute d = |r - (N - 1)| + |c - (N - 1)|.

  • If d >= N, the cell contains ..
  • If d < N, the cell contains the lowercase letter for distance d from the center. d = 0 is a, d = 1 is b, and after z the letters wrap back to a.

A single tile for N = 5 is shown below.

....e.......ede.....edcde...edcbcde.edcbabcde.edcbcde...edcde.....ede.......e....

The room floor is an infinite plane filled by repeating this tile vertically and horizontally with no gaps. Rows are numbered from 0 at the top, and columns are numbered from 0 at the left.

Given N, the upper-left coordinate (R1, C1), and the lower-right coordinate (R2, C2) of a rectangle, print exactly the characters written in that rectangle. Coordinate (x, y) means row x, column y.

Input

The first line contains five integers N, R1, C1, R2, and C2, separated by spaces.

Output

Print R2 - R1 + 1 lines. Each line must contain C2 - C1 + 1 characters with no spaces.

Constraints

  • 1 <= N <= 20,000
  • 0 <= R1 <= R2 <= 20,000
  • 0 <= C1 <= C2 <= 20,000
  • 0 <= (R2 - R1 + 1) * (C2 - C1 + 1) <= 40,000
....e.......ede.....edcde...edcbcde.edcbabcde.edcbcde...edcde.....ede.......e....