Problem:
Set Intersection

Find the intersection of two sets $A = \{a_0, a_1, ..., a_{n-1}\}$ and $B = \{b_0, b_1, ..., b_{m-1}\}$.

Input

The input is given in the following format.

$n$
$a_0 \; a_1 \; ... \; a_{n-1}$
$m$
$b_0 \; b_1 \; ... \; b_{m-1}$

Elements of $A$ and $B$ are given in ascending order respectively. There are no duplicate elements in each set.

Output

Print elements in the intersection in ascending order. Print an element in a line.

Constraints

$1 \leq n, m \leq 200,000$

$0 \leq a_0 < a_1 < ... < a_{n-1} \leq 10^9$

$0 \leq b_0 < b_1 < ... < b_{m-1} \leq 10^9$

Sample Input 1

4
1 2 5 8
5
2 3 5 9 11

Sample Output 1

2
5

Solution in C# (judge verdict: Accepted)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ITP2_9_B
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int n = ReadInt();
            int[] a = ReadIntAr();
            int m = ReadInt();
            int[] b = ReadIntAr();
            a = a.Intersect(b).ToArray();
            Array.Sort(a);
            foreach (var item in a) Console.WriteLine(item);
        }


        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }
        static string WriteAr(int[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(double[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(long[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }

    }

}