Help me in solving NOPAL problem

My issue

I am initially trying to find two different characters and then concatenating them with a string. Then for the rest of the characters, I am finding such substrings of length three with three different consecutive characters. This way we can ensure that there are no palindromic substrings in the string. But my code is failing a hidden testcase? Kindly help me in solving the problem.

My code

import random
import string
t = int(input())
for _ in range(t):
    n = int(input())
    ch1 = random.choice(string.ascii_lowercase) 
    ch2 = random.choice(string.ascii_lowercase)
    while(ch1==ch2):
        ch1 = random.choice(string.ascii_lowercase) 
    st = ch1 + ch2
    for i in range(2,n):
        ch = random.choice(string.ascii_lowercase)
        while(ch in st[i-2:i]):
            ch = random.choice(string.ascii_lowercase)
        st = st + ch
    print(st)

Problem Link: Palindromes Not Allowed Practice Coding Problem - CodeChef

@mancomike
logic is just print abcabcabc… and so till n length.
refer my c++ code for better understanding .

#include <iostream>
using namespace std;

int main() {
	// your code goes here
	int t;
	cin>>t;
	while(t--)
	{
	    int n;
	    cin>>n;
	    int q=n/3;
	    int r=n%3;
	    while(q--)
	    {
	        cout<<"abc";
	    }
	    if(r==1)
	    cout<<"a";
	    else if(r==2)
	    {
	    cout<<"ab";
	    }
	    cout<<endl;
	}
	return 0;
}