3396. Elidibus the Warrior of Light

Description

Ascian Elidibus summons hero fragments from distant worlds through spells, and gathers the pure desire to save the world in his own soul, forming a collection of the concept of the hero "Warrior of Light".

Because he once served as the heart of Zodiac, Elidibus is not complete now. Even if the memory has faded, even if he can no longer remember the person he promised, he will defeat us.

Elidibus the Warrior of Light has three different abilities:

  • Sword of Light: Deal damage to enemies in the triangle area.

  • Solemn Confiteor: Deal damage to enemies in a circular area.

  • Ascendance: Binds enemies so they cannot move.

Our health point is , and our location coordinates are .

Elidibus first bind us with Ascendance. Then Elidibus will attack  times, each time choose one from the Sword of Light and Solemn Confiteor.

The attack range of the Sword of Light will be given in the form of the coordinates of the three vertices of the triangle.

The attack range of Solemn Confiteor will be given in the form of the coordinates of the center of the circle and the radius of the circle.

We take damage both at the borders and inside the attack range.

Will we still be alive after Elidibus' attack is over? If we are still alive, output the remaining health point, otherwise output how much excess damage Elidibus did.

Input

The first line has two integers , which respectively represent the player's health point and the number of attacks by Elidibus.

The second line has two integers , which represent the coordinates  of the player's position.

Next n lines, each with an integer :

  • If , Elidibus uses the Sword of Light to attack. The is followed by six integers which represent the coordinates  of the three vertices of the triangle attack range of the Sword of Light.

  • If , Elidibus uses Solemn Confiteor to attack. The is followed by three integers , , and which represent the center coordinates and radius of Solemn Confiteor's circular attack range.

Output

An integer on a line, representing the player's remaining health point or the excess damage dealt by Elidibus.

Sample Input

2 2
2 2
1 0 0 0 4 4 0
2 0 0 2

Sample Output

1

Note

Elidibus gathered the pure desire to save the world in his own soul, forming the totality of the hero "Warrior of Light". Its appearance should be very similar to the hero who saved a certain world in a certain era. Or maybe he thinks a hero should be like this.


 


难度等级: 0
总通过次数: 25
总提交次数: 513