#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e2+10;
int x[maxn][4];
int y[maxn][4];
int n;
double eps = 1e-8;
const int INF = 1e9;
int love[maxn][maxn];
int ex_girl[maxn];
int ex_boy[maxn];
bool vis_girl[maxn];
bool vis_boy[maxn];
int match[maxn];
bool dfs(int girl)
{
vis_girl[girl] = true;
for (int boy = 0; boy < n; ++boy) {
if (vis_boy[boy]) continue;
double gap = ex_girl[girl] + ex_boy[boy] - love[girl][boy];
if (fabs(gap) <= eps) {
vis_boy[boy] = true;
if (match[boy] == -1 || dfs( match[boy] )) {
match[boy] = girl;
return true;
}
}
}
return false;
}
int KM()
{
memset(match, -1, sizeof(match));
memset(ex_boy, 0, sizeof(ex_boy));
for (int i = 0; i < n; ++i) {
ex_girl[i] = love[i][0];
for (int j = 1; j < n; ++j) {
ex_girl[i] = max(ex_girl[i], love[i][j]);
}
}
for(int i = 0; i < n; ++i) {
while (1) {
memset(vis_girl, false, sizeof(vis_girl));
memset(vis_boy, false, sizeof(vis_boy));
if (dfs(i)) break;
int d = INF;
for(int i=0; i<n; i++)if(vis_girl[i]){
for(int j=0; j<n; j++){
if(!vis_boy[j]){
d = min(d, ex_girl[i]+ex_boy[j]-love[i][j]);
}
}
}
for (int j = 0; j < n; ++j) {
if (vis_girl[j]) ex_girl[j] -= d;
if (vis_boy[j]) ex_boy[j] += d;
}
}
}
int ans = 0;
for(int i=0; i<n; i++){
ans+=(ex_boy[i]+ex_girl[i]);
}
return ans;
}
int cal(int* a, int *b){
int ans = 0;
for(int i=0; i<4; i++){
for(int j=0; j<4; j++){
if(a[i] == b[j]){
ans++;
break;
}
}
}
return ans;
}
int main()
{
ios::sync_with_stdio(false);
while(cin>>n){
for(int i=0; i<n; i++){
cin>>x[i][0]>>x[i][1]>>x[i][2]>>x[i][3];
}
for(int i=0; i<n; i++){
cin>>y[i][0]>>y[i][1]>>y[i][2]>>y[i][3];
}
int num;
for(int i=0; i<n; i++){
for(int j=0; j<n; j++){
num = cal(x[i], y[j]);
love[i][j] = num;
}
}
int ans = KM();
cout<<4*n-ans<<endl;
}
return 0;
}