#include <iostream>
#include <string>
#include <map>
#include <cstdio>
#include <vector>
#include <complex>
#include <cassert>

using namespace std;

#define X real()
#define Y imag()
#define at(i) ((*this)[i])
#define SELF (*this)
    enum {TRUE = 1, FALSE = 0, BORDER = -1};
    typedef int BOOL;
    typedef long double R;
    const R INF = 1e8;
    R EPS = 1e-12;
    const R PI = 3.1415926535897932384626;
    inline int sig(const R &x) { return (abs(x) < EPS ? 0 : x > 0 ? 1 : -1); }
    inline BOOL less(const R &x, const R &y) {return sig(x-y) ? x < y : BORDER;}

    typedef complex<R> P;
inline R norm(const P &p){return p.X*p.X+p.Y*p.Y;}
inline R inp(const P& a, const P& b){return (conj(a)*b).X;}
inline R outp(const P& a, const P& b){return (conj(a)*b).Y;}
inline P unit(const P& p){return p/abs(p);}
inline P proj(const P &s, const P &t){return t*inp(s, t)/norm(t);}
inline int ccw(const P &s, const P &t, const P &p, int adv=0){
    int res = sig(outp(t-s, p-s));
    if(res || !adv) return res;
    if(sig(inp(t-s, p-s)) < 0) return -2; // p-s-t
    if(sig(inp(s-t, p-t)) < 0) return 2; // s-t-p
    return 0; // s-p-t
}
struct L : public vector<P>{ // line
    L(const P &p1, const P &p2){this->push_back(p1);this->push_back(p2);}
    L(){}
    P dir()const {return at(1) - at(0);}
    BOOL online(const P &p)const {return !sig(outp(p-at(0), dir()));}
};
struct S : public L{ // segment
    S(const P &p1, const P &p2):L(p1, p2){}
    S(){}
    BOOL online(const P &p)const {
        if(!sig(norm(p - at(0))) || !sig(norm(p - at(1)))) return BORDER;
        // 座標の二乗とEPS の差が大きすぎないように注意
        return !sig(outp(p-at(0), dir())) && inp(p-at(0), dir()) > EPS && inp(p-at(1), -dir()) > -EPS;
//return !sig(abs(at(0)-p) + abs(at(1) - p) - abs(at(0) - at(1)));
    }
};

// 交差判定
BOOL intersect(const S &s, const S &t){
    const int p = ccw(t[0], t[1], s[0], 1) * ccw(t[0], t[1], s[1], 1);
    const int q = ccw(s[0], s[1], t[0], 1) * ccw(s[0], s[1], t[1], 1);
    return (p>0||q>0) ? FALSE : (!p||!q) ? BORDER : TRUE;
}

inline P crosspoint(const L &l, const L &m, bool& sat){
        sat = true;
       R A = outp(l.dir(), m.dir()), B = outp(l.dir(), l[1] - m[0]);
       if(!sig(abs(A)) && !sig(abs(B))) return m[0]; // same line
       //if(abs(A) < EPS) assert(false); // !!!PRECONDITION NOT SATISFIED!!!
       if(abs(A) < EPS){
           sat = false;
           return {};
       }
       return m[0] + B / A * (m[1] - m[0]);
} 
#undef SELF
#undef at


#define rep(i,n) for(int i = 0; i < (n); ++i)
#define reps(i,a,n) for(int i = (a); i < (n); ++i)

vector<S> G;
vector<P> A;

int main(){
    int n,m;
    cin >> n >> m;
    
    rep(i, n){
        int l;
        cin >> l;
        vector<P> z;
        rep(i, l){
            int x,y;
            cin >>x >> y;
            z.emplace_back(x, y);
        }
        rep(i, l){
            G.emplace_back(z[i], z[(i+1)%l]);
        }
    }
    {
        vector<P> z;
        z.emplace_back(-10000000, -10000000);
        z.emplace_back(-10000000,  10000000);
        z.emplace_back( 10000000,  10000000);
        z.emplace_back( 10000000, -10000000);
        G.emplace_back(z[0], z[1]);
        G.emplace_back(z[1], z[2]);
        G.emplace_back(z[2], z[3]);
        G.emplace_back(z[3], z[0]);
    }

    rep(i, m){
        int x,y;
        cin >> x >> y;
        A.emplace_back(x, y);
    }
    int ans = 1;
    rep(i, m){
        rep(j, G.size()){
            L LI(A[i], G[j][0]);
            reps(k, i+1, m){
                reps(l, j+1, G.size()){
                    L NE(A[k], G[l][0]);
                    // cout << "$" << LI[0] << LI[1] << "  " << NE[0] << NE[1] << endl;
                    bool sat;
                    P p = crosspoint(LI, NE, sat);
                    if(!sat) continue;
                    int an = 0;
                    rep(a, m){
                        S aa(A[a], p);
                        bool ok = true;
                        rep(b, G.size()){
                            auto r = intersect(aa, G[b]);
                            if(r == TRUE){
                                ok = false;
                                break;
                            }
                        }
                        if(ok) ++an;
                    }
                    ans = max(ans, an);
                }
            }
        }
    }
    cout << ans << endl;


    
}


Measured memory_bytes: 3104