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

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

    res = ['YES']
    for pc in enumerate(range(2, d - r + 2), 1):
        res.append('%d %d' % pc)
    rest = list(range(n, d - r + 1, -1))
    try:
        dfs(1, r, rest)
        for p in range(2, d - r + 1):
            dfs(p, d - r + 1 - p, rest, k - 2)
    except IndexError:
        pass
    print('\n'.join(res))


if __name__ == '__main__':
    main()
