#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(_v) for(auto _x:_v){cout<<_x<<" ";}cout<<endl
#define printVS(vs) for(auto x : vs){cout << x << endl;}
#define printVV(_vv) for(auto _v:_vv){for(auto _x:_v){cout<<_x<<" ";}cout<<endl;}
#define printP(p) cout << p.first << " " << p.second << endl
#define printVP(vp) for(auto p : vp) printP(p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
const int inf = 1e9;
const int mod = 1e9 + 7;

typedef complex<double> P;
typedef vector<P> G;
#define here(g, i) g[i]
#define next(g, i) g[(i + 1) % g.size()]
#define prev(g, i) g[(i - 1 + g.size()) % g.size()]
const double EPS = 1e-10;
const double INF = 1e12;
const double PI = acos(-1);

struct L {
    P a, b, v;
    L(){}
    L(P _a, P _b) : a(_a), b(_b), v(b - a) {}
    L(double _ax, double _ay, double _bx, double _by) : L(P(_ax, _ay), P(_bx, _by)) {}
};

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

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

int ccw(P p0, P p1, P p2) {
    if (cross(p1 - p0, p2 - p0) > 0) return +1; // counter-clockwise
    if (cross(p1 - p0, p2 - p0) < 0) return -1; // clockwise
    if (dot(p1 - p0, p2 - p0) < 0) return +2;   // online_back
    if (dot(p0 - p1, p2 - p1) < 0) return -2;   // online_front
    return 0;                                   // on_segment
}

// !! ???????????????????????¨?????? "<" !!
bool intersectSS(L l1, L l2) {
    return (ccw(l1.a, l1.b, l2.a) * ccw(l1.a, l1.b, l2.b) < 0 &&
            ccw(l2.a, l2.b, l1.a) * ccw(l2.a, l2.b, l1.b) < 0);
}

P crosspointSS(L l1, L l2) {
    assert(intersectSS(l1, l2));
    double d1 = abs(cross(l2.v, l1.a - l2.a));
    double d2 = abs(cross(l2.v, l1.b - l2.a));
    double t = d1 / (d1 + d2);
    return l1.a + t * l1.v;
}

bool intersectLL(L l1, L l2) {
    return cross(l1.v, l2.v) != 0;
}

P crosspointLL(L l1, L l2) {
    return l1.a + l1.v * cross(l2.v, l2.a - l1.a) / cross(l2.v, l1.v);
}

bool intersectSG(L l, G g) {
    int n = g.size();
    rep(i, n) {
        if (intersectSS(l, L(here(g, i), next(g, i)))) {
            return true;
        }
    }
    return false;
}

P readP() {
    double x, y;
    cin >> x >> y;
    return P(x, y);
}

G readG() {
    int n;
    cin >> n;
    G g(n);
    rep(i, n) g[i] = readP();
    return g;
}

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int n, m;
    cin >> n >> m;
    vector<G> g(n);
    rep(i, n) g[i] = readG();
    vector<P> p(m);
    rep(i, m) p[i] = readP();

    if (m == 1) {
        cout << 1 << endl;
        return 0;
    }

    int ans = 0;
    rep(i1, m) {
        P p1 = p[i1];
        rep(j1, n) {
            rep(k1, g[j1].size()) {
                P q1 = g[j1][k1];
                rep2(i2, i1 + 1, m) {
                    P p2 = p[i2];
                    rep(j2, n) {
                        rep(k2, g[j2].size()) {
                            P q2 = g[j2][k2];
                            // Line!!!!
                            if (!intersectLL(L(p1, q1), L(p2, q2))) {
                                continue;
                            }
                            P c = crosspointLL(L(p1, q1), L(p2, q2));
                            int cnt = 0;
                            rep(i3, m) {
                                cnt += [&](L l) {
                                    rep(j, n) {
                                        // Segment!!!!
                                        if (intersectSG(l, g[j])) return false;
                                    }
                                    return true;
                                }(L(c, p[i3]));
                            }
                            ans = max(ans, cnt);
                        }
                    }
                }
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3300