Let N be a positive integer. The number N has three digits when expressed in base 7. When the number N is expressed in base 18, it has the same three digits, in reverse order. What is N? (Express your answer in decimal.)