import sys

input = sys.stdin.readline

def main():

	a = input().split(" ")
	n = int(a[0])
	d = int(a[1])
	k = int(a[2])

	if d > n - 1:
		sys.stdout.write("NO\n")
		return

	par = [-1 for i in range(n)]
	atdep = [0 for i in range(n)]
	bad = [False for i in range(n)]
	prevlevel = [0]
	clevel = []
	cdep = 1
	callow = k
	cnode = 1

	for i in range(1, n):

		if len(clevel) == callow:
			prevlevel = clevel
			clevel = []
			cdep += 1
			callow *= (k - 1)

		cdiv = k
		if cdep > 1:
			cdiv -= 1

		if cdiv == 0:
			sys.stdout.write("NO\n")
			return

		par[cnode] = prevlevel[len(clevel) // cdiv]
		atdep[cnode] = cdep
		clevel.append(cnode)

		cnode += 1

	mdep = d // 2

	firstchild = callow // cdiv

	g = [[] for i in range(n)]
	for i in range(1, n):
		g[par[i]].append(i)
		g[i].append(par[i])

	endpoints = []

	def dfs(c, l, d):
		cans = [c, d]
		for j in g[c]:
			if j == l:
				continue
			ov = dfs(j, c, d + 1)
			if ov[1] > cans[1]:
				cans = ov
		return cans

	for i in g[0]:
		endpoints.append(dfs(i, 0, 1))

	cd = 0
	for j in range(2):
		if j >= len(endpoints):
			break
		cd += endpoints[j][1]

	if cd > d:
		sys.stdout.write("NO\n")
		return

	if len(endpoints) > 1:
		a1 = endpoints[0][0]
		a2 = endpoints[1][0]
		d1 = endpoints[0][1]
		d2 = endpoints[1][1]

		temp = a1
		while temp != -1:
			bad[temp] = True
			temp = par[temp]
		temp = a2
		while temp != -1:
			bad[temp] = True
			temp = par[temp]

		for j in range(n - 1, -1, -1):
			if bad[j]:
				continue
			if d2 < d1:
				par[j] = a2
				a2 = j
				d2 += 1
			else:
				par[j] = a1
				a1 = j
				d1 += 1

	sys.stdout.write("YES\n")
	for i in range(1, n):
		sys.stdout.write(str(i + 1) + " " + str(par[i] + 1) + "\n")


main()