Which tetromino is this? Given an unsigned 16-bit integer N, your task is to determine whether its binary representation mapped inside a 4x4 matrix is matching a tetromino shape, and if so, which shape it is.

Matrix

Each bit of N is mapped inside a 4x4 matrix, from left to right and from top to bottom, starting with the most significant one.

Example:

N = 17600
binary representation: 0100010011000000
matrix: [ [ 0, 1, 0, 0 ],
          [ 0, 1, 0, 0 ],
          [ 1, 1, 0, 0 ],
          [ 0, 0, 0, 0 ] ]


Tetromino shapes

Base shapes

There are 7 tetromino shapes, identified by the letters O, I, S, Z, L, J and T:



Rotations and translations

If a shape is translated and/or rotated within the 4x4 matrix, it is still considered a valid variation of the same tetromino. For instance, 17600, 1136, 2272 and 1604 should all be identified as J tetrominoes:



Don't wrap!

However, the shapes can't wrap around or be shifted beyond any boundary of the matrix. For instance, neither 568 nor 688 should be identified as J tetrominoes (let alone any other shape):



Clarifications and rules


You may take input as an integer, or directly as 16 binary digits in any reasonable format, such as a 2D array, a flat array or a delimited string.
The input is guaranteed to be an unsigned 16-bit integer (or its equivalent representation as an array or a string).
When a valid shape is identified, you must print or return the letter identifying the shape, in either lower or upper case.
If no shape is identified, you must print or return a value that doesn't match any tetromino letter. You may also choose to return nothing at all.
To be considered valid, the matrix must contain the exact tetromino shape without any additional cells (see 1911 and 34953 in the test cases).
This is code-golf, so the shortest answer in bytes wins!


Test cases

You can follow this link to get the test cases as 2D arrays.

0      -&gt; false
50     -&gt; false
51     -&gt; 'O'
1911   -&gt; false
15     -&gt; 'I'
34952  -&gt; 'I'
34953  -&gt; false
1122   -&gt; 'S'
3168   -&gt; 'Z'
785    -&gt; 'L'
1136   -&gt; 'J'
568    -&gt; false
688    -&gt; false
35968  -&gt; 'T'
19520  -&gt; 'T'
Python 3, 124 bytes



def f(n):
 while n&amp;4369&lt;n/n:n&gt;&gt;=1
 while n&amp;15&lt;1:n&gt;&gt;=4
 return'TJLZSIO'["rēȣc6&#15;3ıGtĲȱᄑ@'̢̑@@@@Ȳq&#23;".index(chr(n))%7]


Try it online!

Expects an integer n representing a 4 × 4 binary matrix. Throws if no tetromino is found.

Line 2 slides the shape to the right until a 1 is in the rightmost column. (4369 is 0001 0001 0001 0001 in binary.) Line 3 lowers the shape until a 1 is in the bottom row. Together this turns e.g.:

    0 1 0 0        0 0 0 0
    1 1 1 0  into  0 0 0 0
    0 0 0 0        0 0 1 0
    0 0 0 0        0 1 1 1


Then we look for the index of n in this list:

 [114  275  547   99   54   15   51
  305   71  116  306  561 4369   64
   39  802  785   64   64   64   64
  562  113   23]
#   T    J    L    Z    S    I    O


Each column of indices equivalent modulo 7 corresponds to a tetromino shape. 64 (@) is used as a padding value as n cannot be 64 at this point in the code.

NB. An exception is thrown for input 0 by computing n/n instead of 1.