E. DoveCCL and Resistance
题号:NC15725
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
Special Judge, 64bit IO Format: %lld

题目描述

Do you remember Kanna-chan we met last year? She is so cute, and this year, she entered middle school, with Cirno. As we know, Cirno is bad at math, so she had trouble when studying physics.

Today, Kanna-chan's teacher is preparing for mid-term exam, one of the problem looks like follows:

Please calculate the equivalent resistance of the circuit below.

As Kanna-chan's teacher is too lazy, so he asked you for help, he will give you the answer of the problem, and your task is to generate a valid circuit satisfies that it's equivalent resistance equals to the answer.

输入描述:

Input contains one line with two integers, p and q, means the answer of the problem should be p/q, where , .

输出描述:

Output a circuit satisfy teacher's request. The first line of your input should be two integers, n and m, n is the number of nodes and m is the number of resistance you used. Where 


Then m lines follows, each line contains three integers, ,which means that there is a wi-Ohm resistance connected between ui and vi, , multiple resistances can be used between two nodes.


Then output two integers s, t, , means that the equivalent resistance between node s and node t equals to p/q.

示例1

输入

复制
22 9

输出

复制
3 4
1 2 2
2 3 1
2 3 1
2 3 4
1 3

说明