for (int offset = 0; offset < cnt; offset++) {
for (int i = 0; i < 20; i++) {
sum += a[i + offset] * b[i];
}
}
#include <iostream>
#include <vector>
using namespace std;
int main() {
int test_case;
int T;
cin >> T;
for (test_case = 1; test_case <= T; ++test_case) {
int N, M;
int a[21] = { 0 };
int b[21] = { 0 };
cin >> N >> M;
for (int i = 0; i < N; i++) {
cin >> a[i];
}
for (int i = 0; i < M; i++) {
cin >> b[i];
}
int cnt = abs(N - M) + 1;
int sum = 0, ans = 0;
if (N > M) {
for (int offset = 0; offset < cnt; offset++) {
for (int i = 0; i < 20; i++) {
sum += a[i + offset] * b[i];
}
if (sum > ans) ans = sum;
sum = 0;
}
}
else {
for (int offset = 0; offset < cnt; offset++) {
for (int i = 0; i < 20; i++) {
sum += a[i] * b[i + offset];
}
if (sum > ans) ans = sum;
sum = 0;
}
}
cout << "#" << test_case << " " << ans << endl;
}
return 0;
}