A rooted tree has 1023 vertices. Vertex 1 is the root, and the two children of vertex v are vertex 2v and vertex 2v+1. Under this rule each natural number from 1 to 1023 is attached to exactly one vertex. Vertices numbered 512 to 1023 have no children. The top four levels look like this.
1
2 3
4 5 6 7
8 9 10 11 12 13 14 15
Let M(a,b) be the largest vertex number that lies on both the path from vertex 1 to vertex a and the path from vertex 1 to vertex b. For example, M(4,11)=2 and M(7,12)=3.
Given two natural numbers A and B, let M(A,B)=k. Write a program that computes 10k.