import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
char c = sc.next().charAt(0);
int f = sc.nextInt();
for (int i = 1; i <= a; i++) {
for (int j = 1; j <= b; j++) {
if(f == 0) {
if(i != 1 && i != a && j != 1 && j !=b) {
System.out.print(' ');
}
else {
System.out.print(c);
}
}
else{
System.out.print(c);
}
}
System.out.println();
}
sc.close();
}
}