Sharing apples and bananas

Given a apples and b bananas, print every common divisor n of a and b with the per-friend apple and banana counts.

Easy2MathNumber theoryImplementationNo attempts yetTime limit2sMemory limit512 MB

Problem

Areum has a pile of apples and a pile of bananas, but she does not like fruit, so she gives all of it to her friends and keeps nothing for herself. She always shares fairly and never cuts a piece of fruit. If there are nn friends, all nn get the same number of apples and the same number of bananas, and no fruit is left over.

For example, with 8 apples and 4 bananas there are only three fair ways to share.

  • 1 friend gets all 8 apples and all 4 bananas.
  • 2 friends each get 4 apples and 2 bananas.
  • 4 friends each get 2 apples and 1 banana.

Write a program that prints every way Areum can share the fruit.

Input

The first line contains the number of apples aa and the number of bananas bb, separated by a space. (1a,b10001 \le a, b \le 1000)

Output

Print every possible way to share the fruit. For each way, print on one line the number of friends, the number of apples one friend gets, and the number of bananas one friend gets, separated by spaces. Print each way exactly once, ordered by increasing number of friends.