<jupyter_start><jupyter_text>https://www.hackerearth.com/practice/data-structures/arrays/multi-dimensional/practice-problems/algorithm/monk-and-inversions-arrays-strings/<jupyter_code>1 2 3
4 5 6
7 8 9

4 3
1 4

0
2
T = int(input())

for _ in range(T):
    n = int(input())

    m = []
    for i in range(n):
        m.append(list(map(int, input().split())))

    count = 0

    for i in range(n):
        for j in range(n):

            for k in range(i, n):
                for l in range(j, n):
                    if m[i][j] > m[k][l]:
                        count += 1

    print(count)
n = 3
m = [[1,2,3],[4,5,6],[7,8,9]]

n = 2
m = [[4,3],[1,4]]


count = 0

for i in range(n):
    for j in range(n):
        
        for k in range(i, n):
            for l in range(j, n):
                if m[i][j] > m[k][l]:
                    count += 1
                    print(check, m[k][l])

print(count)<jupyter_output>4 3 
1 4 
9 3
9 1
2
{'fraction_non_alphanumeric': 0.1636556854410202, 'fraction_numerical': 0.04569606801275239, 'mean_word_length': 1.6837606837606838, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 6, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '628920', 'license': 'MIT', 'n_tokens_mistral': 409, 'n_tokens_neox': 367, 'n_words': 99, 'path': 'HackerEarth/Monk and Inversions.ipynb', 'repo_name': 'deepaksood619/Python-Competitive-Programming', 'size': '941'}