private static String solve(int Gp, int Gc, int Gf, int N, int[][] foods) {
        int itr = (int) Math.pow(2, N); // number of iterations required
        for (int mask = 0; mask < itr; mask++) {
            int GpSum = 0, GcSum = 0, GfSum = 0;
            
            for (int i = 0; i < N; i++) 
                if ((mask & (1 << i)) > 0) { // if the i-th bit of the mask is set
                    GpSum += foods[i][0];
                    GcSum += foods[i][1];
                    GfSum += foods[i][2];
                    
                    if (GpSum > Gp || GcSum > Gc || GfSum > Gf) break;
                }
            
            if (GpSum == Gp && GcSum == Gc && GfSum == Gf) return "yes";
        }
        
        return "no";
    }