#include<bits/stdc++.h>
#define inf 1<<29
#define linf 1e18
#define eps (1e-6)
#define mod 1000000007
#define pi M_PI
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;

class Point{
public:
  double x,y;
  Point(double x=0,double y=0):x(x),y(y){}

  Point operator+(Point p){ return Point(x+p.x,y+p.y);}
  Point operator-(Point p){ return Point(x-p.x,y-p.y);}
  Point operator*(double k){ return Point(x*k,y*k);}
  Point operator/(double k){ return Point(x/k,y/k);}
  bool operator<(Point p)const{ return (x!=p.x ? x<p.x : y<p.y);}
  bool operator==(Point p)const{ return fabs(x-p.x)<eps && fabs(y-p.y)<eps;}

  double abs(){ return sqrt(norm());}
  double norm(){ return (x*x+y*y);}
};
typedef Point Vector;
typedef vector<Point> Polygon;

class Segment{
public:
  Point p1,p2;
  Segment(Point p1=Point(),Point p2=Point()):p1(p1),p2(p2){}
};
typedef Segment Line;

double norm(Vector a){ return (a.x*a.x+a.y*a.y);}
double abs(Vector a){ return sqrt(norm(a));}
double dot(Vector a,Vector b){ return (a.x*b.x+a.y*b.y);}
double cross(Vector a,Vector b){ return (a.x*b.y-a.y*b.x);}

bool isParallel(Segment s,Segment t){
  return equals(cross(s.p1-s.p2,t.p1-t.p2),0.0);
}

int ccw(Point p0,Point p1,Point p2){
  Vector a=p1-p0;
  Vector b=p2-p0;
  if(cross(a,b)>eps)return 1;
  if(cross(a,b)<-eps)return -1;
  if(dot(a,b)<-eps)return 2;
  if(a.norm()<b.norm())return -2;
  return 0;
}

bool intersect(Point p1,Point p2,Point p3,Point p4){
  return (ccw(p1,p2,p3)*ccw(p1,p2,p4)<=0 &&
          ccw(p3,p4,p1)*ccw(p3,p4,p2)<=0);
}

bool intersect(Segment s1,Segment s2){
  return intersect(s1.p1,s1.p2,s2.p1,s2.p2);
}

Point getCrossPointLL(Line a,Line b){
  double A=cross(a.p2-a.p1,b.p2-b.p1);
  double B=cross(a.p2-a.p1,a.p2-b.p1);
  if(abs(A)<eps || abs(B)<eps)return b.p1;
  return b.p1+(b.p2-b.p1)*(B/A);
}

int n,m,l;
vector<Polygon> polygons;
vector<Point> vp;
vector<Segment> vs[20];

vector<Line> getS(int a,int b){
  Point p=vp[a];
  Polygon P=polygons[b];
  vector<Line> res;
  FOR(i,0,P.size()){
    int count=0;
    FOR(j,0,P.size())count+=ccw(p,P[i],P[j]);
    if(abs(count)==P.size()-1)res.pb(Line(p,P[i]));
  }
  return res;
}

vector<Point> getP(int a,int b){
  vector<Point> res;
  FOR(i,0,vs[a].size()){
    FOR(j,0,vs[b].size()){
      if(isParallel(vs[a][i],vs[b][j]))continue;
      res.pb(getCrossPointLL(vs[a][i],vs[b][j]));
    }
  }
  return res;
}

int check(Segment s){
  FOR(i,0,n){
    Polygon P=polygons[i];
    int size=P.size();
    FOR(j,0,size){
      Point a=P[j],b=P[(j+1)%size];
      if(ccw(s.p1,s.p2,a)==0 || ccw(s.p1,s.p2,b)==0)continue;
      if(ccw(a,b,s.p1)==0 || ccw(a,b,s.p2)==0)continue;
      if(intersect(s,Segment(a,b)))return 0;
    }
  }
  return 1;
}

int solve(){
  FOR(i,0,m){
    FOR(j,0,n){
      vector<Segment> tmp=getS(i,j);
      FOR(k,0,tmp.size())vs[i].pb(tmp[k]);
    }
  }
  vector<Point> ev;
  FOR(i,0,m){
    FOR(j,0,m){
      vector<Point> res=getP(i,j);
      FOR(k,0,res.size())ev.push_back(res[k]);
    }
  }
  int ans=1;
  FOR(i,0,ev.size()){
    int count=0;
    FOR(j,0,m)count+=check(Segment(ev[i],vp[j]));
    ans=max(ans,count);
  }
  return ans;
}

int main()
{
  cin>>n>>m;
  FOR(i,0,n){
    cin>>l;
    Polygon p;
    FOR(j,0,l){
      int x,y;
      cin>>x>>y;
      p.pb(Point(x,y));
    }
    polygons.pb(p);
  }
  FOR(i,0,m){
    int x,y;
    cin>>x>>y;
    vp.pb(Point(x,y));
  }
  cout<<solve()<<endl;
  return 0;
}

Measured memory_bytes: 3240