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 <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;

int hit(int str[],int str2[]){
  int i, j = 0;

  for(i = 0;i < 4;i++){
    if(str[i] == str2[i]){
      j++;
    }
  }

  return j;
}

int blow(int str3[],int str4[]){
  int i, j = 0;

  sort(str3, str3 + 4);
  sort(str4, str4 + 4);

  for(i = 0;i < 4;i++){
    if(str3[i] == str4[i]){
      j++;
    }
  }

  return j;
}

int main(){
  int str[4], str2[4];

  while(scanf("%d %d %d %d", &str[0], &str[1], &str[2], &str[3]) != EOF){ 

    cin >> str2[0] >> str2[1] >> str2[2] >> str2[3];

  int hit_var = hit(str, str2);
  int blow_var = blow(str, str2);

  cout << hit_var << " " << blow_var - hit_var << endl;

  }

  return 0;
}

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

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

int main(void) {
	int a[4], b[4], e = 0, f = 0;
	while(cin >> a[0] >> a[1] >> a[2] >> a[3]){
		e = 0;
		f = 0;
		cin >> b[0] >> b[1] >> b[2] >> b[3];
		for (int i = 0; i < 4; i++) {
			if (a[i] == b[i]) e++;
		}
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 4; j++) {
				if (i != j) {
					if (a[i] == b[j]) {
						f++;
					}
				}
			}
		}
		cout << e << " " << f << endl;
	}
	return 0;
}

C++: #include <iostream>

#define SIZE 4

using namespace std;

int main() {
	int a[SIZE], b[SIZE], hit, blo;

	while (cin>>a[0]>>a[1]>>a[2]>>a[3]>>b[0]>>b[1]>>b[2]>>b[3]) {
		hit = 0;
		blo = 0;
		for (int i = 0; i < SIZE; i++) {
			if (a[i] == b[i]) {
				hit++;
				a[i] = 10 + hit;
				b[i] = 10 + hit;
			}
		}

		for (int i = 0; i < SIZE; i++) {
			for (int j = i + 1; j < SIZE; j++) {
				if (a[i] == 10 || b[j] == 10) {
					continue;
				}

				if (a[i] == b[j]) {
					a[i] = 10 + hit + blo;
					b[i] = 10 + hit + blo;
					blo++;
				}
			}
		}
		cout << hit << " " << blo << endl;
	}

	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
    int a[4][50],b[4][50],hit,blow,n;
    for(int i = 0;i < 50;i++){
        cin >> a[0][i] >> a[1][i] >> a[2][i] >> a[3][i] 
            >> b[0][i] >> b[1][i] >> b[2][i] >> b[3][i] ;
        int t = 0;
        for(int j = 0;j < 4;j++){
            if(a[j][i] != 0){
                t = 1;
                j = 4;
            }
            if(b[j][i] != 0){
                t = 1;
                j = 4;
            }
        }
        if (t == 0){
            n = i + 1;
            i = 50;
        }
    } 
    for(int i = 0;i < n;i++){
        hit = blow = 0;
        for(int j = 0;j < 4;j++){
            for(int k = 0;k < 4;k++){
                if(a[j][i] == b[k][i]){
                    if(j == k){
                        hit++;
                    }
                    else{
                        blow++;
                    }
                }
            }
        }
        cout << hit << " " << blow << endl;
    }
}

C++: #include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<complex>
#include<stack>
#include<cmath>

using namespace std;

#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)


#define X real()
#define Y imag()
typedef complex<double> P;

int main(){
	  
	  int a;
	  while(cin>>a){
	  	vector<int> A;
		A.push_back(a);
		rep(i,3){
			int b;
			cin>>b;
			A.push_back(b);
		}
		
		vector<int> B;
		rep(i,4){
			int b;
			cin>>b;
			B.push_back(b);
		}
		
		int hit=0;
		int blow = 0;
		rep(i,4){
			rep(j,4){
				if(A[i]==B[j]){
					if(i==j)hit++;
					else blow++;
				}
				
			}
		}
		
		printf("%d %d\n",hit,blow);
	  }
	
}

C++: #include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>

using namespace std;
int main(){
	int a[4], b[4];
	int hit = 0, brow = 0;
	
	while(cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]){
		for(int i = 0;i < 4;i++){
			for(int j = 0;j < 4;j++){
				if(a[i] == b[j]){
					if(i == j) hit++;
					else brow++;
				}
			}
		}
		cout << hit << " " << brow << endl;
	}

	
	return 0;
}

C++: #include <iostream>

using namespace std;

void solve()
{
	int a[4];
	int 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;
		int blow = 0;
		for(int i = 0; i < 4; ++i)
		{
			for(int j = 0; j < 4; ++j)
			{
				if(a[i] == b[j])
				{
					if(i == j)
					{
						++hit;
					}
					else
					{
						++blow;
					}
					break;
				}
			}
		}
		cout << hit << " " << blow << endl;
	}
}

int main()
{
	solve();
	return(0);
}

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

int main()
{
  std::array<int,8> hitting;
  std::set<int> blowing;
  while(std::cin >> hitting[0]){
    blowing.insert(hitting[0]);
    for(int i=1;i<8;++i){
      std::cin >> hitting[i];
      blowing.insert(hitting[i]);
    }
    int num=0;
    for(int j=0;j<4;++j){
      if(hitting[j]==hitting[j+4]){
        ++num;
     }
    }
    std::cout << num << " " << 8-(int)(blowing.size())-num << std::endl;
    blowing.clear();
  }
return 0;
}

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

int main() {
  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;
    bool checked[4][4]; for(int i=0;i<4;i++)for(int j=0;j<4;j++)checked[i][j]=false;
    
    for(int i = 0; i < 4; i++) {
      for(int j = 0; j < 4; j++) {
	if(checked[i][j]) continue;
	
	if(i == j && a[i] == b[j]) {
	  hit++;
	  checked[i][j] = true; checked[j][i] = true;
	}
	else if(a[i] == b[j]) {
	  blow++;
	  checked[i][j] = true; checked[j][i] = true;
	}
      }
    }

    cout << hit << " " << blow << endl;
  }
  
  return 0;
}

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

int main() {
	int a[4];
	int b[4];
	bool flag[4];
	while(cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]) {
		int hitNumber = 0;
		int blowNumber = 0;
		for(int i = 0; i < 4; i++) flag[i] = false;
		for(int i = 0; i < 4; i++) {
			if(a[i] == b[i]) {
				hitNumber++;
				flag[i] = true;
			}
		}
		for(int i = 0; i < 4; i++) {
			if(flag[i] == true) continue;
			else {
				for(int j = 0; j < 4; j++) {
					if(a[i] == b[j]) {
						blowNumber++;
					}
				}
			}
		}
		cout << hitNumber << " " << blowNumber << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

int main()
{
    int a[4],b[4];
    while (true)
    {
        if ( cin.eof() ) { break; }
        rep(j,4) cin>>a[j];
        rep(j,4) cin>>b[j];
        
        int hit=0,bl=0;
        rep(i,4){
            if(a[i]==b[i]) hit++;
            rep(j,4){
                if(a[i]==b[j]) bl++;
            }
        }
        cout<<hit<<" "<<bl-hit<<endl;
    }
    return 0;
}