cswork / OAOpen practice workspace

SnowflakeOA #42

Process Logs

Estimated EasyJudge-ready

Topics (AI-labelled)Hashing

Each log is sender recipient amount. A user is counted once for a log whenever they take part in it as the sender or the recipient; a transfer to oneself still counts only once. Output the ID of every user who takes part in at least threshold logs, sorted in ascending numeric order, not lexicographic string order. The amount does not affect the count.

Input

The first line contains n threshold, followed by n lines of sender recipient amount. 1≤n≤100000, 1≤threshold≤n; each field is a positive decimal integer of 1..9 digits without leading zeros. The original text guarantees that at least one user is output.

Output

First output the number of users, then output each user ID in ascending numeric order.

Example 1

Input:

3 2
1 2 100
1 1 5
10 1 9

Output:

1
1

Example 2

Input:

1 1
2 10 1

Output:

2
2 10

Example 3

Input:

1 1
999999999 999999999 999999999

Output:

1
999999999

Example notes

The answers to the three public examples are, in order: 1 1; 2 2 10; 1 999999999. The examples were checked by independent enumeration, state search, or direct simulation.

Editorial

Loading solution…