import sys input = lambda :sys.stdin.readline()[:-1] ni = lambda :int(input()) na = lambda :list(map(int,input().split())) yes = lambda :print("yes");Yes = lambda :print("Yes") no = lambda :print("no");No = lambda :print("No") ####################################################################### b = 500 def dist(a, b): return abs(a[0] - b[0]) + abs(a[1] - b[1]) for _ in range(ni()): n, l = na() l += 1 p = [] for i in range(n): x, y = na() p.append([x*b//l,[y if (x*b//l)%2 else -y] , x, y]) p = sorted(p) print(n) s = 0 for i in range(n): s += dist(p[i][2:], p[(i+1)%n][2:]) print(*p[i][2:]) assert s <= 1000*(l-1)