The only difference between easy and hard versions are constraints on n and k.

You are messaging in one of the popular social networks via your smartphone. Your smartphone can show at most k most recent conversations with your friends. Initially, the screen is empty (i.e. the number of displayed conversations equals 0).

Each conversation is between you and some of your friends. There is at most one conversation with any of your friends. So each conversation is uniquely defined by your friend.

You (suddenly!) have the ability to see the future. You know that during the day you will receive n messages, the i-th message will be received from the friend with ID id_i (1 ≤ id_i ≤ 10^9).

If you receive a message from id_i in the conversation which is currently displayed on the smartphone then nothing happens: the conversations of the screen do not change and do not change their order, you read the message and continue waiting for new messages.

Otherwise (i.e. if there is no conversation with id_i on the screen):

  * Firstly, if the number of conversations displayed on the screen is k, the last conversation (which has the position k) is removed from the screen. 
  * Now the number of conversations on the screen is guaranteed to be less than k and the conversation with the friend id_i is not displayed on the screen. 
  * The conversation with the friend id_i appears on the first (the topmost) position on the screen and all the other displayed conversations are shifted one position down. 



Your task is to find the list of conversations (in the order they are displayed on the screen) after processing all n messages.

Input

The first line of the input contains two integers n and k (1 ≤ n, k ≤ 200) — the number of messages and the number of conversations your smartphone can show.

The second line of the input contains n integers id_1, id_2, ..., id_n (1 ≤ id_i ≤ 10^9), where id_i is the ID of the friend which sends you the i-th message.

Output

In the first line of the output print one integer m (1 ≤ m ≤ min(n, k)) — the number of conversations shown after receiving all n messages.

In the second line print m integers ids_1, ids_2, ..., ids_m, where ids_i should be equal to the ID of the friend corresponding to the conversation displayed on the position i after receiving all n messages.

Examples

Input


7 2
1 2 3 2 1 3 2


Output


2
2 1 


Input


10 4
2 3 3 1 1 2 1 2 3 3


Output


3
1 3 2 

Note

In the first example the list of conversations will change in the following way (in order from the first to last message):

  * []; 
  * [1]; 
  * [2, 1]; 
  * [3, 2]; 
  * [3, 2]; 
  * [1, 3]; 
  * [1, 3]; 
  * [2, 1]. 



In the second example the list of conversations will change in the following way:

  * []; 
  * [2]; 
  * [3, 2]; 
  * [3, 2]; 
  * [1, 3, 2]; 
  * and then the list will not change till the end. 
import com.sun.corba.se.impl.orbutil.graph.Graph;

import java.io.*;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.Stack;


public class Main {

    static final boolean debug = false;
    static final boolean fileIO = false;

    public static final int INF = Integer.MAX_VALUE;

    public static void main(String[] args) throws Exception {
        InputStream is = null;
        OutputStream os = null;
        if (fileIO) {
            is = new FileInputStream("input.txt");
            os = new FileOutputStream("output.txt");
        } else {
            is = System.in;
            os = System.out;
        }
        InputReader in = new InputReader(is);
        PrintWriter out = new PrintWriter(os);
        new Task_2().solve(in, out);
        out.close();
    }
}

class Task_2 {

    // position in the order -> id of the author corresponding to position
    TreeMap<Integer, Integer> posId = new TreeMap<>();

    // id -> position
    TreeMap<Integer, Integer> stateId = new TreeMap<>();
    // position -> id
    TreeMap<Integer, Integer> statePos = new TreeMap<>();

    public void solve(InputReader in, PrintWriter out) throws Exception {
        int n = in.nextInt(), k = in.nextInt();
        for (int i = 0; i < n; ++i) {
            int idi = in.nextInt();
            posId.putIfAbsent(i, idi);
        }
        // Implementation
        for (Map.Entry<Integer, Integer> e : posId.entrySet()) {
            int id = e.getValue();
            if (stateId.get(id) != null) { continue; }
            if (stateId.size() == k) {
                // TODO:
                int idToRemove = statePos.get(k - 1);
                statePos.remove(k - 1);
                stateId.remove(idToRemove);
            }
            for (Map.Entry<Integer,Integer> stateIdEntry : stateId.entrySet()) {
                int _id = stateIdEntry.getKey();
                int _pos = stateIdEntry.getValue();
                stateId.put(_id, _pos + 1);
                statePos.put(_pos + 1, _id);
            }
            stateId.put(id, 0);
            statePos.put(0, id);
            if (Main.debug) {
                for (int i = 0; i < (int)(statePos.size()); ++i) {
                    System.out.print(statePos.get(i));
                    if (i < statePos.size() - 1) {
                        System.out.print(" ");
                    } else {
                        System.out.println();
                    }

                }
            }
        }
        // Result
        int m = statePos.size();
        out.println(m);
        for (int i = 0; i < m; ++i) {
            out.print(statePos.get(i));
            if (i < (m - 1)) {
                out.print(" ");
            } else {
                out.println();
            }
        }
    }
}


class Task_8 {

    int n;
    int x1, y1, x2, y2;


    long f1(long time) {
        long details = (time + y1) / (x1 + y1);
        return details;
    }

    long f2(long time) {
        long details = (time + y2) / (x2 + y2);
        return details;
    }

    // maxDetails for a fixed time @time
    int f(long time) {
        // time to complete the task
        return f1(time) + f2(time) < n ? 0 : 1;
    }




    long higher() {
        long lo = 1, hi = (long)(1e18 + 1);
        while (lo + 1 < hi) {
            long m = (lo + hi) / 2;
            if (f(m) == 1) {
                hi = m;
            } else {
                lo = m;
            }
        }
        return hi;
    }

    public void solve(InputReader in, PrintWriter out) throws Exception {
        n = in.nextInt();
        x1 = in.nextInt();
        y1 = in.nextInt();
        x2 = in.nextInt();
        y2 = in.nextInt();
        //
        long answer = higher();
        out.println(answer);
    }
}

class Task_7 {

    final int LEFT = 1;
    final int RIGHT = 2;
    final int UP = 3;
    final int DOWN = 4;

    class Wall {
        int id;
        int dir;
        public Wall(int id, int dir) {
            this.id = id;
            this.dir = dir;
        }
    }

    int[][] a;


    class Segment {
        int l, r;
        public Segment(int l, int r) {
            this.l = l;
            this.r = r;
        }
    }


    ArrayList<Segment> cols = new ArrayList<>();
    ArrayList<Segment> rows = new ArrayList<>();

    class Point {
        public static final int OPEN = 0;
        public static final int CLOSED = 2;
        int coordinate;
        int weight; // either OPEN or CLOSED
        int id; // id of the segment it belongs to
        public Point(int coordinate, int weight, int id) {
            this.coordinate = coordinate;
            this.weight = weight;
            this.id = id;
        }
    }

    int __solve(ArrayList<Segment> sgs) {
        int ans = 0;
        TreeSet<Point> pts = new TreeSet<>(new Comparator<Point>() {
            @Override
            public int compare(Point o1, Point o2) {
                if (o1.coordinate != o2.coordinate) {
                    return o1.coordinate - o2.coordinate;
                } else if (o1.weight != o2.weight) {
                    return o1.weight - o2.weight;
                } else {
                    return 0;
                }
            }
        });
        for (int i = 0; i < sgs.size(); ++i) {
            pts.add(new Point(sgs.get(i).l, Point.OPEN, i));
            pts.add(new Point(sgs.get(i).r, Point.CLOSED, i));
        }
        int lo = -1; // Rightmost point p is put into sgs[lo].r
        for (Point p : pts) {
            if (p.weight == Point.CLOSED) {
                //
            }
        }
        return ans;
    }


    public void solve(InputReader in, PrintWriter out) throws Exception {
        int n = in.nextInt(), m = in.nextInt();
        a = new int[n][m];
        for (int i = 0; i < n; ++i) {
            String line = in.nextString();
            for (int j = 0; j < m; ++j) {
                if (line.charAt(j) == '.') { // Empty
                    a[i][j] = 0;
                } else { // Bomb
                    a[i][j] = 1;

                }
            }
        }
        // adding vertical walls between columns
        for (int i = 0; i < n; ++i) {
            int lo = -1;
            for (int j = 0; j < m; ++j) {
                if (a[i][j] == 1) {
                    if (lo != -1) {
                        cols.add(new Segment(lo + 1, j));
                    }
                    lo = j;
                }
            }
        }
        // adding horizontal walls between rows
        for (int j = 0; j < m; ++j) {
            int lo = -1;
            for (int i = 0; i < n; ++i) {
                if (a[i][j] == 1) {
                    if (lo != -1) {
                        rows.add(new Segment(lo + 1, j));
                    }
                    lo = i + 1;
                }
            }
        }
        // answer = ?
        int x = __solve(cols);
        int y = __solve(rows);
        out.println(x + y);

    }
}


class NegativeNumbers {

    final int n = 3, m = 4;

    private int _solve(int[][] data, int n, int m) {
        int j = m - 1;
        int count = 0;
        for (int i = 0; i < n; ++i) {
            while (j >= 0 && data[i][j] >= 0) {
                j -= 1;
            }
            count += (j + 1);
        }
        return count;
    }

    public void solve(InputReader in, PrintWriter out) {
        int[][] data = {
                {-3, -2, -1, 1},
                {-1, 2, 3, 4},
                {4, 5, 6, 7}
        };
        // [-3, -2, -1, 1]
        // [-1, 2, 3, 4]
        // [4, 5, 6, 7]
        out.println(_solve(data, n, m));
    }
}


class KNearestPoints {

    class Point {
        int x, y;
        public Point(int x, int y) {
            this.x = x;
            this.y = y;
        }

        public double distSquared() {
            return this.x * this.x + this.y * this.y;
        }

        @Override
        public String toString() {
            return "(" + this.x + " " + this.y + ")";
        }
    }

    public void solve(InputReader in, PrintWriter out) throws Exception {
        //
        TreeSet<Point> pts = new TreeSet<>(new Comparator<Point>() {
            @Override
            public int compare(Point o1, Point o2) {
                double d1 = o1.x * o1.x + o1.y * o1.y;
                double d2 = o2.x * o2.x + o2.y * o2.y;
                if (d1 > d2) {
                    return 1;
                } else if (d1 == d2) {
                    return 0;
                } else {
                    return -1;
                }
            }
        });
        int n = in.nextInt();
        int k = in.nextInt();
        List<Point> list = new ArrayList<>();
        for (int i = 0; i < n; ++i) {
            int x = in.nextInt();
            int y = in.nextInt();
            Point p = new Point(x, y);
            list.add(p);
        }
        //
        for (int i = 0; i < k; ++i) {
            pts.add(list.get(i));
        }
        //
        for (int i = k; i < n; ++i) {
            if (pts.last().distSquared() > list.get(i).distSquared()) {
                pts.pollLast();
                pts.add(list.get(i));
            }
        }
        //
        for (Point p : pts) {
            out.println(p);
        }

    }
}









class ReverseWords {

    public void solve(InputReader in, PrintWriter out) throws Exception {
        in.setSpaceCharFilter(new InputReader.SpaceCharFilter() {
            @Override
            public boolean isSpaceChar(int ch) {
                return ch == -1 || ch == '\n';
            }
        });
        StringBuilder s = new StringBuilder(in.nextString());
        _reverse(s, 0, s.length() - 1);
        out.println(s);
        //
        for (int i = 0; i < s.length(); ++i) {
            int j = i;
            while (j < s.length() && s.charAt(j) != ' ') {
                ++j;
            }
            _reverse(s, i, j - 1);
            i = j;
        }
        out.println(s);
    }

    private void _reverse(StringBuilder s, int lo, int hi) {
        for (int k = 0; k < (hi - lo + 1) / 2; ++k) {
            char tmp = s.charAt(lo + k);
            s.setCharAt(lo + k, s.charAt(hi - k));
            s.setCharAt(hi - k, tmp);
        }
    }
}



class SpacesToTheEnd {

    public void solve(InputReader in, PrintWriter out) throws Exception {

        // Поддерживаем инвариант:
        // S[left..right-1] => содержит только пробелы, при этом S[left - 1] != ' '
        String src = new String("the sky is blue");
        StringBuilder s = new StringBuilder(src);
        for (int left = 0, right = 0; right < s.length(); ++right) {
            if (s.charAt(right) != ' ') {
                char tmp = s.charAt(left);
                s.setCharAt(left, s.charAt(right));
                s.setCharAt(right, tmp);
                ++left;
            }
        }
        out.println(s);
        // 0123456789
        // the sky  is  blue
        // left = 3, right = 2
        // left = 3, right = 4 => swap(3,4)
        // thes ky  is  blue
    }
}


class SpiralMatrix {

    // N = 3
    // 1 2 3
    // 8 9 4
    // 7 6 5

    int fillLayer(int level, int[][] a, int cnt) {
        // level = 0 => a[0][0] = 1, a[0][1] = 2, a[0][2] = 3, ... , a[0][n - 1] = n
        // a[1][n-1] = n + 1, a[2][n-2] = n + 2, ... ,
        // БЕЗ РЕКУРСИИ !!!
        // CASE 1

        return 1;
    }

    void f(int[][] a, int level, int NUMBER_OF_LAYERS, int cnt) {
        if (level >= NUMBER_OF_LAYERS) {
            return;
        } else {
            // На текущем слое @level мы будем заполнять его начиная с числа @cnt
            int lastFilledNumber = fillLayer(level, a, cnt);
            f(a, level + 1, NUMBER_OF_LAYERS, lastFilledNumber);
        }
    }

    public void solve(InputReader in, PrintWriter out) throws Exception {
        int n = in.nextInt();
        int[][] a = new int[n][n];
        int NUMBER_OF_LAYERS = n / 2 + n % 2;
        f(a, 0, NUMBER_OF_LAYERS, 1);
        //
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                out.print(a[i][j]);
                if (j < n - 1) {
                    out.print(" ");
                }
            }
            out.println();
        }
    }
}




class SegmentTree {

    private static long NIL = Long.MAX_VALUE;

    public interface Function {
        public long value(long a, long b);
    }

    private Function f;

    private long[] tree;
    private int n;

    public SegmentTree(int[] array, Function f) {
        this.f = f;
        this.n = array.length;
        int sz = 1;
        while (sz < n) sz <<= 1;
        this.tree = new long[sz + (sz - 1)];
        build(array, 0, 0, n - 1);
    }

    private void build(int[] array, int id, int lo, int hi) {
        if (lo == hi) {
            tree[id] = array[lo];
        } else {
            int m = (lo + hi) >> 1;
            build(array, 2 * id + 1, lo, m);
            build(array, 2 * id + 2, m + 1, hi);
            tree[id] = f.value(tree[2 * id + 1], tree[2 * id + 2]);
        }
    }

    public long query(int i, int j) {
        return query(0, 0, n - 1, i, j);
    }
    private long query(int id, int lo, int hi, int i, int j) {
        if (i <= lo && hi <= j) {
            return tree[id];
        }
        if (lo > j || hi < i) {
            return NIL;
        }
        int m = (lo + hi) >> 1;
        int l_id = 2 * id + 1;
        int r_id = 2 * id + 2;
        if (j <= m) {
            return query(l_id, lo, m, i, j);
        }
        if (i > m) {
            return query(r_id, m + 1, hi, i, j);
        }
        return f.value(query(l_id, lo, m, i, j), query(r_id, m + 1, hi, i, j));
    }

    // @a[i] = value
    public void update(int i, int value) {
        update(0, 0, n - 1, i, value);
    }
    //
    private void update(int id, int lo, int hi, int i, int value) {
        if (lo == hi) {
            tree[id] = value;
        } else {
            int m = (lo + hi) >> 1;
            int l_id = 2 * id + 1;
            int r_id = 2 * id + 2;
            if (i <= m) {
                update(l_id, lo, m, i, value);
            } else {
                update(r_id, m + 1, hi, i, value);
            }
            tree[id] = f.value(tree[l_id], tree[r_id]);
        }
    }
}

class InputReader {

    class EOF extends Exception {
        public EOF(String msg) {
            super(msg);
        }
    }

    private InputStream stream;
    private byte[] buf;
    private int curChar = 0, snumChars = 0;

    private SpaceCharFilter filter;

    public InputReader(InputStream stream) {
        this.stream = stream;
        this.buf = new byte[8192];
        this.filter = null;
    }

    public void setSpaceCharFilter(SpaceCharFilter filter) {
        this.filter = filter;
    }


    public int snext() {
        if (curChar >= snumChars) {
            curChar = 0;
            try {
                snumChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (snumChars <= 0) {
                return -1;
            }
        }
        return buf[curChar++];
    }

    public int nextInt() throws EOF, InputMismatchException {
        int c = snext();
        while (isSpaceChar(c) && c != -1) {
            c = snext();
        }
        if (c == -1) {
            throw new EOF("End of file");
        }
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = snext();
        }
        int res = 0;
        while (!isSpaceChar(c)) {
            if (c < '0' || c > '9') {
                throw new InputMismatchException();
            }
            res *= 10;
            res += c - '0';
            c = snext();
        }
        return res * sgn;
    }

    public double nextDouble() throws EOF, InputMismatchException {
        return Double.parseDouble(nextString());
    }

    public long nextLong() throws EOF, InputMismatchException {
        return Long.parseLong(nextString());
    }

    public String nextString() throws InputMismatchException, EOF {
        int c = snext();
        while (isSpaceChar(c) && c != -1) {
            c = snext();
        }
        if (c == -1) {
            throw new EOF("End of file");
        }
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = snext();
        } while (!isSpaceChar(c));
        return res.toString();
    }



    public boolean isSpaceChar(int c) {
        if (filter != null) {
            return filter.isSpaceChar(c);
        }
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public interface SpaceCharFilter {
        public boolean isSpaceChar(int ch);
    }
}

