This page is still under construction.

Parts of this page are still being built. What you see may change.

Grid Pattern

Interview

Time limit10sMemory limit512 MB

Summary
For each case, print a text grid with pipe, minus, and plus lines and asterisk-filled cells of size w by h.
Level

Easy2 of 10

Topics
Implementation, Simulation, String
Solved
No attempts yet

Problem

Games commonly found on Unix systems in the 1970s and 1980s were designed in text mode. Many of these games use a grid as their basic layout, placing pieces or items in rows and columns. Classic examples are tic-tac-toe, chess, and minesweeper. Your task is to design a simple text-based grid layout engine that these games can use.

Given the dimensions, print a text-based grid pattern. Use | (pipe) for vertical lines, - (minus) for horizontal lines, and + (plus) where lines cross. Fill every other position with * (asterisk).

Input

The first line contains a positive integer NN (1≤N≤1001 \le N \le 100), the number of test cases. Each of the next NN lines contains four positive integers rowrow, colcol, ww, and hh: the number of rows, the number of columns, and the width and height of a single cell. (1≤row,col≤101 \le row, col \le 10, 1≤w,h≤51 \le w, h \le 5)

Output

For each test case, first print a line in the format Case #x:, where xx is the case number starting from 1. Then print the grid pattern.

The grid pattern has row⋅(h+1)+1row \cdot (h+1) + 1 lines, each of length col⋅(w+1)+1col \cdot (w+1) + 1. A border line is + followed by colcol repetitions of ww copies of - and one +. A cell line is | followed by colcol repetitions of ww copies of * and one |. The pattern starts with a border line, and each row adds hh cell lines followed by one border line. See the sample output for the exact format.

Examples1

  1. Example 1

    Input
    2
    2 2 2 2
    1 3 3 1
    
    Expected output
    Case #1:
    +--+--+
    |**|**|
    |**|**|
    +--+--+
    |**|**|
    |**|**|
    +--+--+
    Case #2:
    +---+---+---+
    |***|***|***|
    +---+---+---+