题目描述
Problem Description
Foolish Fusu and villainous Xiao F are playing a new type of card game.
Initially, Fusu and Xiao F each have $n$ cards in their hands. Each card has a suit $f$ and a point value $p$. In this problem, the suit is a positive integer not exceeding $m$, and the point value is a positive integer not exceeding $r$.
The game consists of $n$ rounds. In each round, Fusu will choose a card from his hand to play. Xiao F will then choose from his current hand the card with the same suit and a higher point value than the card Fusu played, specifically the one with the smallest point value among those that satisfy the condition. If no such card exists, Xiao F will not play any card.
Note that regardless of what card Xiao F plays, the round immediately ends, and Fusu will not play another card but instead start the next round.
Given the sequence of cards Fusu plays, please determine how many cards Xiao F has left in his hand at the end.
Input Format
The first line contains three integers, representing the number of cards each person has $n$, the upper limit of suits $m$, and the upper limit of point values $r$.
The second line contains $n$ integers, where the $i$-th integer represents the suit $f1_i$ of Fusu's $i$-th card.
The third line contains $n$ integers, where the $i$-th integer represents the point value $p1_i$ of Fusu's $i$-th card.
The fourth line contains $n$ integers, where the $i$-th integer represents the suit $f2_i$ of Xiao F's $i$-th card.
The fifth line contains $n$ integers, where the $i$-th integer represents the point value $p2_i$ of Xiao F's $i$-th card.
The sixth line contains a permutation of length $n$ describing Fusu's sequence of card plays. The $i$-th integer $p_i$ indicates that Fusu plays his $p_i$-th card in the $i$-th round.
Output Format
Output a single integer representing the number of cards Xiao F has left in his hand at the end.
Sample Input and Output
Input Sample #1
3 1 2
1 1 1
1 2 1
1 1 1
2 2 1
2 3 1
Output Sample #1
1
Input Sample #2
3 2 2
1 2 1
1 1 1
1 2 1
2 2 2
1 2 3
Output Sample #2
0
Notes
Sample 1 Explanation
Xiao F's card with suit $1$ and point value $1$ cannot beat any card. All other cards have been played.
Data Size and Constraints
- For $10\%$ of the data, $r = 1$;
- For $20\%$ of the data, $n = 1$;
- For $50\%$ of the data, $m = 1$;
- For $100\%$ of the data, $1 \leq n, m, r \leq 100$, $1 \leq f1_i, f2_i \leq m$, $1 \leq p1_i, p2_i \leq r$. $1 \leq p_i \leq n$, $p$ is a permutation of length $n$.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分