def main():
    n, d, k = map(int, input().split())
    if k == 1 and d != n - 1 or k > 1 and (k ** ((d // 2) + 1) - 1) // (k - 1) * (d % 2 + 1) - d % 2 < n:
        print('NO')
        return

    def dfs(parent, depth, src, degree=k - 1):
        for _ in range(degree):
            child = src.pop()
            res.append('%s %s' % (parent, child))
            if depth:
                dfs(child, depth - 1, src)

    res = ['YES']
    if d % 2:
        try:
            dfs(1, d // 2, list(range(n, 1, -1)), k)
        except IndexError:
            pass
    else:
        res.append('1 2')
        try:
            dfs(1, d // 2, list(range(n + n % 2 - 1, 1, -2)))
        except IndexError:
            pass
        try:
            dfs(2, d // 2, list(range(n - n % 2, 2, -2)))
        except IndexError:
            pass
    print('\n'.join(res))


if __name__ == '__main__':
    main()
