Why this brute-force is not working?(Codeforces Round #664 C)

Hey, Can anybody tells why this bruteforce not working.
link to qs: Problem - C - Codeforces.
my sol :

#include <bits/stdc++.h>
using namespace std;
#define int long long

int dp[201];

const int mx = 1e9;

int solve(int *arr, int *brr, int index, int n, int m)
{
if (index >= n)
return 0;
if (dp[index] != -1)
return dp[index];
int res = mx * mx;
for (int j = 0; j < m; j++)
{
int temp = (arr[index] & brr[j]);
temp |= solve(arr, brr, index + 1, n, m);
res = min(res, temp);
}
return dp[index] = res;
}

signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);

int n, m;
cin >> n >> m;

int arr[n], brr[m];
for (int i = 0; i < n; i++)
    cin >> arr[i];
for (int j = 0; j < m; j++)
    cin >> brr[j];
memset(dp, -1, sizeof(dp));
cout << solve(arr, brr, 0, n, m);

return 0;

}

consider this case
2 2
13 7
11 5
your ans 7((13&5)|(7&11))
actual ans 5((13&5)|(7&5))
actually last index of arr a returns 3 (i.e 7&11)always but if it would have returned 5(7&5) the ans would be 5.