import scala.io.Source
import scala.annotation.tailrec

object Main{
  def main(args: Array[String]){
    val lines = for{
      in <- Source.stdin.getLines.toList
    }yield in.split(" ").toList.map(_.toInt)

    if(lines.length <= 2){
      val tup = hitAndBlow(lines.head, lines.last)
      println(tup._1 + " " + tup._2)
    }
    else{
      mulHitAndBlow(lines, List()).reverse.foreach{tup => println(tup._1 + " " + tup._2)}
    }
  }

  @tailrec
  def mulHitAndBlow(list: List[List[Int]], tupList: List[(Int, Int)]): List[(Int, Int)]={
    if(list.isEmpty) tupList
    else mulHitAndBlow(list.tail.tail, hitAndBlow(list.head, list.tail.head) :: tupList)
  }

  def hitAndBlow(list1: List[Int], list2: List[Int]): (Int, Int) ={
    val hit = numOfHit(list1, list2, 0)
    (hit, numOfBlow(list1, list2, 0) - hit)
  }

  @tailrec
  def numOfHit(list1: List[Int], list2: List[Int], n: Int): Int={
    if(list1.isEmpty) n
    else if(list1.head == list2.head) numOfHit(list1.tail, list2.tail, n + 1)
    else numOfHit(list1.tail, list2.tail, n)
  }

  @tailrec
  def numOfBlow(list1: List[Int], list2: List[Int], n: Int): Int={
    if(list2.isEmpty) n
    else if(checkBlow(list1, list2.head)) numOfBlow(list1, list2.tail, n + 1)
    else numOfBlow(list1, list2.tail, n)
  }

  def checkBlow(list1: List[Int], n :Int): Boolean = list1.contains(n)
}