This page is still under construction.

Parts of this page are still being built. What you see may change.

Trees

Time limit1sMemory limit256 MB

Summary
Given N and K, build a rooted tree where every internal node has exactly K children, or report impossible, and output the lexicographically smallest edge-list string where space sorts before digits.
Level

Medium7 of 10

Topics
Tree, Greedy, Implementation, Math
Solved
No attempts yet

Problem

Vasya has gone deep into graph theory. He read a chapter about trees, and one problem keeps bothering him: he must build a rooted tree with NN nodes in which every node except the leaves has exactly KK children. The answer is written as a list of edges, and among all valid trees he must find the lexicographically minimal one.

The list of edges is written into a string as follows. Each edge is described by a pair of integers, the numbers of the nodes it connects. The two numbers are written without leading zeroes, with exactly one space character between them. The string consists of the descriptions of all N−1N-1 edges, written consecutively and separated by a single space character. All nodes are numbered from 11 to NN, and the root is node 11.

Vasya must find the lexicographically minimal string that can be produced this way for a rooted tree of the required kind. In lexicographic comparison, the space character is smaller than every digit.

For example, consider a tree with 55 nodes in which every non-leaf node has 22 children. A tree with edges (1,4),(1,5),(4,3),(4,2)(1, 4), (1, 5), (4, 3), (4, 2) satisfies the requirement. Its edge list can be written as a string in several ways:

  • 4 2 4 3 1 4 1 5
  • 2 4 3 4 1 4 1 5
  • 1 4 1 5 2 4 3 4

Each of these is smaller than the previous one, but none is optimal. For these values of NN and KK, the lexicographically minimal string 1 2 1 3 2 4 2 5 comes from a different tree.

Help Vasya solve this task; he has a graph theory test coming up!

Input

The first line of the input file contains two integers NN and KK, where NN is the number of nodes in the required tree and KK is the number of children of each non-leaf node (2≤N≤1052 \le N \le 10^5, 1≤K≤1051 \le K \le 10^5).

Output

If no tree with the specified parameters exists, print the word No on the only line of the output file.

Otherwise, print the word Yes on the first line of the output file, and print the required lexicographically minimal string on the second line.

Examples2

  1. Example 1

    Input
    5 2
    
    Expected output
    Yes
    1 2 1 3 2 4 2 5
    
  2. Example 2

    Input
    4 10
    
    Expected output
    No