print2d
\ndef print2d(a: List[List[int]], cols=None, rows=None) -> None:\n    a = [x[:] for x in a]\n    if rows:\n        if isinstance(rows, int):\n            rows =
```\ndef print2d(a: List[List[int]], cols=None, rows=None) -> None:\n    a = [x[:] for x in a]\n    if rows:\n        if isinstance(rows, int):\n            rows = [x for x in range(rows)]\n        for i in range(len(a)):\n            a[i] = [rows[i]] + a[i]\n    if cols:\n        if isinstance(cols, int):\n            cols = [x for x in range(cols)]\n        if rows:\n            cols = [\'\'] + cols\n        a = [cols] + a\n    l = [0]*len(a[0])\n    for x in a:\n        for i in range(len(x)):\n            l[i] = max(l[i], len(str(x[i])))\n    for x in a:\n        for i in range(len(x)):\n            print(str(x[i]).rjust(l[i]), end=\' \')\n        print()\n    print()\n\nclass Solution:\n    def countOfPairs(self, n: int, x: int, y: int) -> List[int]:\n        x -= 1\n        y -= 1\n        dist = [[sys.maxsize]*n for _ in range(n)]\n        dist[x][y] = 1\n        dist[y][x] = 1\n        for i in range(1, n):\n            dist[i-1][i] = 1\n            dist[i][i-1] = 1\n        for i in range(n):\n            dist[i][i] = 0\n        for k in range(n):\n            for i in range(n):\n                for j in range(n):\n                    dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])\n        r = [0]*n\n        for i in range(n):\n            for j in range(n):\n                if dist[i][j]:\n                    r[dist[i][j]-1] += 1\n        return r\n```\n\n```\nclass Solution:\n    def countOfPairs(self, n: int, x: int, y: int) -> List[int]:\n        x, y = x-1, y-1\n        r = [0]*n\n        for i in range(n-1):\n            for j in range(i+1, n):\n                r[min(j-i, abs(min(abs(i-x), abs(i-y)) + min(abs(j-x), abs(j-y))) + 1) - 1] += 2\n        return r\n```
['Python3']