TouchStone
  Please Login
Login Sign Up
 Homepage  Problem Set  Examinations  Submissions  Discussions  Statistics
  • Home
  • Problem Set
  • P4465
  • Problem
  • P4465Destroy the cube
    Limits : Time Limit : 4000 MS   Memory Limit : 565535 KB
    Description

    Input Format

    The first line contains a positive integer T(1≤T≤5), denoting the number of test cases.
    For each test case:
    The first line contains two positive integers n,t(1≤n≤6×10^4,1≤t≤1.2×10^5).
    The next t lines, each line contains two positive integers x,y(1≤xy≤⌊(n+1)/2⌋), denoting a given black position.

    Output Format

    For each test case:
    A single line contains a nonnegative integer, denoting the answer.

    Sample Input

    2
    3 1
    2 2
    5 2
    2 3
    3 3

    Sample Output

    20
    76


    Source  2017 Multi7 杭州二中