Python 2, 226 224 204204 193 bytes
-1 byte thanks to Trelzevir
x,s,n=input() j=''.join g=lambda x,i:[eval("_"j(_.replacesplit(' ','')).%sjust(len(_))"%['l','r'][i%2]"%'lr'[i%2])for _ in x] for i in([0,3,1,2]*n)[s:s+n]:x=i<2and mapx=[map(''.joinj,zip(*g(map(''.joinj,zip(*x)),i)))or ,g(x,i);print'\n'][i>1];print'\n'.join(x) Function that remove all spaces of each element in the list and complete with spaces on left or right.
g=lambda x,i:[eval("_"''.replacejoin(_.split(' ','')).%sjust(len(_))"%['l','r'][i%2]"%'lr'[i%2])for _ in x] This to transpose (rotate 90º) when the input is 0 or 1(U or D) and apply g
x=i<2and mapx=[map(''.join,zip(*g(map(''.join,zip(*x)),i)))or ,g(x,i)][i>1]