How do I craft that? There are 21 items in Minecraft that you can craft using only wood and items crafted from wood:


  axe
  boat
  bowl
  button
  chest
  crafting table
  door
  fence
  gate
  hoe
  ladder
  pickaxe
  planks
  pressure plate
  shovel
  sign
  slab
  stairs
  stick
  sword
  trapdoor  


This list assumes that the 6 different types of wooden planks/slabs/doors/etc. all count as the same item. Another way to think of it is to assume you only have access to one type of wood.

Each of these 21 items has a different crafting recipe. We'll represent each of these recipes as a 2×2 or 3×3 grid of the characters .WPS. The . is an empty crafting slot, W is for wood, P is for wood planks, and S is for sticks. No other characters are needed for these particular items.

For example, this is the recipe for a chest:

PPP
P.P
PPP


Challenge

Write a program that takes in the name of one of our 21 items, exactly as it appears above, and prints a valid crafting recipe for that item.

Crafting recipes are translation invariant, so if the input is fence, both of these are valid:

PSP
PSP
...

...
PSP
PSP

If a recipe fits in a 2×2 grid, you can output it in a 2×2 or 3×3 grid. e.g. stick:

.P
.P

...
.P.
.P.

Recipes can also be mirrored horizontally (around a vertical line of symmetry), though this only makes a difference for the axe, hoe, and stairs. e.g. hoe:

.PP
.S.
.S.

PP.
.S.
.S.

So outputting any recipe that fits in the grid and has the correct shape (ignoring translation and mirroring) is what your program needs to do. These are all the recipes that the official game will recognize. (Note that recipes cannot be rotated or mirrored vertically.)

Details


Take input from stdin or the command line. You can assume the input is always valid. Requiring quotes around input (e.g. "chest") is fine.
Output to stdout (or closest alternative) with an optional trailing newline.
The shortest submission in bytes wins.


Example

Here's a list of all inputs and sample outputs:

axe
PP.
SP.
S..

boat
P.P
PPP
...

bowl
P.P
.P.
...

button
P.
..

chest
PPP
P.P
PPP

crafting table
PP
PP

door
PP.
PP.
PP.

fence
PSP
PSP
...

gate
SPS
SPS
...

hoe
PP.
S..
S..

ladder
S.S
SSS
S.S

pickaxe
PPP
.S.
.S.

planks
W.
..

pressure plate
PP
..

shovel
P..
S..
S..

sign
PPP
PPP
.S.

slab
PPP
...
...

stairs
P..
PP.
PPP

stick
P.
P.

sword
P..
P..
S..

trapdoor
PPP
PPP
...
CJam, 100 96 94 91 bytes

"+WcbKF AQH;_{GM8Lyf=_tmTn"141bDb3/l72b970%={Z"O&gt;HVa=4a"98bZb+"P.SW"f=3/=}%N*


StackExchange mangles unprintables, so rather than copying and pasting here is the permalink. Additionally, here's the test program.

(Thanks to @Optimizer for telling me about f and @MartinBüttner for telling me about CJam's modulo indexing.)

Cygwin's hexdump:

0000000 0122 2b1e 571a 6308 621f 4b05 2046 5141
0000010 1608 1848 5f3b 1115 1d7b 4d47 4c38 6679
0000020 5f3d 6d74 0c54 226e 3431 6231 6244 2f33
0000030 376c 6232 3739 2530 7b3d 225a 1b4f 483e
0000040 6156 343d 2261 3839 5a62 2b62 5022 532e
0000050 2257 3d66 2f33 7d3d 4e25 002a          
000005b


Explanation

To construct the recipes, we use 13 different rows (also listed are explanations why this is minimal):

0    W..    (required by planks)
1    ...    (required by many)
2    .PP    (required by many)
3    PPP    (required by chest)
4    .P.    (required by bowl)
5    ..P    (required by stairs)
6    S.S    (required by ladder)
7    SSS    (required by ladder)
8    .S.    (required by sign)
9    .SP    (required by axe)
10   P.P    (required by bowl)
11   PSP    (required by fence)
12   SPS    (required by gate)


We encode the rows via Z"O&gt;HVa=4a"98bZb+"P.SW"f=3/, which gives

["W.." "..." ".PP" "PPP" ".P." "..P" "S.S" "SSS" ".S." ".SP" "P.P" "PSP" "SPS"]


The first bit "+WcbKF AQH;_{GM8Lyf=_tmTn"141bDb3/ encodes the recipes, giving 

[[3 3 8] [1 0 0] [1 0 0] [3 8 8] [1 3 3] [2 8 8] [6 7 6] [1 0 0] [1 10 3] [1 1 2] [2 2 2] [1 11 11] [1 1 4] [1 0 1] [1 10 4] [2 9 8] [3 10 3] [1 2 2] [4 8 8] [1 4 4] [1 1 3] [1 12 12] [4 4 8] [5 2 3]]


Note how the first entry is [3 3 8], which is the recipe for sign.

l72b970%= reads in the input, then applies some magic to work out which recipe to take from the list. Even though we only have 21 recipes there are 24 in the list — the extra few spots correspond to the [1 0 0]s.

After reading the input, picking the recipe and converting the recipe to rows, we put in some newlines N* and auto-print.



CJam, 89 86 83 bytes

'W"9=!%)S@*m:@DQzk?V$%qyR55AmVEpPNW}"132b3b"P.S"f=+3/3/l57b5342%24%(=N*


... it turns out that hardcoding all the outputs does a bit better in CJam. I'm pretty disappointed.

Once again we have some unprintables so here's the permalink and test program.

Cygwin's hexdump:

0000000 5727 0222 3d39 1021 2925 531e 2a40 6d0b
0000010 403a 1844 7a51 3f6b 2456 7125 5279 3506
0000020 4135 046d 1a56 7045 1550 164e 1057 7d01
0000030 3122 3233 3362 2262 2e50 2253 3d66 332b
0000040 332f 6c2f 3735 3562 3433 2532 3432 2825
0000050 4e3d 002a                              
0000053


Explanation

The outputs are encoded using base 3, with the lone W being tacked onto the front before the string is split into 3s to give rows, and the rows are split into groups of 3s to give recipes.

Like above, base converting and modulo magic is used to select the recipe. There are 22 recipes (one unused) but we need to take modulo 24, so we actually need to explicitly specify 24% this time rather than relying on modulo indexing.