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++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
template<typename V> constexpr typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  vi a(4), b(4);
  while (cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]) {
    vi c, d;
    int s = 0;
    rep(i, 4) {
      if (a[i] == b[i]) {
        s++;
      } else {
        c.pb(a[i]), d.pb(b[i]);
      }
    }
    vi interset;
    sort(all(c));
    sort(all(d));
    set_intersection(all(c), all(d), back_inserter(interset));
    cout << s << ' ' << interset.size() << endl;
  }
}

C++: #include<iostream>

using namespace std;


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

  while(cin >> a[0]>> a[1]>> a[2]>>a[3]){
    blow = 0;hit=0;
    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++;
	if(a[i]== b[j]&& i!=j)blow++;
      }
    }

    cout << hit <<" "<< blow<< endl;//
  }


  return 0;
}

C++: ////   template  ///////////////////////////////////////////////////////
#include <stdlib.h>
#include <sys/time.h>
#include <stdio.h>
#include <sys/resource.h>
#include <iostream>
#include <vector>
#include <bitset>
using namespace std;

class timer{
	enum KIND{ REAL, CPU }; // real_time or cpu_time
	double t0; // start
	double t1; // end
	KIND kind_of_time; // default is real_time
	double get_realtime(){struct timeval tv; gettimeofday(&tv, NULL);
		return tv.tv_sec + (double)tv.tv_usec*1e-6;}
	double get_cputime(){struct rusage RU; getrusage(RUSAGE_SELF, &RU); 
		return RU.ru_utime.tv_sec + (double)RU.ru_utime.tv_usec*1e-6;}
public:
	timer(){kind_of_time = REAL;}
	void set(KIND k){kind_of_time = k;}
	void start(){t0 = get_realtime();}
	void stop(){t1 = get_realtime();}
	void print(){printf("TotalTime : %.3fsec\n", t1-t0);}
};
////////////////////////////////////////////////////////////////////////

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;
		bitset<10> fa, fb;
		for(int i=0; i<4; i++){
			if(a[i]==b[i]) hit++;
			fa.set(a[i]), fb.set(b[i]);
		}
		for(int i=0; i<10; i++)
			if(fa[i]&fb[i]) blow++;
		blow -= hit;
		cout << hit << " " << blow << endl;
	}

    return 0;
}

C++: #include<iostream>
#include<stdio.h>
#include<math.h>
#include<string>
#include<queue>
#include<algorithm>
#include<utility>
#include<vector>
#include<list>
using namespace std;
int main() {
	int a[8], hit = 0, blow = 0, k = 0, f, cnt=0;
	while (cin >> f) {
		a[k] = f;
		k++;
		if (k % 8 == 0) {
			for (int i = 0; i < 4; ++i) {
				if (a[i] == a[i+4]) {
					hit++;
					a[i] = -1;
					a[i+4] = -1;
					continue;
				}
				for (int j = i+1; j < 4; ++j) {
					if (a[i] == a[j+4] )blow++;
				}
			}
			cout << hit << " " << blow << endl;
			k = 0;
			hit = 0;
			blow = 0;
		}
	}
	return 0;
}

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

int main(){
  int t=1,i,j,h,bu,a[4],b[4];

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

  for(i=0;i<4;i++){
      cin>>b[i];
    }
  h=0;bu=0;
  for(i=0;i<4;i++){
    for(j=0;j<4;j++){
      if(a[i]==b[j]&&i==j)h+=1;
      else if(a[i]==b[j])bu+=1;   
    }
  }
  cout<<h<<" "<<bu<<endl;
  }
  return 0;
}

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

int main() {
  int a[5],b[5];
  while ( cin >> a[1] >> a[2] >> a[3] >> a[4]
	  >> b[1] >> b[2] >> b[3] >> b[4] ) {
    int h = 0,bb = 0;
    for ( int i = 1; i < 5; i++ ) {
      if ( a[i] == b[i] ) h++;
    }

    for ( int i = 1; i < 5; i++ ) {
      for ( int j = 1; j < 5; j++ ) {
	if ( i != j && a[i] == b[j] ) bb++;
      }
    }
    cout << h << " " << bb << endl;
  }
  return 0;
}

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];
    
    while(cin>>a[0]>>a[1]>>a[2]>>a[3])
    {
        int hit = 0;  // should define hit and below inside the loop, otherwise, it can be accumulated
        int blow = 0;
        
        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])
                {
                    if (i == j)
                    {
                        hit++;
                    }
                    
                    if(i != j)
                    {
                        blow++;
                    }
                }
                else
                    continue;
            }
        }
        
        cout<<hit<<" "<<blow<<endl;
    }
}

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

C++: while gets
	a=$<.split.map(&:to_i)
	b=gets.split.map(&:to_i)
	c,d=0,0;
	4.times do |i|
		if a[i]==b[i] then
			c+=1
		else
			4.times do |j|
				if a[i]==b[j] then
					d+=1;break;
				end
			end
		end
	end
	print c," ",d,"\n"
end

C++: #include<iostream>
#include<sstream>
#include<fstream>
#include<cstdio>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<string>
using namespace std;

int main(){
	int num1[4],num2[4];
	while(cin>>num1[0]>>num1[1]>>num1[2]>>num1[3]>>num2[0]>>num2[1]>>num2[2]>>num2[3]){
		int h=0,b=0;
		for(int x=0;x<4;++x){
			for(int y=0;y<4;++y){
				if(num1[x]==num2[y])++b;
				if(x==y && num1[x]==num2[y])++h;
			}		
		}
		cout<<h<<" "<<b-h<<endl;
	}	
	return 0;
}