### constant

DXYS = [[1, -1], [0, -1], [-1, 0], [-1, 1], [0, 1], [1, 0]]
CH_A = 'a'.ord

### subroutines

def same?(p0, p1)
  return false if p0.length != p1.length

  x = y = 0
  eggs = {[0, 0] => true}
  
  for b0 in p0.each_byte
    d = b0 - CH_A
    x += DXYS[d][0]
    y += DXYS[d][1]
    eggs[[x, y]] = true
  end

  pts = eggs.keys

  for k in (0...6)
    pts.each do |x, y|
      ok = true
      for b1 in p1.each_byte
        d = (b1 - CH_A + k) % 6
        x += DXYS[d][0]
        y += DXYS[d][1]
        if eggs[[x, y]].nil?
          ok = false
          break
        end
      end
      return true if ok
    end
  end

  false
end

### main

n = gets.to_i

n.times do
  p0 = gets.strip
  p1 = gets.strip
  gets
  #p [p0, p1]

  puts same?(p0, p1) ? 'true' : 'false'
end