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.
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 (
- The breadth of their head (
- The width of their right ear (
- The length of their index finger (
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
L in place of small, medium, and large:
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:
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
Here are some sample inputs and outputs.
This is code golf, so the shortest entry wins. Ask questions in the comments if the specification is not clear.