题目描述
Background
A set is a concept in mathematics, which can be simply described as a collection of numbers.
Sets have the following characteristics:
- Unordered: In any set, the status of each element is the same, and the elements are unordered.
- Distinctness: In a set, any two elements are considered different, meaning each element can appear only once.
- Definiteness: Given a set, any element either belongs to or does not belong to the set; there is no ambiguity.
An element $a$ belonging to set $A$ is denoted as $a \in A$, and conversely, $a \notin A$.
If a set contains no elements, it is called the empty set, denoted as $\varnothing$. The empty set is a subset of all sets.
The number of elements in a set is called the size of the set. The size of set $A$ can be denoted as $|A|$.
Set $C$ is the intersection of sets $A$ and $B$ if and only if for any element $a \in C$, $a \in A$ and $a \in B$, and for any element $b \notin C$, $b \notin A$ or $b \notin B$. This is denoted as $C = A \cap B$.
Set $C$ is the union of sets $A$ and $B$ if and only if for any element $a \in C$, $a \in A$ or $a \in B$, and for any element $b \notin C$, $b \notin A$ and $b \notin B$. This is denoted as $C = A \cup B$.
Simply put, the intersection consists of elements that belong to both sets, like the overlap of two sets, while the union consists of elements that belong to either set, like the combination of two sets.
Specifically, for sets of the form $\{x | a \le x \le b\}$, they can be denoted as $[a, b]$. If the left symbol is changed to a less-than sign, the left bracket is changed to a parenthesis. The same applies to the right side.
Problem Description
Given two sets $A$ and $B$, both consisting of integers between $0$ and $63$.
Please calculate and output:
- $|A|$
- $A \cap B$
- $A \cup B$
Input Format
The input consists of four lines.
The first line contains an integer $x (0 \le x \le 63)$, representing the number of elements in set $A$.
The second line contains $x$ integers $a_1, ..., a_x$, representing the elements of set $A$, ensuring no duplicates. If $A$ is the empty set, this line will have no numbers.
The third line contains an integer $y (0 \le y \le 63)$, representing the number of elements in set $B$.
The fourth line contains $y$ integers $b_1, ..., b_y$, representing the elements of set $B$, ensuring no duplicates. If $B$ is the empty set, this line will have no numbers.
Output Format
Output three lines.
The first line should contain an integer, representing $|A|$.
The second line should contain several integers, representing the elements of $A \cap B$, sorted in ascending order and separated by spaces. If it is the empty set, this line should be empty, preserving the newline.
The third line should contain several integers, representing the elements of $A \cup B$, sorted in ascending order and separated by spaces. If it is the empty set, this line should be empty, preserving the newline.
Sample Input and Output
Sample Input #1
4
1 3 5 8
3
3 6 8
Sample Output #1
4
3 8
1 3 5 6 8
Sample Input #2
0
4
1 2 3 4
Sample Output #2
0
1 2 3 4
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分