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

#define ll long long

int main()
{
    int t;
    cin >> t;
    while(t--) {
        int n, m;
        cin >> n >> m;
        ll a[n], b[n];
        bool razl_a = false, razl_b = false;
        ll min_razlika = LONG_MAX;
        ll start = LONG_MAX;
        for (int i = 0; i < n; i++) {
            cin >> a[i];
            if (i > 0) {
                if (a[i] % 2 != a[i-1] % 2) razl_a = true;
            }
            start = min(start, a[i]);
        }
        for (int i = 0; i < m; i++) {
            cin >> b[i];
        }


        sort(a, a+n);
        for (int i = 1; i < n; i++) {
            min_razlika = min(min_razlika, a[i] - a[i-1]);
        }

        int x = min_razlika;
        if (razl_a) {
            if (min_razlika%2 == 0) x = min_razlika-1;
        }
        else {
            if (min_razlika % 2 == 1) x = min_razlika - 1;
        }
        while(x > 1) {
            bool moze = true;
            for (int i = 0; i < m; i++) {
                if ((b[i] - start) % x == 0) {
                    moze = false;
                    break;
                }
            }
            if (moze) break;
            x -= 2;
        }
        if (x <= 1) cout << "ODGOVOR: " << 0 << "\n";
        else cout << "ODGOVOR: " << 1 << "\n";
    }
    return 0;
}