Vasily has a number a, which he wants to turn into a number b. For this purpose, he can do two types of operations:  multiply the current number by 2 (that is, replace the number x by 2·x);  append the digit 1 to the right of current number (that is, replace the number x by 10·x + 1). 

You need to help Vasily to transform the number a into the number b using only the operations described above, or find that it is impossible.

Note that in this task you are not required to minimize the number of operations. It suffices to find any way to transform a into b.


-----Input-----

The first line contains two positive integers a and b (1 ≤ a < b ≤ 10^9) — the number which Vasily has and the number he wants to have.


-----Output-----

If there is no way to get b from a, print "NO" (without quotes).

Otherwise print three lines. On the first line print "YES" (without quotes). The second line should contain single integer k — the length of the transformation sequence. On the third line print the sequence of transformations x_1, x_2, ..., x_{k}, where:  x_1 should be equal to a,  x_{k} should be equal to b,  x_{i} should be obtained from x_{i} - 1 using any of two described operations (1 < i ≤ k). 

If there are multiple answers, print any of them.


-----Examples-----
Input
2 162

Output
YES
5
2 4 8 81 162 

Input
4 42

Output
NO

Input
100 40021

Output
YES
5
100 200 2001 4002 40021

Difficulty: interview

Starter code:

Solutions:
3

prev = dict()

def dfs(a, b):
    if a > b:
        return
    if 2 * a not in prev:
        prev[2 * a] = a
        dfs(2 * a, b)
    if 10 * a + 1 not in prev:
        prev[10 * a + 1] = a
        dfs(10 * a + 1, b)



a, b = list(map(int, input().split()))
dfs(a, b)

if b not in prev:
    print("NO")
else:
    print("YES")
    path = []
    while b != a:
        path.append(b)
        b = prev[b]
    path.append(a)
    path.reverse()
    print(len(path))
    print(*path)


a, b = list(map(int, input().split()))
k = [b]
f = 1
while b > a:
    if (b % 10 == 1):
        b -= 1
        b //= 10
    elif (b % 2 == 0):
        b //= 2
    else:
        f = 0
        break
    k.append(b)
else:
    k.reverse()
    if (k[0] == a):
        print("YES")
        print(len(k))
        print(*k)
    else:
        print("NO")
if f == 0:
    print("NO")


# You lost the game.
a,b = map(int, input().split())
R = [b]
ok = 1
while b > a:
    while b % 10 != 1 and b > a:
        if b % 2 == 1:
            ok = 0
            break
        else:
            b = b//2
            R += [b]
    if b > a:
        b = (b-1)//10 
        R += [b]
if ok == 0 or b < a:
    print("NO")
else:
    print("YES")
    print(len(R))
    for i in range(len(R)):
        print(R[len(R)-1-i],end=" ")


def canoperate(n):
    return str(n)[-1] == "1" and str(n) != "1" or n % 2 == 0

def operate(n):
    if n % 2 == 0:
        return n // 2
    else:
        return (n - 1) // 10

a, b = map(int, input().split())
res = [b]
while canoperate(b):
    b = operate(b)
    res.append(b)
    if b == a:
        print("YES")
        print(len(res))
        print(*res[::-1])
        break
else:
    print("NO")

read = lambda: list(map(int, input().split()))
a, b = read()
Q = [a]
prev = dict()
st = 0
while st < len(Q):
    cur = Q[st]
    st += 1
    if cur * 2 <= b:
        Q.append(cur * 2)
        prev[cur * 2] = cur
    if cur * 10 + 1 <= b:
        Q.append(cur * 10 + 1)
        prev[cur * 10 + 1] = cur
if prev.get(b) is None:
    print('NO')
    return
print('YES')
ans = []
cur = b
while cur != a:
    ans.append(cur)
    cur = prev[cur]
ans.append(a)
print(len(ans))
print(*ans[::-1])


a, b = map(int, input().split())
ans = [b]
while b > a:
    if b % 10 == 1:
        b //= 10
        ans += [b]
    elif b % 2 == 0:
        b //= 2
        ans += [b]
    else:
        break
if b == a:
    print('YES')
    print(len(ans))
    ans.reverse()
    print(' '.join(list(map(str, ans))))
else:
    print('NO')

a, b = map(int, input().split())
ans = []
f = True
while b >= a:
    ans.append(b)
    if b % 10 == 1:
        b //= 10
    elif b % 2 == 0:
        b //= 2
    else:
        if b != a:
            f = False
        break
if ans[-1] != a:
    print("NO")
else:
    print("YES")
    print(len(ans))
    print(*ans[::-1])

n, m = list(map(int, input().split()))
steps = [m]
while (m > n):
    if (m % 2 == 0):
        m //= 2
    elif (m % 10 == 1):
        m //= 10
    else:
        break
    steps.append(m)
if (m != n):
    print("NO")
else:
    print("YES")
    steps.reverse()
    print(len(steps))
    print(*steps)

a, b = list(map(int, input().split()))
queue = [a]
qstart = 0
prev = dict()
prev[a] = -1
while qstart + 1 <= len(queue):
    our = queue[qstart]
    qstart += 1
    if our * 2 <= 10 ** 9 and our * 2 not in prev:
        queue.append(our * 2)
        prev[our * 2] = our
    t = our * 10 + 1
    if t <= 10 ** 9 and t not in prev:
        queue.append(t)
        prev[t] = our
if b in prev:
    print('YES')
    res = []
    curr = b
    while curr != -1:
        res.append(curr)
        curr = prev[curr]
    print(len(res))
    print(' '.join(map(str, res[::-1])))
else:
    print('NO')


a, b = map(int, input().split())
do = []
while True:
    do.append(b)
    if b == a:
        break
    if b % 2 == 0:
        b //= 2
    elif str(b)[-1] == '1':
        if b == 1:
            if a == 1:
                break
            else:
                print("NO")
                return                
        else:
            b = int(str(b)[:-1])
    else:
        print("NO")
        return
do = do[::-1]
print("YES")
print(len(do))
print(*do)

a, b = list(map(int, input().split()))
ans = []
fl = False
ans.append(b)
while b > a:
    if b % 2 == 0:
        b //= 2
        ans.append(b)
    else:
        if b % 10 == 1:
            b //= 10
            ans.append(b)
        else:
            fl = True
            print('NO')
            break

if not fl and b == a:
    print('YES')
    print(len(ans))
    print(*ans[::-1])
elif not fl:
    print('NO')

a, b = list(map(int, input().split()))
ans = [b]
while (b % 10 == 1 or b % 2 == 0) and b > 0 and b > a:
    if b % 2 == 0:
        b //= 2
        ans.append(b)
    elif b % 10 == 1 and b != 1:
        b = int(str(b)[:-1])
        ans.append(b)
    elif b == 1:
        ans.append(1)
        break
    
if a == b:
    print('YES')
    print(len(ans))
    print(*(reversed(ans)))
else:
    print('NO')


a, b = map(int, input().split())
pred = [str(b)]
while a != b and b > a:
    if b % 10 == 1 and b != 1:
        b = b // 10
        pred.append(str(b))
    elif b % 2 == 0:
        b = b // 2
        pred.append(str(b))
    else:
        break
if a != b:
    print('NO')
else:
    print('YES')
    print(len(pred))
    pred.reverse()
    print(' '.join(pred))

a, b = list(map(int, input().split()))
arr = [str(b)]
while b > a:
    if b % 10 == 1:
        b //= 10
        arr.append(str(b))
    elif b % 2 == 0:
        b //= 2
        arr.append(str(b))
    else:
        b = -1
if b == a:
    arr.reverse()
    print('YES', len(arr), ' '.join(arr), sep='\n')
else:
    print('NO')
    

rez = 'NO'
ms = []
def gen(a,b, mas):
    nonlocal rez,ms
    if a == b:
        rez = 'YES'
        ms = mas[:]
    elif a < b:
        gen(a*2,b,mas + [a*2])
        gen(a*10+1,b,mas + [a*10+1])
a,b = list(map(int, input().split()))
gen(a,b,[a])
if rez == 'YES':
    print(rez);
    print(len(ms))
    print(*ms)
else: print(rez)


a, b = [int(x) for x in input().split()]
ans = [b]
while b > a:
    if b % 2 == 1 and str(b)[-1] != '1':
        print("NO")
        break
    if b % 2 == 1 and str(b)[-1] == '1':
        b = b // 10
        ans.append(b)
        continue
    if b % 2 == 0:
        b = b // 2
        ans.append(b)
        continue
else:
    if b != a:
        print("NO")
    else:
        print("YES")
        print(len(ans))
        for i in range(len(ans)):
            print(ans[len(ans) - i - 1], end = " ")

a, b = map(int, input().split())
ans = [b]

while (b > a):
    if (b % 2 == 0):
        b //= 2
        ans.append(b)
    elif (b % 10 == 1):
        b //= 10
        ans.append(b)
    else:
        break

if (b == a):
    print('YES')
    print(len(ans))
    print(*reversed(ans))
else:
    print('NO')

a, b = map(int, input().split())

flag = True
ans = []

while b > a:
    if b % 2 == 0:
        ans.append(b)
        b //= 2
    elif b % 10 == 1:
        ans.append(b)
        #print(b)
        b = (b - 1) // 10
    else:
        b = -1
ans.append(b)

if b != a:
    print("NO")
else:
    print("YES")
    print(len(ans))
    for i in range(len(ans) - 1, -1, -1):
        print(ans[i], end = " ")

q,w=map(int,input().split())
a=[]
while w>q:
	if w%10==1:
		a.append(w)
		w//=10
	elif w%2==1:
		w=q-1
	else:
		a.append(w)
		w//=2
a.append(w)
if w==q:
	print("YES")
	print(len(a))
	for i in a[::-1]:
		print(i,end=' ')
else:
	print('NO')

#!/usr/bin/env python3


def convert(a, b):
    path = [b]
    while b != a:
        if b % 2 == 0 and b > 0:
            b //= 2
            path.append(b)
        elif b % 10 == 1:
            b //= 10
            path.append(b)
        else:
            return None
    return reversed(path)


def main():
    ans = convert(*list(map(int, input().split())))
    if ans is None:
        print("NO")
    else:
        print("YES")
        path = list(ans)
        print(len(path))
        print(*path)


def __starting_point():
    main()

__starting_point()

def actionA(i):
    return i // 2

def actionB(i):
    return (i - 1) // 10

def getAction(i):
    if not (i % 2):
        return actionA
    elif (i % 10) == 1:
        return actionB
    else:
        return None

def fail():
    print('NO')

def m():
    i, j = (int(a) for a in input().split(' '))
    l = [j]
    while True:
        act = getAction(j)
        if act is None:
            return fail()
        j = act(j)
        l.append(j)
        if j < i:
            return fail()
        if j == i:
            break
    l.reverse()
    print('YES', len(l), ' '.join(str(i) for i in l), sep='\n')  # success!

def __starting_point():
    m()


__starting_point()

from math import *
a ,b = map(int, input().split())
ans = [b]
per = 0
while b > a:
    if str(b)[-1] == '1':
        b = int(str(b)[:-1])
        ans.append(b)
    elif b % 2 == 0:
        b = b // 2
        ans.append(b)
    else:
        per = 1
        break
if per == 0 and b == a:
    print('YES')
    print(len(ans))
    ans.reverse()
    print(' '.join(map(str, ans)))
else:
    print('NO')

a, b = map(int, input().split())
flag = True
order = [b]
while b > a:
    if b % 2 == 0:
        b //= 2
        order.append(b)
    elif b % 10 == 1:
        b //= 10
        order.append(b)
    else:
        break
if b == a:
    print("YES")
    print(len(order))
    for i in range(len(order) - 1, -1, -1):
        print(order[i], end=" ")
else:
    print("NO")