line = raw_input().split(' ') n = int(line[0]) m = int(line[1]) sumB = 0 sumW = 0 for i in range(n): line = raw_input().split(' ') wi = int(line[0]) bi = int(line[1]) max = m - wi if m-bi < max: sumB += bi else: sumW += wi print(sumB,sumW)