Flip Flop Circuit that has two inputs?
As Turbo J said, the device performing that function is a SR latch. The CD4043 and CD4044 ICs may be what you're looking for. Then you'll have to add an inverter in order to generate the Q output. You can use the 74HC04 inverter.







simulate this circuit &ndash; Schematic created using CircuitLab

OTOH, if you need your P, Q voltages to be different from the A, B peak voltages then you'll have to implement some kind of logic level conversion. A simple transistor switch will do the trick. Even better, you can save the 74HC04 inverters by using complementary transistors for the switches.

There is also a synchronous version of the SR latch: the JK flip-flop. But it may not be what you're looking for.