Set Difference

Interview

Time limit2sMemory limit256 MB

Summary
Given two sets of up to 500,000 natural numbers each, output the count and sorted list of elements present in A but not in B.
Level

Easy3 of 10

Topics
Hash map, Sorting, Array
Solved
No attempts yet

Problem

You are given two sets A and B of natural numbers. Write a program that finds every element that belongs to A but not to B.

Input

The first line contains the number of elements of A, n(A), and the number of elements of B, n(B), separated by a space (1 ≤ n(A), n(B) ≤ 500,000). The second line lists the elements of A and the third line lists the elements of B, separated by spaces. Each element is a natural number no greater than 2,147,483,647, and the elements within a single set are distinct.

Output

On the first line, print the number of elements that belong to A but not to B. On the second line, print those elements in increasing order, separated by spaces. If there is no such element, print only 0 on the first line.

Examples2

  1. Example 1

    Input
    4 3
    2 5 11 7
    9 7 4
    
    Expected output
    3
    2 5 11
    
  2. Example 2

    Input
    3 5
    2 5 4
    1 2 3 4 5
    
    Expected output
    0