The sum of two numbers A and B is 3. The sum of their cubes is 36, What is the sum of their squares decreased by the product of the two numbers?