#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <iostream>
#include <cassert>
#include <complex>

using namespace std;
typedef long long ll;

const double eps = 1e-8;

typedef complex<double> P;

double dot(P a, P b){
  return (a * conj(b)).real();
}

double cross(P a, P b){
  return (conj(a) * b).imag();
}

int ccw(P a, P b, P c){
  if(cross(b-a, c-a) > eps) return 1;
  if(cross(b-a, c-a) < -eps) return -1;
  if(dot(b-a, c-a) < -eps) return -2;
  if(dot(a-b, c-b) < -eps) return 2;
  return 0;
}

bool isIntersectedLL(P a1, P a2, P b1, P b2){
  return abs(cross(a1-a2, b1-b2)) > eps;
}

bool isIntersectedSS(P a1, P a2, P b1, P b2){
  int a = ccw(b1, b2, a1);
  int b = ccw(b1, b2, a2);
  int c = ccw(a1, a2, b1);
  int d = ccw(a1, a2, b2);

  return a*b < 0 && c*d < 0;
}


P getCrosspointLL(P a1, P a2, P b1, P b2){
  P a = a2 - a1;
  P b = b2 - b1;
  return a1 + a * cross(b, b1-a1) / cross(b, a);
}

P p[10];
int l[10];
P pol[10][20];

int main(){
  int n, m;
  int x, y;

  scanf("%d%d", &n, &m);
  
  vector<P> vec, vec2;

  for(int i=0;i<n;i++){
    scanf("%d", l+i);
    for(int j=0;j<l[i];j++){
      scanf("%d%d", &x, &y);
      pol[i][j] = P(x,y);
      vec.push_back(pol[i][j]);
      vec2.push_back(pol[i][j]);
    }
  }

  for(int i=0;i<m;i++){
    scanf("%d%d", &x, &y);
    p[i] = P(x, y);
    //vec.push_back(p[i]);
  }



  for(int i=0;i<m;i++){
    for(int j=i+1;j<m;j++){
      for(int t=0;t<vec2.size();t++){
        for(int q=0;q<vec2.size();q++){
          if(isIntersectedLL(p[i], vec2[t], p[j], vec2[q])){
            vec.push_back(getCrosspointLL(p[i], vec2[t], p[j], vec2[q]));
          }
        }
      }
    }
  }

  int ans = 0;
  
  for(int i=0;i<vec.size();i++){
    int counter = 0;
    
    for(int j=0;j<m;j++){
      bool flag = true;
      for(int k=0;k<n;k++){
        for(int t=0;t<l[k];t++){
          flag &= !isIntersectedSS(pol[k][t], pol[k][(t+1)%l[k]], p[j], vec[i]);
        }
      }
      counter += flag;
    }

    ans = max(ans, counter);
  }

  cout << ans << endl;
  
  return 0;  
}

