import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int caseNum = in.nextInt();
int paraNum, pageNum, width, height;
while (caseNum-- != 0) {
pageNum = in.nextInt(); // 页数
paraNum = in.nextInt(); // 段落的个数
width = in.nextInt(); // 宽
height = in.nextInt(); // 高
int [] charNum = new int[pageNum]; // 每段的字数
for (int i = 0; i < pageNum; i++) {
charNum[i] = in.nextInt();
}
int minSide = Math.min(width, height);
// i 表示字号,一个一个地试
for (int fontSize = minSide; fontSize >= 0; fontSize--) {
int charNumPerLine = width / fontSize; // 每行的字数
int lineNumPerPage = height / fontSize; // 每一页的行数
int rowNum = 0; // 总行数
for (int j = 0; j < pageNum; j++){
rowNum += charNum[j] / charNumPerLine;
if (charNum[j] % charNumPerLine!=0) {
rowNum++;
}
}
int page = rowNum / lineNumPerPage; // 总页数
if (rowNum % lineNumPerPage != 0) page++;
if (page <= paraNum){
System.out.println(fontSize);
break;
}
}
}
}
}