A,B=map(int,input().split()) S=input() NOW=[A,B] USED=set() USED.add((A,B)) ANS=[] for s in S: if s=="L" and NOW[1]!=0: NOW[1]-=1 USED.add(tuple(NOW)) elif s=="U" and NOW[0]!=0: NOW[0]-=1 USED.add(tuple(NOW)) elif s=="R": x,y=NOW if (x,y+1) in USED: NOW=[x,y+1] else: ANS.append((x,y+1)) elif s=="D": x,y=NOW if (x+1,y) in USED: NOW=[x+1,y] else: ANS.append((x+1,y)) print(len(ANS)) for x,y in ANS: print(x,y)