Input file consist of multiple data sets. Each data set occupies one or more lines. There are no empty lines in the input file. Each line starts with a single letter 'D', 'C' or 'Q' (upper or lower case) followed by 1 to 5 integers with following meaning:
'D' (define) has only one argument which defines number of planets N considered in following data set (N<=6000000, planets are numerated from 1..N).
'C' (connect) creates a connection between a given pair(s) of planets.
'Q' (query) examines if a given pair(s) of planets are connected.
Both 'C' and 'Q' command ('X' in following text) share the same syntax:
X src dst – Creates a connection (or query) between given pair of planets (src, dst).
X src dst nnn – Creates a connection (or query) between src planet and nnn consecutive planets numerated from dst.
Example: X 1 100 3 creates following links (1,100), (1,101), (1,102).
X src dst nnn step – Creates a connection (or query) between src planet and nnn planets numerated from dst with given step.
Example: X 1 100 3 5 creates following links (1,100), (1,105), (1,110).
X src dst nnn dststep srcstep – Creates a connection (or query) between nnn pairs of planets numerated from src with srcstep and dst with dststep respectively.
Example: X 1 100 3 5 15 creates following links (1,100), (16,105), (31,110).