Taro and Hanako study biology and have watched beehives for a long time. They want to find the egg patterns that queen bees of one wild species lay. A queen bee lays a batch of eggs in a short time. Neither of them has ever caught a queen in the act, so every hive they find already holds eggs in its cells.
They record an egg layout by one convention. They assume the queen moved from a cell to an adjacent cell along a path that never returns to a cell it has already used, and they write that path down. Biology gives them no guarantee that such a path exists in every hive, but so far they have never failed to find one.
A cell touches six neighbors, so a move has six directions. Taro and Hanako write those six directions as the letters a, b, c, d, e and f, running counterclockwise around the cell. A record is the sequence of moves along the path, so a record of n letters marks n+1 cells.
The two of them studied hives in a forest separately, each with their own way of getting close to a hive without being stung.
They now have to report on their work jointly at a conference, and while merging their notes they find a serious fault in the convention. They never agreed which direction, in an absolute sense, the letter a points to. Each of them fixed a as some direction, and the two choices need not match. Either end of the path can also be taken as its start. One layout therefore produces several different records.
A hive is observed only from its front and never from its back, so a layout is never confused with its mirror image.
They may have recorded the same hive twice without knowing it, and they wrote down neither the place nor the time of an observation, so they have to find the duplicates in their notes. Write a program that decides whether two records were made from the same layout. Two records describe the same layout when the cells one of them marks can be brought onto the cells the other marks by turning the hive and sliding it, but never by flipping it over. Only which cells hold eggs matters, not the order in which the path visited them.
The first line holds the number of record pairs that follow. That number has at most three digits.
Each record pair takes three lines: two layout records, then a line holding a hyphen. A layout record is a sequence of the letters a, b, c, d, e and f. A record is empty when the queen laid a single egg, and an empty record is given as an empty line. You can trust Taro and Hanako that no path in the input visits a cell more than once. No line holds any character other than the ones described above, and no line is longer than one hundred characters.
For each pair of records, print a line holding either "true" or "false". Print "true" when the two records represent the same layout and "false" otherwise. The line must hold no other characters.