# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), <s>18</s> 17 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage) Dª€gà©nи®ô¹ì²ζø®∍ [Try it online](https://tio.run/##yy9OTMpM/f/f5dCqR01r0g8vOLQy78KOQ@sObzm08/CaQ5vObTsM5D3q6P3/PzraMFYn2giIjYHYRMc0NpbLAgA) or [verify all test cases](https://tio.run/##yy9OTMpM/V@m5JlXUFpSbKWgZF@ZUGyvpJCYlwJk63Ap@ZeWAGWAEjqVCaFhEZH/XQ6tetS0Jv3wgkMr8y7sOLTu8JbIw2sizm07DGQ/6uj9r3Nom/3/aCAw1DHVMY7ViTbRMQWShjpGQGgaG6tjEaujEB0dq2MApqNBQlCmAYgRbYAQAGky1jFBEgDKGwExzFyQabEA). **Explanation:** <!-- language-all: lang-python --> D # Duplicate the first (implicit) input-matrix ª # Append the matrix to itself € # Map over each inner list: g # Pop and push its length à # Pop and push the maximum # (we now have the dimension of the output-square, which is either # equal to the amount of rows or amount of columns, whichever of # the two is larger) © # Store this maximum in variable `®` (without popping) n # Square it и # Repeat the second (implicit) input that amount of times as list ®ô # Split it into parts of size `®` ¹ì # Prepend the first input-matrix at the front ζ # Zip/transpose; swapping rows/columns, ² # using the second input-character as filler ø # And then zip/transpose the rows/columns back ®∍ # Shorten the matrix to the first `®` amount of rows # (after which the resulting matrix is output implicitly)