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
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

  while(cin >> a[0] >> a[1] >> a[2] >> a[3]) {
    cin >> b[0] >> b[1] >> b[2] >> b[3];
    int hit = 0, blow = 0;

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

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

int main(void){
  int a[4];
  int b[4];

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

    int count=0;
    int hit=0;
    int blow=0;

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

C++: #include<iostream>

using namespace std;

int main() {
	
	int A[4] = {};
	int B[4] = {};
	
	while(cin >> A[0]) {
	int hit = 0;
	int 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(A[i] == B[j]) {
				
				if( i == j )
					hit++;
					
				else
					blow++;
					
		}
		
	}
	
}
	cout << hit << " " << blow << "\n";
}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main() {
	int size = 4;
	int ina[size];
	int inb[size];
	int hit=0, blow=0;
	while(true){
		cin>>ina[0]>>ina[1]>>ina[2]>>ina[3];
		cin>>inb[0]>>inb[1]>>inb[2]>>inb[3];
		if(cin.eof()) break;
		for(int i=0; i<size; i++) {
			if(ina[i] == inb[i]) hit++;
			for(int j=0; j<size; j++){
				if(i==j) break;
				if(ina[i] == inb[j]) blow++;
			}
		}
		cout<<hit<<" "<<blow<<endl;
	}
	return 0;
}

C++: // includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve

int main(int argc, char const* argv[])
{
  int a[4], b[4];
  while(cin >> a[0]){
    rep(i, 3)cin >> a[i+1];
    rep(i, 4)cin >> b[i];
    int hit = 0;
    int blow = 0;
    rep(i, 4){
      if(a[i] == b[i])hit++;
      rep(j, 4){
        if(a[i] == b[j]){
          blow++;
          break;
        }
      }
    }
    cout << hit << " " << blow - hit << endl;
  }
	return 0;
}

C++: #include<iostream>
#include<math.h>
#include<vector>
using namespace std;
int main() {
	int a,i,j,k,l,m,hit,blow;
	vector<int> s,t,u;
	while (true) {
		hit = 0;
		blow = 0;
		s.clear();
		t.clear();
		for (i = 0; i < 4; i++) {
			cin >> a;
			s.push_back(a);
		}
		for (j = 0; j < 4; j++) {
			cin >> a;
			t.push_back(a);
		}
		for (k = 0; k < 4; k++) {
			if (s[k] == t[k]&&s[k]>=0) {
				hit += 1;
				s[k] = -1;
				t[k] = -1;
			}
		}
		for (l = 0; l < 4; l++) {
			for (m = 0; m < 4; m++) {
				if (s[l] == t[m] && s[l] > 0) {
					blow += 1;
					s[l] = -1;
					t[m] = -1;
				}
			}
		}
		cout << hit << " " << blow << endl;
	}
	return 0;
}

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

int main() {
    int a[4], b[4];
    while (scanf("%d", a) != EOF) {
        rep (i, 3) scanf("%d", a+i+1);
        rep (i, 4) scanf("%d", b+i);
        int h = 0, k = 0;
        rep (i, 4) if (a[i] == b[i]) h++;
        rep (i, 4) rep (j, 4) if (a[i] == b[j]) k++;
        printf("%d %d\n", h, k-h);
    }
    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) {
                    break;
                }
                if (b_num[i] == a_num[j]) {
                    ++blow;
                    break;
                }
            }
        }
        std::cout << blow << std::endl;
        
    }
    return 0;
}