Don't repeat yourself in Rock-Paper-Scissors Upon the rumor that Codegolf will have a Rock-Paper-Scissors tournament you look into the topic of square-free words. A word made of the letters R, P, S is square-free if it does not contain a sequence that repeats twice. That is to say, the word can not be written as

a x x b


where a and b are words of any length and x is a word of length at least one, all made of the letters R, P, S.

Task

Write a program that generates the square-free words of the letters R, P, S of length n where the number 1 &lt;= n &lt;= 10 is taken as input. 

Example

For example the square-free words of length 3 are

RPR, RSR, RPS, RSP, SPS, SRS, SRP, SPR, PRP, PSP, PSR, PRS

and those of length 4 are

RPRS, RPSR, RPSP, RSRP, RSPR, RSPS, PRPS, PRSR, PRSP, PSRP, PSRS, PSPR, SRPR, SRPS, SRSP, SPRP, SPRS, SPSR

and note that for example SPSP or PRPR are not square-free

Rules


This is codegolf, shortest program wins, standard loopholes are closed.
You may print the words or create them in memory. 
Your program may be written as a function.


References

Wikipedia entry on square-free words

The number of square-free ternary words of given length are
in https://oeis.org/A006156 

Related: Arbitrary-Length Ternary Squarefree Words
Ruby, 39 bytes

-&gt;n{(?P*n..?S*n).grep_v /[^RPS]|(.+)\1/}


This hilariously inefficient function generates all strings of length N that lie alphabetically between N Ps and N Ss, then filters out the vast majority that contain non-RPS characters. The actual squarefree check just uses a Regexp backreference: (.+)\1.

More idiomatic 65 bytes that finish in a reasonable amount of time for N=10:

-&gt;n{%w[R P S].repeated_permutation(n).map(&amp;:join).grep_v /(.+)\1/}


Edit: Saved a byte thanks to G B.