← Home
package main

import (
	"bufio"
	"fmt"
	"math/bits"
	"os"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	buf := make([]byte, 1024*1024)
	scanner.Buffer(buf, 10*1024*1024)
	scanner.Split(bufio.ScanWords)

	scanInt := func() int {
		scanner.Scan()
		res := 0
		for _, b := range scanner.Bytes() {
			res = res*10 + int(b-'0')
		}
		return res
	}

	if !scanner.Scan() {
		return
	}
	nBytes := scanner.Bytes()
	n := 0
	for _, b := range nBytes {
		n = n*10 + int(b-'0')
	}
	m := scanInt()

	adjList := make([][]int, n)
	adjBits := make([][]uint64, n)
	words := (n + 63) / 64
	for i := 0; i < n; i++ {
		adjBits[i] = make([]uint64, words)
	}

	for i := 0; i < m; i++ {
		u := scanInt() - 1
		v := scanInt() - 1
		adjList[u] = append(adjList[u], v)
		adjList[v] = append(adjList[v], u)
		adjBits[u][v/64] |= 1 << (v % 64)
		adjBits[v][u/64] |= 1 << (u % 64)
	}

	A2 := make([]int32, n*n)
	for i := 0; i < n; i++ {
		for j := i; j < n; j++ {
			c := 0
			for w := 0; w < words; w++ {
				c += bits.OnesCount64(adjBits[i][w] & adjBits[j][w])
			}
			A2[i*n+j] = int32(c)
			A2[j*n+i] = int32(c)
		}
	}

	var C3 int64 = 0
	t := make([]int64, n)
	for i := 0; i < n; i++ {
		for _, k := range adjList[i] {
			t[i] += int64(A2[i*n+k])
		}
		t[i] /= 2
		C3 += t[i]
	}
	C3 /= 3

	var Tr int64 = 0
	for i := 0; i < n; i++ {
		idxI := i * n
		a2i := A2[idxI : idxI+n]
		for _, k := range adjList[i] {
			idxK := k * n
			a2k := A2[idxK : idxK+n]
			var sum int64 = 0
			for j := 0; j < n; j++ {
				sum += int64(a2i[j]) * int64(a2k[j])
			}
			Tr += sum
		}
	}

	var S int64 = 0
	for i := 0; i < n; i++ {
		S += int64(len(adjList[i])) * t[i]
	}

	ans := (Tr / 10) + 3*C3 - S
	fmt.Println(ans)
}