Multiplication of two complex numbers is ( a + ib ) ( c + id ) = ( ac - bd ) + i ( ad + bc )
int x = ( ( p . first * q . first ) % M - ( p . second * q . second ) % M + M ) % M ; int y = ( ( p . first * q . second ) % M + ( p . second * q . first ) % M ) % M ;