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>
using namespace std;

int main(){
	int a[4], b[4];
	int hit, blow;

	while (cin >> a[0] >> a[1] >> a[2] >> a[3]){
		cin >> b[0] >> b[1] >> b[2] >> b[3];

		hit = 0; blow = 0;

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

		for (int i = 0; i < 4; ++i){
			if (a[i] == b[i]){
				++hit;
				--blow;
			}
		}

		cout << hit << " " << blow << 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] >> b[0] >> b[1] >> b[2] >> b[3]){
    int h=0,bs=0;
    for(int i=0;i<4;i++){
      for(int j=0;j<4;j++){
	if(a[i]==b[j]){
	  if(i==j) h++;
	  else bs++;
	}
      }
    }
    cout << h << " " << bs << endl; 
  }
}

C++: #include <iostream>
using namespace std;
void check(int a[], int b[], int *hit, int *blow, int n){
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			if(a[i] == b[j]){
				if(i==j) (*hit)++;
				else (*blow)++;
			}
			
		}
	}
}

	

int main(void)
{
	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;
		check(a,b,&hit,&blow,4);
		cout << hit << " " << blow << endl;
	}	
	return 0;
}

C++: #include <iostream>

using namespace std;

int main() {
  int hit, blow;
  int a[4], b[4];

  while (!cin.eof()) {
    cin >> a[0] >> a[1] >> a[2] >> a[3];
    cin >> b[0] >> b[1] >> b[2] >> b[3];
    hit = blow = 0;
    for (int i = 0; i < 4; i++)
      for (int j = 0; j < 4; j++)
        if (a[i] == b[j])
          (i == j) ? hit++ : blow++;
    cout << hit << " " << blow << 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] >> b[0] >> b[1] >> b[2] >> b[3] )
    {
        int c[10] = {};

        for( int i = 0; i < 4; i++ )
        {
            c[a[i]]++;
            c[b[i]]++;
        }

        int hit = 0;
        for( int i = 0; i < 4; i++ )
            if( a[i] == b[i] )
                hit++;

        int blow = 0;
        for( int i = 0; i < 10; i++ )
            if( c[i] == 2 )
                blow++;

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

C++: #include <iostream>

int main(){
    int a_num[4];
    int b_num[4];
    
    while (true) {
        
        // input a's number.
        for (int i=0; i<4; ++i) {
            if(! (std::cin >> a_num[i]) ){
                return 0;
            }
        }
        // input b's number.
        for (int i=0; i<4; ++i) {
            if(! (std::cin >> b_num[i]) ){
                return 0;
            }
        }
        
        // count hit.
        int hit=0;
        for (int i=0; i<4; ++i) {
            if (a_num[i] == b_num[i]) {
                ++hit;
            }
        }
        std::cout << hit << " ";
        
        // count blow.
        int blow=0;
        for (int i=0; i<4; ++i) {
            for (int j=0; j<4; ++j) {
                if (i!=j && b_num[i] == a_num[j]) {
                    ++blow;
                }
            }
        }
        std::cout << blow << std::endl;
        
    }
    return 0;
}

C++: #include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <string>
#include <queue>
#include <algorithm>
#include <cctype>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const double pi=acos(-1);

vector<char> a(4),b(4);

int main(){
	char c,d,e,f;
	while(cin>>c>>d>>e>>f){
		int hit=0,blow=0;
		a={c,d,e,f};
		for(int i=0;i<4;i++) cin>>b[i];
		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(i==j) continue;
				if(a[i]==b[j]) blow++;
			}
		}
		cout<<hit<<' '<<blow<<endl;
	}
}

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, k = 0;

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

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

  while(scanf("%d", &str[0]) != EOF){ 
	scanf("%d %d %d", &str[1], &str[2], &str[3]);
    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 << endl;

  }

  return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>

#include <algorithm>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
#endif

#define ITER(c)         __typeof__((c).begin())
#define FOREACH(it, c)  for (ITER(c) it=(c).begin(); it != (c).end(); ++it)
#define RITER(c)        __typeof__((c).rbegin())
#define RFOREACH(it, c) for (RITER(c) it=(c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n)       REPEAT(i, 0, n)
#define REPEAT(i, k, n) for (int i = (k); i < (n); ++i)
#define REVREP(i, n)    for (int i = ((n)-1); i >= 0; --i)
#define FIND(c, n)      std::find((c).begin(), (c).end(), (n));
#define BSEARCH(c, n)   std::binary_search((c).begin(), (c).end(), (n))
#define LLPOW(p1,p2)    ((ll)pow((double)(p1), (int)p2))
#define ESIZEOF(A)      (sizeof(A)/sizeof((A)[0]))
#define MIN(p1,p2)      (((p1)<(p2))?(p1):(p2))
#define MAX(p1,p2)      (((p1)>(p2))?(p1):(p2))
#define CIN_NO_SYNC     do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0)
#define GETSTR(p)       fgets((p), sizeof(p), stdin)
#define CHOMP(p)        do{ char *_q = (p) + strlen(p)-1; if(*_q == '\n') *_q = 0; } while(0)

typedef long long ll;
typedef unsigned long long ull;

#define X real()
#define Y imag()
typedef double D;
typedef complex<double>P;
#define EPS (1e-9)

#ifdef _DEBUG
#define pf printf
#define pr(n) do { cout << #n " = " << (n) << endl; } while(0)
#else
#define pf(...) /* */
#define pr(...) /* */
#endif

int main(){
    while(1){
        int a[4], b[4];
        REP(i,4) if(!(cin >> a[i])) return 0;
        REP(i,4) if(!(cin >> b[i])) return 0;

        int hi = 0, bl = 0;
        REP(i,4) REP(j,4){
            if(a[i] == b[j]){
                if(i == j) hi++; else bl++;
            }
        }
        cout << hi << " " << bl << endl;
    }

    return 0;
}

C++: #include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main(){
  int a[4],u[10],h,b,t;
  while(cin>>a[0]){
    rep(i,10) u[i]=0;
    h = 0;
    b = 0;
    rep(i,3)
      cin >> a[i+1];
    rep(i,4)
      u[a[i]] = 1;
    rep(i,4){
      cin >> t;
      if(a[i] == t) h++;
      if(u[t]) b++;
    }
    cout << h << " " << b-h << endl;
  }
  return 0;
}