fork download
  1. k, q = map (int, raw_input ().split ())
  2. n = 3 ** k
  3. m = n - 1
  4. print n, m
  5.  
  6. root = 1
  7. size = 0
  8. cur = 2
  9. while cur <= n:
  10. old = root
  11. root = cur
  12. cur += 1
  13. for k in range (size):
  14. print root, cur
  15. cur += 1
  16. print root, old
  17. for k in range (size + 1):
  18. print root, cur
  19. cur += 1
  20. size = cur - 2
  21.  
  22. print q
  23. for j in range (q):
  24. print 1, 3, n * 5 // 6
  25.  
Success #stdin #stdout 0.01s 8976KB
stdin
2 5
above is for ideone
below is for maxtest
10 100000
stdout
9 8
2 1
2 3
4 5
4 6
4 2
4 7
4 8
4 9
5
1 3 7
1 3 7
1 3 7
1 3 7
1 3 7