Go: package main

import (
	"bufio"
	"os"
	"strings"
	"strconv"
	"fmt"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	a := make([]int, 4)
	b := make([]int ,4)
	for scanner.Scan() {
		inputa := strings.Split(scanner.Text(), " ")
		for i := range a {
			a[i], _ = strconv.Atoi(inputa[i])
		}
		scanner.Scan()
		inputb := strings.Split(scanner.Text(), " ")
		for i := range b {
			b[i], _ = strconv.Atoi(inputb[i])
		}
		hit := 0
		blow := 0
		if a[0] == b[0] {
			hit++
		}
		if a[1] == b[1] {
			hit++
		}
		if a[2] == b[2] {
			hit++
		}
		if a[3] == b[3] {
			hit++
		}
		if a[0] == b[1] {
			blow++
		}
		if a[1] == b[2] {
			blow++
		}
		if a[2] == b[3] {
			blow++
		}
		if a[1] == b[0] {
			blow++
		}
		if a[2] == b[1] {
			blow++
		}
		if a[2] == b[0] {
			blow++
		}
		if a[3] == b[2] {
			blow++
		}
		if a[3] == b[1] {
			blow++
		}
		if a[3] == b[0] {
			blow++
		}
		if a[0] == b[2] {
			blow++
		}
		if a[1] == b[3] {
			blow++
		}
		if a[0] == b[3] {
			blow++
		}
		fmt.Printf("%d %d\n", hit, blow)
	}
}

C++: #include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

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 num[10]; CLR(num);
    int hit = 0, blow = 0;
    FOR(i,0,4) {
      if(a[i] == b[i]) hit++;
      num[a[i]]++;
      num[b[i]]++;
    }
    FOR(i,0,10) if(num[i] > 1) blow++;
    cout << hit << " " << blow - hit << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> P;

string str;
vector<int> v1(4);
vector<int> v2(4);
int main()
{
  while(scanf("%d %d %d %d",&v1[0],&v1[1],&v1[2],&v1[3])!=EOF){
    scanf("%d %d %d %d",&v2[0],&v2[1],&v2[2],&v2[3]);
    int i,j,hit=0,blow=0;
    rep(i,4){
      if(v1[i]==v2[i])
	hit++;
      else
	rep(j,4){
	  if(i==j)continue;
	  if(v1[i]==v2[j])blow++;
	}
    }
    cout<<hit<<" "<<blow<<endl;
  }
}

C++: #include <iostream>
using namespace std;
int main( void )
{
  int a[4],b[4],hit,blow;
  while( 1 ){
    for( int i=0; i<4; i++ ) cin >> a[i];
    for( int i=0; i<4; i++ ) cin >> b[i];
    if( cin.eof() ) break;
    hit=0;
    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;
    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],!cin.eof()){
        int Hit=0,Blow=0;
        bool hantei[4];
        cin>>b[0]>>b[1]>>b[2]>>b[3];
        if(cin.eof()){
            break;
        }
        for(int i=0;i<4;i++){
            if(a[i]==b[i]){
                Hit++;
                hantei[i]=true;
            }
        }
        for(int i=0;i<4;i++){
            for(int j=0;j<4;j++){
                if(i==j){
                    continue;
                }
                if(!(hantei[i]) && b[i]==a[j]){
                    if(!hantei[j]){
                        Blow++;
                        break;
                    }
                }
            }
        }
        cout<<Hit<<' '<<Blow<<endl;
    }
    return 0;
}

C++: #include <iostream>

int main()
{
    int a[4], b[4];
    while (std::cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]) {
        int 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;
                }
            }
        }
        std::cout << hit << ' ' << blow << std::endl;
    }
}

C++: #include <iostream>

using namespace std;

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

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

  return 0;
}

C++: #include <iostream>
using namespace std;
int main(void){
    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 "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	vector<int> A(4),B(4);
	while(cin>>A[0]){
		vector<int> AN(10,0);
		AN[A[0]]++;
		REP(i,3){
			A[i+1]=in();
			AN[A[i+1]]++;
		}
		int blow=0,hit=0;
		REP(i,4){
			B[i]=in();
			if(AN[B[i]]) blow++;
			if(A[i]==B[i]){
				blow--;
				hit++;
			}
		}
		out(hit,blow);
	}
	return 0;
}

C++: #include<iostream>

using namespace std;

int main(void)
{
	int a1,a2,a3,a4,b1,b2,b3,b4;
	while(cin>>a1>>a2>>a3>>a4>>b1>>b2>>b3>>b4)
	{
		int hit,blow;
		hit=blow=0;
		if(a1==b1) hit++;
		else if(a1==b2||a1==b3||a1==b4) blow++;
		if(a2==b2) hit++;
		else if(a2==b1||a2==b3||a2==b4) blow++;
		if(a3==b3) hit++;
		else if(a3==b1||a3==b2||a3==b4) blow++;
		if(a4==b4) hit++;
		else if(a4==b1||a4==b2||a4==b3) blow++;
		cout<<hit<<" "<<blow<<endl;
	}
}

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

using namespace std;

void Solution()
{
//    int a1, a2, a3, a4;
//    int b1, b2, b3, b4;
//    
//    int a[2][4] = {a1, a2, a3, a4, b1, b2, b3, b4};
    
    int a[4];
    int b[4];
    
    int hit = 0;
    int blow = 0;
    
    while(cin>>a[0]>>a[1]>>a[2]>>a[3])
    {
        cin>>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]) && (i == j))
                {
                    
                    hit++;
                }
                else if((a[i] == b[j]) && (i != j))
                {
                    blow++;
                }
            }
        }
        
        cout<<hit<<" "<<blow<<endl;
    }
    
    return;
}

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