#include <iostream>
#include <iomanip>
#include <complex>
#include <vector>
#include <algorithm>
#include <cmath>
#include <array>
using namespace std;
const double EPS = 1e-8;
const double INF = 1e12;
const double PI = acos(-1);
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define X real()
#define Y imag()

typedef complex<double> P;
typedef vector<P> VP;
struct L : array<P, 2>{
    L(const P& a, const P& b){ at(0)=a; at(1)=b; }
    L(){}
};

namespace std{
    bool operator < (const P& a, const P& b){
        return !EQ(a.X,b.X) ? a.X<b.X : a.Y+EPS<b.Y;
    }
    bool operator == (const P& a, const P& b){
        return abs(a-b) < EPS;
    }
}

double dot(P a, P b){
    return (conj(a)*b).X;
}
double cross(P a, P b){
    return (conj(a)*b).Y;
}
int ccw(P a, P b, P c){
    b -= a;
    c -= a;
    if(cross(b,c) > EPS) return +1; //ccw
    if(cross(b,c) < -EPS) return -1; //cw
    if(dot(b,c) < -EPS) return +2; //c-a-b
    if(abs(c)-abs(b) > EPS) return -2; //a-b-c
    return 0; //a-c-b
}

bool intersectSS(const L& a, const L& b){
    return ( ccw(a[0],a[1],b[0]) *ccw(a[0],a[1],b[1]) <= 0 ) &&
        ( ccw(b[0],b[1],a[0]) *ccw(b[0],b[1],a[1]) <= 0 );
}
bool intersectSP(const L& s, const P &p){
    return abs(cross(s[0]-p, s[1]-p))<EPS  && dot(s[0]-p, s[1]-p)<EPS;
}

bool isParallel(const P &a, const P &b){
    return abs(cross(a,b)) < EPS;
}
bool isParallel(const L &a, const L &b){
    return isParallel(a[1]-a[0], b[1]-b[0]);
}

P crosspointLL(const L &l, const L &m) {
  double A = cross(l[1]-l[0], m[1]-m[0]);
  double B = cross(l[1]-l[0], l[1]-m[0]);
  return m[0] + B/A *(m[1]-m[0]);
}

int in_poly(const P &p, const VP &poly){
    int n = poly.size();
    int ret = -1;
    for(int i=0; i<n; i++){
        P a = poly[i]-p;
        P b = poly[(i+1)%n]-p;
        if(a.Y > b.Y) swap(a,b);
        if(intersectSP(L(a,b), P(0,0))) return 0;
        if(a.Y<=0 && b.Y>0 && cross(a,b)<0) ret = -ret;
    }
    return ret;
}

bool isVisible(const L &l, const VP &poly){
    int n = poly.size();
    VP cp;
    cp.push_back(l[0]);
    cp.push_back(l[1]);
    for(int i=0; i<n; i++){
        L edge(poly[i], poly[(i+1)%n]);
        if(!isParallel(l, edge) && intersectSS(l, edge)){
            cp.push_back(crosspointLL(l, edge));
        }
    }
    sort(cp.begin(), cp.end());
    cp.erase(unique(cp.begin(), cp.end()), cp.end());
    
    bool ret = true;
    for(int i=0; i<(int)cp.size()-1; i++){
        if(in_poly((cp[i]+cp[i+1])/2.0, poly) > 0){
            ret = false;
            break;
        }
    }
    return ret;
}

int main(){
    int n,m;
    cin >> n >> m;
    vector<VP> poly(n);
    for(int i=0; i<n; i++){
        int l;
        cin >> l;
        poly[i].resize(l);
        for(int j=0; j<l; j++){
            double x,y;
            cin >> x >> y;
            poly[i][j] = P(x, y);
        }
    }
    VP man(m);
    for(int i=0; i<m; i++){
        double x,y;
        cin >> x >> y;
        man[i] = P(x, y);
    }

    vector<L> ray;
    for(P p: man){
        for(VP &po: poly){
            for(P v: po){
                ray.push_back(L(p, v));
            }
        }
    }
    VP cand;
    for(int i=0; i<(int)ray.size(); i++){
        for(int j=i+1; j<(int)ray.size(); j++){
            if(!isParallel(ray[i], ray[j])){
                cand.push_back(crosspointLL(ray[i], ray[j]));
            }
        }
    }

    int ans = 0;
    for(int i=0; i<(int)cand.size(); i++){
        int sub = 0;
        for(int j=0; j<m; j++){
            bool canlook = true;
            L ray(cand[i], man[j]);
            for(int k=0; k<(int)poly.size(); k++){
                if(!isVisible(ray, poly[k])){
                    canlook = false;
                    break;
                }
            }
            if(canlook) sub++;
        }
        ans = max(ans, sub);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3432