#include #include #include #include #warning That's the baby, that's not my baby typedef long long ll; void solve() { int n; std::cin >> n; int a[n]; for (int i = 0; i < n; i++) { std::cin >> a[i]; } int b[n]; for (int i = 0; i < n; i++) { std::cin >> b[i]; } /// e clar ca cel putin una dintre subsecvente se termina pe pozitia n (proof by the proof is left as an excersise for the reader) int answer = 0; // 1. prima subsecventa se termina pe pozitia n for (int r2 = n - 1; r2 >= 0; r2--) { int cur = 0; for (int l2 = r2; l2 >= 0; l2--) { if (a[n - (r2 - l2 + 1)] != b[l2]) { cur++; } answer = std::max(answer, cur); } } // 2. a doua subsecventa se termina pe pozitia n for (int r1 = n - 1; r1 >= 0; r1--) { int cur = 0; for (int l1 = r1; l1 >= 0; l1--) { if (a[l1] != b[n - (r1 - l1 + 1)]) { cur++; } answer = std::max(answer, cur); } } std::cout << answer; } int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(0); int t; std::cin >> t; while (t--) { solve(); std::cout << '\n'; } return 0; }