/*
       shool : Cu Chi High School
       participant : Ngo Quoc Binh
*/
#include <bits/stdc++.h>
using namespace std;

#define debug(x) cerr << #x << " = " << x << "\n";
#define vdebug(a) cerr << #a << " = "; for(auto x : a) cout << x << " "; cout << "\n";
#define TIME cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s\n";
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define hashmap unordered_map
#define hashset unordered_set
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rev(x) reverse(all(x))
#define sz(x) ((int)((x).size()))
#define max_arr(x) *max_element(all(x))
#define min_arr(x) *min_element(all(x))

#define pb push_back
#define pf push_front
#define PB pop_back
#define PF pop_front
#define en '\n'
#define ff first
#define ss second
#define task "wtf"

using ll = long long;
using ull = unsigned long long;
using ld = long double;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

void solve()
{
        int n,m,d;
        cin >> n >> m >> d;

        set<vector<int>> a;
        for(int i = 0 ; i < n ; i++)
        {
                vector<int> res(d + 1);
                for(int j = 0 ; j <= d ; j++) cin >> res[j];
                a.insert(res);
        }

        for(int i = 0 ; i < m ; i++)
        {
                vector<int> res(d + 1);
                for(int j = 0 ; j <= d ; j++) cin >> res[j];
                if(a.count(res)) cout << "BAD" << en;
                else cout << "GOOD" << en;
        }
}

int main()
{
        fastIO

        solve();

        return 0;
}