Under construction

Still being built. Things may change

Bru and the Orange Split

Time limit0.1sMemory limit1024 MB

Summary
Given counts X of ascending pairs and Y of descending pairs, the task is to build the shortest sequence of values from 1 to 10^9 that has exactly those counts.
Level

Medium7 of 10

Topics
Combinatorics, Greedy, Implementation
Solved
No attempts yet

Problem

Bru has a warehouse with 10910^9 oranges of each taste from 11 to 10910^9. Bru wants to share the oranges with friends.

Bru will invite a total of NN friends. The value of NN is not yet fixed. The NN friends stand in a line and each takes one orange from Bru. Bru wants to give out the oranges so that the following conditions hold.

Let the friends be numbered 11, 22, ⋯\cdots, NN in the order they arrive. Let AiA_i be the taste of the orange given to friend ii. Then,

  • The number of pairs (i,j)(i, j) with i<ji<j and Ai<AjA_i < A_j is XX.
  • The number of pairs (i,j)(i, j) with i<ji<j and Ai>AjA_i > A_j is YY.

If several ways satisfy these conditions, Bru wants to save oranges and picks the way with the smallest NN. Write a program that invites friends and gives out oranges so that Bru's conditions are met.

Input

The first line contains two integers XX and YY, separated by a space.

Output

The first line prints the number of friends NN.

The second line prints the tastes A1,A2,⋯ ,ANA_1, A_2, \cdots, A_N of the oranges given to the NN friends, separated by spaces.

If several ways are possible, print a way with the smallest NN. If there are still several such ways, print any of them.

It is guaranteed that a valid way with N≤106N \le 10^6 always exists.

Constraints

  • 0≤X,Y≤1090 \le X, Y \le 10^9
  • X+Y>0X + Y > 0
  • Each element of AA is an integer from 11 to 10910^9.

Examples2

  1. Example 1

    Input
    2 2
    
    Expected output
    4
    1 2 2 1
    
  2. Example 2

    Input
    7 3
    
    Expected output
    5
    1 2 5 4 3