AT_scpc2026_div2_l ChannelTalk Workflow

Description

#### 表示言語 / / > ChannelTalk, an all-in-one AI messenger that facilitates real-time communication with customers, offers a workflow feature that allows anyone to easily create chatbots. Using ChannelTalk Workflow, you can combine triggers and actions like building blocks based on the customer and the situation to automate the entire process from the start to the end of a consultation. Additionally, frequently used functions can be created as modules and reused multiple times. Ino intends to build a chatbot using ChannelTalk Workflow to handle $ N $ different types of questions. Each question is assigned a unique number from $ 1 $ to $ N $ . Ino wants to add $ M $ modules to the workflow and number them from $ 0 $ to $ M-1 $ in the order they are added. Since Ino cannot manage too many modules, at most $ 2\,048 $ modules can be used. When question $ x $ is entered, module $ i $ operates as follows. - If $ x = i $ , it answers the question and ends the consultation. - If $ x \neq i $ , it enters question $ x $ to module $ L_i $ if $ x \le F_i $ , and module $ G_i $ if $ x \gt F_i $ . When a question is received, it is first input to module $ 0 $ , and executing each module takes $ 1 $ second. That is, the time taken to process question $ i $ is equal to the total number of modules passed through, including module $ 0 $ and module $ i $ , until the consultation ends. If the same module is passed through multiple times, it is counted as many times as it was passed through. Ino wants to ensure that the consultation ends in **exactly** $ K $ seconds regardless of which question from $ 1 $ to $ N $ is asked. Given the number of question types $ N $ and the ending time $ K $ , choose the number of modules $ M $ and the values of $ F_i $ , $ L_i $ , and $ G_i $ for each module so that the consultation always ends exactly at $ K $ seconds using at most $ 2\,048 $ modules. **Note that $ M $ does not need to be minimized.**

Input Format

The input is given from Standard Input in the following format: > $ N $ $ K $

Output Format

On the first line, output the number of modules $ M $ to use. $ (1 \le M \le 2\,048) $ From the second line, output $ M $ lines. On the $ (i+2) $ -th line, output three integers $ F_i $ , $ L_i $ , and $ G_i $ representing module $ i $ , separated by spaces. $ (0 \le F_i \le N;\ 0 \le L_i, G_i < M) $ If no solution exists, output `-1` instead.

Explanation/Hint

### Constraints - $ 2 \le K \le N \le 1\,000 $ - All input values are integers.