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]) min = m - wi if m-bi > min: sumW += wi else: sumB += bi print(sumB,sumW)