cswork / OAOpen practice workspace

IBMOA #64

Process Logs

Estimated EasyJudge-ready

Topics (AI-labelled)HashingStrings

Each log line records the sending user, the receiving user and the amount. Return the IDs of users involved in at least threshold logs, in ascending numeric order. A self-transfer log counts only once for that user, and 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; all three fields are 1..9-digit decimal numbers whose first digit is non-zero, and the answer is guaranteed to be non-empty.

Output

Output the number of users on the first line, followed by one ID per line in ascending numeric order.

Example 1

Input:

3 2
2 10 7
10 10 8
2 3 9

Output:

2
2
10

Example 2

Input:

3 2
1 1 1
2 2 1
2 3 1

Output:

1
2

Example 3

Input:

1 1
99 100 1

Output:

2
99
100

Example notes

The outputs of the three public examples are, in order: 2 / 2 / 10; 1 / 2; 2 / 99 / 100. These answers were verified by independent enumeration or direct simulation.

Editorial

Loading solution…