Find a criminal from his ear, finger, and head Prior to the discovery of fingerprints and DNA testing, the British police used an anthropometric system to identify repeat offenders. Certain parts of the bodies of criminals were measured and stored in records -- these parts of the body were assumed to not change in size after adulthood. This system was known as bertillonnage. 

The diagram below shows a filing system used by the police to access these records quickly. 


Diagram 1: A filing system with numbered drawers.
 Note: if you cannot see the image, try the imgur mirror  or compile it yourself.

The filing cabinet consists of 81 numbered drawers. Each drawer contains cards, and each card has measurements of particular parts of a criminal's body:


The length of their head (H)  
The breadth of their head (B)  
The width of their right ear (E)  
The length of their index finger (F)


Each measurement is classified as either small, medium or large.

For example, drawer 56 contains cards with the following characteristics: small H, large B, medium E, and small F. This can be notated using the letters S, M, and L in place of small, medium, and large:

SH,LB,ME,SF


Note that the size letter goes first, then what the measurement is. In addition, an exclamation point ! may be placed in front to cause a negative:

!SH,LB,!ME,SF


This indicates cards that have the following characteristics: not small H, large B, not medium E, and small F. There are four drawers that contain cards with these characteristics -- 58, 60, 61, and 63.

Your task is to write a program, that, when given a string notating some characteristics, outputs all of the drawers that contain cards with those characteristics. If there are no drawers that contain cards with the given characteristics, output 0. 

Here are some sample inputs and outputs.


Input: SH,LB,ME,SF
Output: 56  
Input: !SH,LB,!ME,SF
Output: 58,60,61,63  
Input: SB,!MF,!LF
Output: 1,2,3,4,5,6,7,8,9
Input: MH,!MH
Output: 0


This is code golf, so the shortest entry wins. Ask questions in the comments if the specification is not clear.
Ruby 1.9.3 - 173 157 143

x=(1..81).select{|j|$*[0].split(?,).all?{|y|i=j-1
z='SML'
[z[i%9/3]+?H,z[i%3]+?E,z[i/27]+?B,z[i/9%3]+?F].member?(y[-2,2])^y[?!]}}
p x==[]?[0]:x


Edit: 


applied Three If By Whiskey's tips.
taken parameters from the command line to save some more chars


Online demo: http://ideone.com/lodTLt