description: It is the easy version of the problem. The only difference is that in this version n = 1.
  
  In the cinema seats can be represented as the table with n rows and m columns. The rows are numbered with integers from 1 to n. The seats in each row are numbered with consecutive integers from left to right: in the k-th row from m (k - 1) + 1 to m k for all rows 1 ≤ k ≤ n.
  
  1| 2| ⋅⋅⋅| m - 1| m  
  ---|---|---|---|---  
  m + 1| m + 2| ⋅⋅⋅| 2 m - 1| 2 m  
  2m + 1| 2m + 2| ⋅⋅⋅| 3 m - 1| 3 m  
  \vdots| \vdots| \ddots| \vdots| \vdots  
  m (n - 1) + 1| m (n - 1) + 2| ⋅⋅⋅| n m - 1| n m  
  The table with seats indices
  
  There are nm people who want to go to the cinema to watch a new film. They are numbered with integers from 1 to nm. You should give exactly one seat to each person.
  
  It is known, that in this cinema as lower seat index you have as better you can see everything happening on the screen. i-th person has the level of sight a_i. Let's define s_i as the seat index, that will be given to i-th person. You want to give better places for people with lower sight levels, so for any two people i, j such that a_i < a_j it should be satisfied that s_i < s_j.
  
  After you will give seats to all people they will start coming to their seats. In the order from 1 to nm, each person will enter the hall and sit in their seat. To get to their place, the person will go to their seat's row and start moving from the first seat in this row to theirs from left to right. While moving some places will be free, some will be occupied with people already seated. The inconvenience of the person is equal to the number of occupied seats he or she will go through.
  
  Let's consider an example: m = 5, the person has the seat 4 in the first row, the seats 1, 3, 5 in the first row are already occupied, the seats 2 and 4 are free. The inconvenience of this person will be 2, because he will go through occupied seats 1 and 3.
  
  Find the minimal total inconvenience (the sum of inconveniences of all people), that is possible to have by giving places for all people (all conditions should be satisfied).
  
  Input
  
  The input consists of multiple test cases. The first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases. Description of the test cases follows.
  
  The first line of each test case contains two integers n and m (n = 1, 1 ≤ m ≤ 300) — the number of rows and places in each row respectively.
  
  The second line of each test case contains n ⋅ m integers a_1, a_2, …, a_{n ⋅ m} (1 ≤ a_i ≤ 10^9), where a_i is the sight level of i-th person.
  
  It's guaranteed that the sum of n ⋅ m over all test cases does not exceed 10^5.
  
  Output
  
  For each test case print a single integer — the minimal total inconvenience that can be achieved.
  
  Example
  
  Input
  
  
  4
  1 3
  1 2 3
  1 5
  2 1 5 3 3
  1 2
  2 1
  1 6
  2 3 2 1 1 1
  
  
  Output
  
  
  3
  6
  0
  1
  
  Note
  
  In the first test case, there is a single way to arrange people, because all sight levels are distinct. The first person will sit on the first seat, the second person will sit on the second place, the third person will sit on the third place. So inconvenience of the first person will be 0, inconvenience of the second person will be 1 and inconvenience of the third person will be 2. The total inconvenience is 0 + 1 + 2 = 3.
  
  In the second test case, people should sit as follows: s_1 = 2, s_2 = 1, s_3 = 5, s_4 = 4, s_5 = 3. The total inconvenience will be 6.
solution: import sys
  import math
  import heapq
  import bisect
  from collections import Counter
  from collections import defaultdict
  from io import BytesIO, IOBase
  from itertools import permutations
  import string
  
  
  class FastIO(IOBase):
      newlines = 0
  
      def __init__(self, file):
          import os
          self.os = os
          self._fd = file.fileno()
          self.buffer = BytesIO()
          self.writable = "x" in file.mode or "r" not in file.mode
          self.write = self.buffer.write if self.writable else None
          self.BUFSIZE = 8192
  
      def read(self):
          while True:
              b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, self.BUFSIZE))
              if not b:
                  break
              ptr = self.buffer.tell()
              self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
          self.newlines = 0
          return self.buffer.read()
  
      def readline(self):
          while self.newlines == 0:
              b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, self.BUFSIZE))
              self.newlines = b.count(b"\n") + (not b)
              ptr = self.buffer.tell()
              self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
          self.newlines -= 1
          return self.buffer.readline()
  
      def flush(self):
          if self.writable:
              self.os.write(self._fd, self.buffer.getvalue())
              self.buffer.truncate(0), self.buffer.seek(0)
  
  
  class IOWrapper(IOBase):
      def __init__(self, file):
          self.buffer = FastIO(file)
          self.flush = self.buffer.flush
          self.writable = self.buffer.writable
          self.write = lambda s: self.buffer.write(s.encode("ascii"))
          self.read = lambda: self.buffer.read().decode("ascii")
          self.readline = lambda: self.buffer.readline().decode("ascii")
  
  
  sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
  input = lambda: sys.stdin.readline().rstrip("\r\n")
  
  
  def get_int():
      return int(input())
  
  
  def get_ints():
      return list(map(int, input().split(' ')))
  
  
  def get_int_grid(n):
      return [get_ints() for _ in range(n)]
  
  
  def get_str():
      return input().strip()
  
  
  def get_strs():
      return get_str().split(' ')
  
  
  def flat_list(arr):
      return [item for subarr in arr for item in subarr]
  
  
  def yes_no(b):
      if b:
          return "YES"
      else:
          return "NO"
  
  
  def binary_search(good, left, right, delta=1, right_true=False):
      """
      Performs binary search
      ----------
      Parameters
      ----------
      :param good: Function used to perform the binary search
      :param left: Starting value of left limit
      :param right: Starting value of the right limit
      :param delta: Margin of error, defaults value of 1 for integer binary search
      :param right_true: Boolean, for whether the right limit is the true invariant
      :return: Returns the most extremal value interval [left, right] which is good function evaluates to True,
              alternatively returns False if no such value found
      """
  
      limits = [left, right]
      while limits[1] - limits[0] > delta:
          if delta == 1:
              mid = sum(limits) // 2
          else:
              mid = sum(limits) / 2
          if good(mid):
              limits[int(right_true)] = mid
          else:
              limits[int(~right_true)] = mid
      if good(limits[int(right_true)]):
          return limits[int(right_true)]
      else:
          return False
  
  
  def prefix_sums(a):
      p = [0]
      for x in a:
          p.append(p[-1] + x)
      return p
  
  
  def solve_a():
      n, s = get_ints()
      return s // ((n + 2) // 2)
  
  
  def solve_b():
      s = get_str()
      if '0' not in s:
          return 0
      x = [c for c in s.split('1') if c]
      if len(x) == 1:
          return 1
      else:
          return 2
  
  
  def solve_c():
      n = get_int()
      s1 = get_str()
      s2 = get_str()
  
      cnt = 0
  
      i = 0
      while i < n:
          if len({s1[i], s2[i]}) == 2:
              cnt += 2
              i += 1
          elif s1[i] == s2[i] == '0':
              if i < n - 1 and '0' not in {s1[i + 1], s2[i + 1]}:
                  cnt += 2
                  i += 2
              else:
                  cnt += 1
                  i += 1
          elif s1[i] == s2[i] == '1':
              if i < n - 1 and '0' in {s1[i + 1], s2[i + 1]}:
                  cnt += 2
                  i += 2
              else:
                  i += 1
  
      return cnt
  
  
  def solve_d1():
      n, m = get_ints()
      a = get_ints()
  
      ai = [(x, -i) for (i, x) in enumerate(a)]
      cnt = 0
      for i in range(m):
          for j in range(i + 1, m):
              if ai[i] < ai[j]:
                  cnt += 1
  
      return cnt
  
  
  t = get_int()
  for _ in range(t):
      print(solve_d1())
  