atcoder#AGC016E. [AGC016E] Poor Turkeys

[AGC016E] Poor Turkeys

Score : 14001400 points

Problem Statement

There are NN turkeys. We number them from 11 through NN.

MM men will visit here one by one. The ii-th man to visit will take the following action:

  • If both turkeys xix_i and yiy_i are alive: selects one of them with equal probability, then eats it.
  • If either turkey xix_i or yiy_i is alive (but not both): eats the alive one.
  • If neither turkey xix_i nor yiy_i is alive: does nothing.

Find the number of pairs (i, j)(i,\ j) (1i<jN1 \leq i < j \leq N) such that the following condition is held:

  • The probability of both turkeys ii and jj being alive after all the men took actions, is greater than 00.

Constraints

  • 2N4002 \leq N \leq 400
  • 1M1051 \leq M \leq 10^5
  • 1xi<yiN1 \leq x_i < y_i \leq N

Input

Input is given from Standard Input in the following format:

NN MM

x1x_1 y1y_1

x2x_2 y2y_2

::

xMx_M yMy_M

Output

Print the number of pairs (i, j)(i,\ j) (1i<jN1 \leq i < j \leq N) such that the condition is held.

3 1
1 2
2

(i, j)=(1, 3),(2, 3)(i,\ j) = (1,\ 3), (2,\ 3) satisfy the condition.

4 3
1 2
3 4
2 3
1

(i, j)=(1, 4)(i,\ j) = (1,\ 4) satisfies the condition. Both turkeys 11 and 44 are alive if:

  • The first man eats turkey 22.
  • The second man eats turkey 33.
  • The third man does nothing.
3 2
1 2
1 2
0
10 10
8 9
2 8
4 6
4 9
7 8
2 8
1 8
3 4
3 4
2 7
5