Help me in solving SHORTSPELL problem

Why is it showing runtime error???

My code


for i in range(int(input())):
    N=int(input())
    S=(input())
    s=list(S)
    final=[]
    
    for i in range(N):
       s.remove(s[i])
       final.append(s)
       s=list(S)
    t=(min(final))
    q="".join(t)
    print(q)
    
        
        

Problem Link: Spell Shortening Practice Coding Problem - CodeChef

@shahnoor_21
here plzz refer my c++ code for better understanding of the logic

#include <bits/stdc++.h>
using namespace std;

int main() {
	// your code goes here
	int t;
	cin>>t;
	while(t--)
	{
	    int n;
	    cin>>n;
	    string s;
	    cin>>s;
	    int ch=0;
	    string ans;
	    for(int i=1;i<n;i++)
	    {
	        if(s[i-1]>s[i]&&!ch)
	        {
	            ch=1;
	        }
	        else
	        ans+=s[i-1];
	    }
	    if(ch)
	    ans+=s[n-1];
	    cout<<ans<<endl;
	}

}