Go: package main

import "fmt"

func main() {
	var a1, a2, a3, a4, b1, b2, b3, b4 int
	for {
		i, _ := fmt.Scan(&a1, &a2, &a3, &a4)
		if i == 0 {
			break
		}
		fmt.Scan(&b1, &b2, &b3, &b4)
		a := [4]int{a1, a2, a3, a4}
		b := [4]int{b1, b2, b3, b4}
		var hit, blow int

		for j := 0; j < 4; j++ {
			for k := 0; k < 4; k++ {
				if a[j] == b[k] {
					if j == k {
						hit++
					} else {
						blow++
					}
				}
			}
		}
		fmt.Println(hit, blow)
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX - 100
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define lowb lower_bound
#define upb upper_bound
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



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

	int a[4], b[4];
	while(cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]) {
		int hit = 0, blow = 0;
		rep(i, 4) {
			if(a[i] == b[i]) hit++;
		}
		rep(i, 4) {
			if(find(a, a + 4, b[i]) != a + 4) blow++;
		}
		cout << hit << " " << blow - hit << endl;
	}
	return 0;
}

C++: #include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
using namespace std;
int main(){
  int a[4],b[4];
  while(cin>>a[0]){
    for(int i=1;i<4;i++){
      cin>>a[i];
    }
    for(int i=0;i<4;i++){
      cin>>b[i];
    }
    int hit=0,brow=0;
    for(int i=0;i<4;i++){
      if(a[i]==b[i]){
	hit++;
      }
    }
    for(int i=0;i<4;i++){
      for(int j=0;j<4;j++){
	if(a[i]==b[j]){
	  brow++;
	}
      }
    }
    cout<<hit<<" "<<brow-hit<<endl;
  }
  return 0;   
}

C++: #include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<cstring>
#include<sstream>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
typedef long long ll;
////////////////////////////////////////////////////////////

int main(){
	int tmp;
	while( cin >> tmp ){
		int a[4],b[4];
		a[0] = tmp;
		rep(i,1,4) cin >> a[i];
		rep(i,0,4) cin >> b[i];
		map<int,bool> mp;
		rep(i,0,4) mp[a[i]] = 1;
		
		int h=0,br=0;
		rep(i,0,4){
			if( a[i] == b[i] ) h++;
			else if(mp[b[i]]) br++;
		}

		cout << h << " "<< br << endl;
	}
	ret 0;
}

C++: #include <cstdio>
#include <algorithm>
#include <cmath>
#include <climits>
using namespace std;

int main() {
	while(true) {
		int a[10],b[10],h,bl;
		fill(a,a+10,0);
		fill(b,b+10,0);
		h=bl=0;
		int a1,a2,a3,a4,b1,b2,b3,b4;
		if(scanf("%d%d%d%d%d%d%d%d",&a1,&a2,&a3,&a4,&b1,&b2,&b3,&b4)<8)break;
		if(a1==b1)h++;
		if(a2==b2)h++;
		if(a3==b3)h++;
		if(a4==b4)h++;
		a[a1]++;
		a[a2]++;
		a[a3]++;
		a[a4]++;
		b[b1]++;
		b[b2]++;
		b[b3]++;
		b[b4]++;
		for(int i = 0; i < 10; i++) bl+=min(a[i],b[i]);
		printf("%d %d\n",h,bl-h);
	}
	return 0;
}

C++: #include <iostream>
using namespace std;


int a[4];
int b[4];
int hit = 0;
int blow = 0;


void solve(){
	for (int i = 0; i < 4; i++){
		for (int j = 0; j < 4; j++){
			if (b[i] == a[j] && i == j){
				hit++;
				break;
			}
			if (b[i] == a[j]){
				blow++;
				break;
			}
		}
	}
}


int main(){
	while (cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]){
		solve();
		cout << hit << ' ' << blow << endl;
		hit = 0;
		blow = 0;
	}

	return 0;
}

C++: #include <iostream>
#include <cmath>
using namespace std;

int main(){
	int a[4], b[4];
	while(cin >> a[0]){
		int hit = 0, blow = 0;
		for(int i = 1;i < 4;i++)cin >> a[i];
		for(int i = 0;i < 4;i++)cin >> b[i];
		for(int i = 0;i < 4;i++){
			for(int j = 0;j < 4;j++){
				if(i==j && a[i] == b[i])hit++;
				if(i!=j && a[i] == b[j])blow++;
			}
		}
		cout << hit << " " << blow << endl;
	}
	return 0; 
}

C++: #include <iostream>
using namespace std;

int main()
{
 int a[4];

 while(cin >> a[0] >> a[1] >> a[2] >> a[3]){
  int c = 0;
  int hit = 0, blow = 0;
  for(int i=0; i<4; i++){
   int n;
   cin >> n;
   if(n == a[c]){
    hit++;
    continue;
   }
   for(int j=0; j<4; j++){
    if(n == a[c]){
     blow++;
     break;
    }
   }
  }
  cout << hit << ' ' << blow << '\n';
 }
 
 return 0;
}

C++: #include <iostream>
#include <array>

int main(){
	std::array<u_int, 4> que;
	std::array<u_int, 4> ans;

	while(std::cin >> que[0] >> que[1] >> que[2] >> que[3] && std::cin >> ans[0] >> ans[1] >> ans[2] >> ans[3]){
		
		int hit = 0;
		int blow = 0;
		
		for(int i = 0; i < 4; ++i){
			if(que[i] == ans[i])
				hit++;

			if(que[i] == ans[(i + 1) % 4] || que[i] == ans[(i + 2) % 4] || que[i] == ans[(i + 3) % 4])
				blow++;
		}

		std::cout << hit << " " << blow << std::endl;
	}

	return 0;
}

C++: #include<iostream>
 
 int main(){
    int a[4],b[4],hit,blow,i,j;
    while(std::cin>>a[0]){
    for(i=1;i<4;i++){
    std::cin>>a[i];
    }for(i=0;i<4;i++){
    std::cin>>b[i];
    }
    hit=0;
    blow=0;
    for(i=0;i<4;i++){
        for(j=0;j<4;j++){
            if(i==j&&a[i]==b[j]){
            hit++;
            }if(i!=j&&a[i]==b[j]){
            blow++;
            }
        }
    }
    std::cout<<hit<<" "<<blow<<std::endl;
    }
    return 0;
}