Can you fold a hexomino into a cube? One of my kid's favorite toys is a set like this.  Actually its one of my favorite toys - I've been playing with it and its been giving me some PPCG challenge ideas.  Here's one:

Write a program or function that takes an ASCII line drawing as input and decides whether or not it folds into a cube.

Input

Input will consist of exactly one hexomino built from squares like this:

+-+
| |
+-+


For example a valid input heximino is:

+-+
| |
+-+-+-+-+
| | | | |
+-+-+-+-+
  | |
  +-+


Output


A truthy value if the hexomino can be folded into a cube, or
A falsey value otherwise.


To save us a bit of work, wikipedia has nice graphics of:


All 35 hexominoes:





All 11 hexominoes that fold into cubes:




Notes


Input hexominoes may have any rotation or reflection, not just those shown in the images above
Input hexominoes may have leading spaces, but will be correctly aligned with respect to themselves
Input hexominoes may have trailing space at the end of lines and trailing newlines at the end of input
PMA/Snails, 130
.!(z\ |o{c..!(z\ }3){w=(..!(z\ )|b..!(z\ )o{..!(z\ }2|c{..!(z\ }1,2w..!(z\ )|w{..!(z\ }1,2c..!(z\ }4o..!(z\ )(..!(z\ )|n..!(z\ )`2

or more &quot;readably&quot;,
?
.!(z\  | o{c..!(z\ }3  )
{w =( ..!(z\ ) | b ..!(z\ ) o {..!(z\ }2  | c {..!(z\ }1,2w..!(z\ ) | w {..!(z\ }1,2c..!(z\  }4
o  ..!(z\ ) ( ..!(z\ ) | n ..!(z\ ) `2

Unusually, a problem came along that can be handled by the limited amount of features implemented so far. The !(z\ ) pattern determines that the current position is at the space in the middle of a square using a negative assertion that there is a space in some &quot;octilinear&quot; direction. The general idea is to check for a pattern that places a square at each of the 5 necessary locations relative to the square that the match starts on. Also, it needs to check that it is not in a 2x2 block of squares. Before the program would work, I had to fix a bug with the parsing of parentheses.
If the hexomino does not map a cube, 0 is printed. If it does, some positive integer is printed (number of matches).
I adapted this polyomino generator to create all possible test cases:
n=input()
r=range
T=lambda P:set(p-min(p.real for p in P)-min(p.imag for p in P)*1j for p in P)
A=[]
for i in r(1&lt;&lt;18):
 P=[k%3+k/3*1j for k in r(18)if i&gt;&gt;k&amp;1]
 C=set(P[:1])
 for x in P:[any(p+1j**k in C for k in r(4))and C.add(p)for p in P]
 P=T(P)
 if not(C^P or P in A or len(P)-n):
  #for y in r(4):print''.join(' *'[y+x*1j in P] for x in r(6))
  o = [ [' ']*13 for _ in r(9)]
  for y in r(4):
   for x in r(6):
    if y+x*1j in P: X=2*x;Y=2*y; o[Y][X]=o[Y+2][X]=o[Y][X+2]=o[Y+2][X+2]='+'; o[Y][X+1]=o[Y+2][X+1]='-';o[Y+1][X+2]=o[Y+1][X]='|'
  print '\n'.join(map(''.join,o))
  A+=[T([p*1j**k for p in P])for k in r(4)]