Patisserie ABC 2

AtCoder
IDabc200_e
Time2000ms
Memory256MB
Difficulty
Takahashi, a pastry chef at _ABC Confiserie_, has decided to make cakes to celebrate AtCoder Beginner Contest 200. A cake made by Takahashi has three parameters: _beauty_, _taste_, and _popularity_, each of which is represented by an integer between $1$ and $N$ (inclusive). He has made a cake of beauty $i$, taste $j$, and popularity $k$ for every triple $(i,j,k)\ (1 \le i,j,k \le N)$. Then, he has arranged these $N^3$ cakes in a row, as follows: * The cakes are in ascending order of sum of beauty, taste, and popularity from left to right. * For two cakes with the same sum of beauty, taste, and popularity, the cake with the smaller beauty is to the left. * For two cakes with the same sum and the same beauty, the cake with the smaller taste is to the left. Find the beauty, taste, and popularity of the $K$\-th cake from the left. ## Constraints * All values in input are integers. * $1 \le N \le 10^6$ * $1 \le K \le N^3$ ## Input Input is given from Standard Input in the following format: $N$ $K$ [samples]
Samples
Input #1
2 5
Output #1
1 2 2

The cakes are in the following order:
$(1,1,1),(1,1,2),(1,2,1),(2,1,1),(1,2,2),(2,1,2),(2,2,1),(2,2,2)$.
Here, each triple of integers represents the beauty, taste, and popularity of a cake.
Input #2
1000000 1000000000000000000
Output #2
1000000 1000000 1000000

The values in input may be large.
Input #3
9 47
Output #3
3 1 4
API Response (JSON)
{
  "problem": {
    "name": "Patisserie ABC 2",
    "description": {
      "content": "Takahashi, a pastry chef at _ABC Confiserie_, has decided to make cakes to celebrate AtCoder Beginner Contest 200. A cake made by Takahashi has three parameters: _beauty_, _taste_, and _popularity_, e",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc200_e"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Takahashi, a pastry chef at _ABC Confiserie_, has decided to make cakes to celebrate AtCoder Beginner Contest 200.\nA cake made by Takahashi has three parameters: _beauty_, _taste_, and _popularity_, e...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments