// Arup Guha
// 3/23/2015
// Solution to January 14 Bronze USACO Problem: Reorder

import java.util.*;
import java.io.*;

public class reorder {

	public static void main(String[] args) throws Exception {

		Scanner stdin = new Scanner(new File("reorder.in"));
		int n = stdin.nextInt();
		int[] start = new int[n];
		int[] end = new int[n];

		// Read in orderings.
		for (int i=0; i<n; i++)
			start[i] = stdin.nextInt()-1;
		for (int i=0; i<n; i++)
			end[stdin.nextInt() - 1] = i;
		stdin.close();

		// Initialize stuff.
		int maxLen = -1;
		int numCycles = 0;
		boolean[] used = new boolean[n];

		// Try starting a cycle at each position.
		for (int i=0; i<n; i++) {

			// Count this cycle length.
			int len = 0;

			// Start here.
			int next = i;

			// Do this cycle.
			while (!used[next]) {
				used[next] = true;
				next = end[start[next]];
				len++;
			}

			// Update it it was a real cycle.
			if (len > 1) {
				numCycles++;
				maxLen = Math.max(maxLen, len);
			}
		}

		// Write out the result.
		BufferedWriter fout = new BufferedWriter(new FileWriter("reorder.out"));
		fout.write(numCycles+" "+maxLen+"\n");
		fout.close();
	}
}