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++: #define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
//#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
//const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
    int a[4], b[4];
    int hit , blow;
    while(scanf("%d%d%d%d%d%d%d%d",&a[0],&a[1],&a[2],&a[3],&b[0],&b[1],&b[2],&b[3]) != EOF){   
    hit = 0, blow = 0;
    for(int i = 0; i < 4; i++){
	  for(int j = 0; j < 4; j++){
		  if (a[i] == b[j]){
			  if (i != j) blow++;
			  else hit++;  
			} 
		 }	
	  }
	cout << hit << " " << blow << endl;
  }
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}

C++: #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
#define INF 1000000000;
using namespace std;
int main() {
  int a[4], b[4];
  while (cin >> a[0] >> a[1] >> a[2] >> a[3]) {
    int ansb = 0, ansh = 0;
    rep(i, 4) cin >> b[i];
    rep(i, 4) rep(j, 4) {
      if (a[i] == b[j]) {
        if (i == j)
          ansh++;
        else
          ansb++;
      }
    }
    cout << ansh << ' ' << ansb << endl;
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

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

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


int a[4];
int b[4];

int main()
{
    int n,m;
    while(~scanf("%d%d%d%d",&a[0],&a[1],&a[2],&a[3]))
    {
        scanf("%d%d%d%d",&b[0],&b[1],&b[2],&b[3]);
        int i;
        n=m=0;
        for(i=0;i<4;i++)
        {
            for(int j=0;j<4;j++)
            {
                if(a[i] == b[j] && i==j)
                {
                    n++;
                }
                if(a[i] == b[j] && i!=j)
                {
                    m++;
                }
            }
        }
        cout<<n<<" "<<m<<endl;
    }
    return 0;
}

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

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

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

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
  int a[4];
  while(cin >> a[0]) {
    REP(i,3)
      cin >> a[i+1];
    int hit = 0;
    int blow = 0;
    REP(i,4) {
      int b;
      cin >> b;
      if (b == a[i])
        hit++;
      else {
        REP(j,4)
          if (b==a[j])
            blow++;
      }
    }
    printf("%d %d\n", hit, blow);
  }
}

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

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

  while (1) {
    if (scanf("%d %d %d %d", &a[0], &a[1], &a[2], &a[3]) != 4) break;
    if (scanf("%d %d %d %d", &b[0], &b[1], &b[2], &b[3]) != 4) break;

    hit = blow = 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]) blow++;
      }
    }
    blow -= hit;
    printf("%d %d\n", hit, blow);
  }

  return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>

using namespace std;

int main(){
    int a[4],b[4],hit,blow;
    
    while(scanf("%d%d%d%d%d%d%d%d",&a[0],&a[1],&a[2],&a[3],&b[0],&b[1],&b[2],&b[3])!=EOF){
        hit=0;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++;
                }
            }
        }
        printf("%d %d\n",hit,blow);
    }
    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 hit_cnt = 0;
		int blow_cnt = 0;
		
		for (int i=0; i<4; i++) {
			if (a[i] == b[i]) { hit_cnt++; a[i] = b[i] = -1; }
		}
		
		for (int i=0; i<4; i++) {
			if (a[i] == -1) continue;
			for (int j=0; j<4; j++) {
				if (a[i] == b[j]) { blow_cnt++; a[i] = b[j] = -1; }
			}
		}
		
		cout << hit_cnt << " " << blow_cnt << endl;
	}	
		
	return 0;
}

C++: #include <stdio.h>
int main() {int A[4],B[4],C[10],i,j;while (scanf("%d %d %d %d %d %d %d %d",&A[0],&A[1],&A[2],&A[3],&B[0],&B[1],&B[2],&B[3])!=EOF) {for (i=0,j=0;i<4;i++) if (A[i]==B[i]) j++;for (i=0;i<10;C[i++]=0);for (i=0;i<4;i++) C[A[i]]++;int k=-j;for (i=0;i<4;i++) if (C[B[i]]>0) k++,C[B[i]]--;printf("%d %d\n",j,k);} return 0;}

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

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

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

	}

        return 0;
}