#pragma GCC optimize("O3") #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define ri register signed #define RI register signed #define cf cout.flush(); #define lson (rt<<1|1) #define rson (rt<<1) #define lson1 (rt1<<1) #define rson1 (rt1<<1|1) #define lson2 (rt2<<1) #define rson2 (rt2<<1|1) #define mid ((l+r)>>1) #define mid1 ((l1+r1)>>1) #define mid2 ((l2+r2)>>1) #define mes(x) memset(x,0,sizeof x) typedef long long LL; typedef long long ll; typedef unsigned long long ull; typedef pair pll; typedef pairP; typedef pair PP; //#define int long long //#define double long double #define ri register signed #define il inline #define deb(...) logger(#__VA_ARGS__,__VA_ARGS__) template void logger(string vars, Args&&... values) { cout << vars << " = "; string delim = ""; //(..., (cout << delim << values, delim = ", ")); } inline string toString(int x) { string ans = ""; bool negtive = x < 0; x = abs(x); while (x)ans.push_back(x % 10 + '0'), x /= 10; if (ans.size() == 0)ans = "0"; if (negtive)ans.push_back('-'); for (int i = 0; i < ans.size() / 2; i++) swap(ans[i], ans[ans.size() - 1 - i]); return ans; } inline int toInt(const string&str) { int ans = 0; bool negtive = str[0] == '-'; for (int i = negtive; i < str.size(); i++) ans = ans * 10 + str[i] - '0'; if (negtive)ans *= -1; return ans; } inline int gcd(int x, int y) { return x ? gcd(y%x, x) : y; } ll exgcd(ll a, LL b, LL &x, LL &y) { LL d = a; if (b == 0) x = 1, y = 0; else { d = exgcd(b, a%b, y, x), y -= a / b * x; } return d; } const int mod = 998244353; inline int rd() { int ans = 0; char last = ' ', ch = getchar(); while (!(ch >= '0' && ch <= '9'))last = ch, ch = getchar(); while (ch >= '0' && ch <= '9')ans = (ans << 3) + (ans << 1) + ch - '0', ch = getchar(); return ans; } inline int QPow(ll a, ll b) { LL ans = 1; if (b < 0)return 0; while (b) { if (b & 1)ans = ans * a; a = a * a; b >>= 1; } return ans; } inline int QPow(LL a, LL b, const int&mod) { LL ans = 1; while (b) { if (b & 1)ans = ans * a%mod; a = a * a%mod; b >>= 1; } return ans; } const double PI = 3.141592653589793115997963468544185161590576171875; const double e = 2.718281828459045; void ask(int x) { cout <<'?'<<' '<< x << endl; cf; } void decide(int x) { cout << "! " << x << endl; cf; } short _min(short a, short b) { return a < b ? a : b; } const int inf = 1e9; const int inf2 = 10000; const double eps = 5e-9; int db_cmp(double x, double y) { if (fabs(x - y) < eps)return 0; if (x > y)return 1; return -1; } const int N = 505; P bear[N]; P house[N]; P operator-(const P&a, const P&b) { return { a.first - b.first,a.second - b.second }; } int cross(const P&a, const P&b) { return a.first*b.second - a.second*b.first; } bool check(int i, int j, int n) { P tmp = bear[j] - bear[i]; for (int k = 1; k <= n; k++) { if (cross((house[k] - bear[i]), tmp) < 0) return 0; } return 1; } int dp[N][N]; inline void floyd(int m) { for (int k = 1; k <= m; k++) for (int i = 1; i <= m; i++) for (int j = 1; j <= m; j++) dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]); } signed main() { int n, m, a, b, v; while (cin >> n) { for (int i = 1; i <= n; i++) cin >> house[i].first >> house[i].second; cin >> m; for (int i = 1; i <= m; i++) for (int j = 1; j <= m; j++) dp[i][j] = inf; for (int i = 1; i <= m; i++) { cin >> bear[i].first >> bear[i].second; } for (int i = 1; i <= m; i++) { bool flag = 1; for (int j = 1; j <= m; j++) { if (i == j)continue; flag = check(i, j, n); if (flag)dp[i][j] = 1; } } floyd(m); int MinCircle = inf; for (int i = 1; i <= m; i++) for (int j = 1; j <= m; j++) if (i != j) if (dp[i][j] + dp[j][i] < inf) MinCircle = min(MinCircle, dp[i][j] + dp[j][i]); if(MinCircle