N=input() M=input() assert(1<=len(N)) assert(len(N)<=100000) assert(1<=len(M)) assert(len(M)<=100000) assert((N=='0')or(N[0]!='0')) assert((N=='0')or(N[0]!='0')) assert((M=='0')or(M[0]!='0')) S='0,1,w,2,w^w,w+1,w,3,w^2,w^(w)+1,w2,w+2,w^w,w+1,w,4,w^w^w' S=S.split(',') X=[0,1,5,2,10,6,5,3,9,11,8,7,10,6,5,4,12] X=[X[i]+1 for i in range(len(X))] def f(N): P=[] b=0 while N: if N&1: v=X[b] P.append(v) b=0 else: b+=1 N>>=1 P=P[::-1] A=[] for i in range(len(P)): while len(A)>0 and A[-1][0]0 and A[-1][0]==P[i]: A[-1]=(A[-1][0],A[-1][1]+1) else: A.append((P[i],1)) return tuple(A) def ord_then(X,Y): for i in range(min(len(X),len(Y))): if X[i]>Y[i]: return -1 if X[i]len(Y): return -1 if len(X)0: if ord_then(A[-1],v)==1: del A[-1] else: break A.append(v) for i in range(len(Q)): v=Q[i] while len(B)>0: if ord_then(B[-1],v)==1: del B[-1] else: break B.append(v) if A