class SuffixTree:
    def__init__(self,s):
        self.s = s
        self.n = len(s)
        self.tree = {}
        self.count = [0]*self.n
        self.ans = [0]*self.n
    def insert(self,i,node,j):
        if self.s[i] not in
    self.tree[node]:
        self.tree[node][self.s[i]=
                        {}
                        node = self.treeInode
                        [self.s[i]]
                        self.count[j]+=1
                        if i+1<self.n:
                        self.insert(i+1,nod,j)
                        def quety(self,i,node):
                        result = 0
                        for char,child in
                        self.tree[node].items():
                        if char < self.s[i]:
                           result +=self.count[i]
                        elif char == self.s[i]
                        result +=self.query(i+1, child)
                          return result
                        s = "anatoly"
                        queries = [(5,'0'),(3,'b'),(7,'x')
                                   suffix_tree = SuffixTree(s)
                                   D = [s]
                                   for k, cin queries
                                     k-=1
                                   S=S[:k]+C*(len(S)-k)
                                   D.append(S)
                                   suffix.tree.insert(0,'',len(D)
                                                      count-suffix-tree.query(0,'')
                                                      print(count)
