CodeEff/ECCO huggingface dataset:
# Original solution
from collections import deque

def pr(A,n):
    for i in range(n):
        if i!=n-1:
            print(A[i],end=" ")
        else:
            print(A[i])

n=int(input())
que_r=deque()
c=0

for i in range(n):
    s=input().split()

    if s[0]=="insert":
        que_r.appendleft(int(s[1]))
    elif s[0]=="delete" and que_r.count(int(s[1]))>=1:
        que_r.remove(int(s[1]))
    elif s[0]=="deleteFirst":
        gav=que_r.popleft()
    elif s[0]=="deleteLast":
        gav=que_r.pop()

pr(que_r,len(que_r))


# Optimized solution
from collections import deque

def pr(A,n):
    for i in range(n):
        if i!=n-1:
            print(A[i],end=" ")
        else:
            print(A[i])

n=int(input())
que_r=deque()

for i in range(n):
    s=input().split()

    if s[0]=="insert":
        que_r.appendleft(int(s[1]))
    elif s[0]=="delete" and que_r.count(int(s[1]))>=1:
        que_r.remove(int(s[1]))
    elif s[0]=="deleteFirst":
        gav=que_r.popleft()
    elif s[0]=="deleteLast":
        gav=que_r.pop()

pr(que_r,len(que_r))
# Original solution
class DLList:
    class Cell:
        def __init__(self, data, pre, nex):
            self.data = data
            self.pre = pre
            self.nex = nex
    
    def __init__(self):
        self.top = DLList.Cell(None, None, None)

    def insert(self, x):
        if self.top.nex == None:
            w = DLList.Cell(x, self.top, self.top)
            self.top.nex = w
            self.top.pre = w
        else:
            w = DLList.Cell(x, self.top, self.top.nex)
            self.top.nex.pre = w
            self.top.nex = w
            
    def delete(self, x):
        w = self.top.nex
        while w != self.top:
            if w.data == x:
                w.pre.nex = w.nex
                w.nex.pre = w.pre
                break
            w = w.nex
            
    def deleteFirst(self):
        w = self.top.nex
        w.pre.nex = w.nex
        w.nex.pre = w.pre
     
    def deleteLast(self):
        w = self.top.pre
        w.pre.nex = w.nex
        w.nex.pre = w.pre 
           
    def pri(self):
        w = self.top.nex
        while w != self.top:
            if w.nex == self.top:
                print(w.data)
                break
            else:
                print(w.data,end=" ")
            w = w.nex

a = DLList()
n = int(input())
for i in range(n):
    s = input().split(" ")
    if s[0] == "insert":
        a.insert(int(s[1]))
    elif s[0] == "delete":
        a.delete(int(s[1]))
    elif s[0] == "deleteLast":
        a.deleteLast()
    elif s[0] == "deleteFirst":
        a.deleteFirst()
a.pri()


# Optimized solution
class DLList:
    class Cell:
        def __init__(self, data, pre, nex):
            self.data = data
            self.pre = pre
            self.nex = nex
    
    def __init__(self):
        self.top = DLList.Cell(None,None,None)
        self.top.nex = self.top

    def insert(self, x):
        w = DLList.Cell(x, self.top, self.top.nex)
        self.top.nex.pre = w
        self.top.nex = w
            
    def delete(self, x):
        w = self.top.nex
        while w != self.top:
            if w.data == x:
                w.pre.nex = w.nex
                w.nex.pre = w.pre
                break
            w = w.nex
            
    def deleteFirst(self):
        w = self.top.nex
        w.pre.nex = w.nex
        w.nex.pre = w.pre
     
    def deleteLast(self):
        w = self.top.pre
        w.pre.nex = w.nex
        w.nex.pre = w.pre 
           
    def pri(self):
        w = self.top.nex
        while w != self.top:
            if w.nex == self.top:
                print(w.data)
                break
            else:
                print(w.data,end=" ")
            w = w.nex

a = DLList()
n = int(input())
for i in range(n):
    s = input().split(" ")
    if s[0] == "insert":
        a.insert(int(s[1]))
    elif s[0] == "delete":
        a.delete(int(s[1]))
    elif s[0] == "deleteLast":
        a.deleteLast()
    elif s[0] == "deleteFirst":
        a.deleteFirst()
a.pri()
# Original solution
from collections import deque

n = int( eval(input( )) )
que = deque( )
for i in range( n ):
	op = input( ).split( " " )
	if "insert" == op[0]:
		que.appendleft( op[1] )
	elif "delete" == op[0]:
		if op[1] in que:
			que.remove( op[1] )
	elif "deleteFirst" == op[0] :
		que.popleft( )
	elif "deleteLast" == op[0]:
		que.pop( )

print(( " ".join( que ) ))

# Optimized solution
import sys
from collections import deque

n = int( sys.stdin.readline( ) )
que = deque( )
lines = sys.stdin.readlines()
for line in lines:
	op = line.rstrip().split( " " )
	if "insert" == op[0]:
		que.appendleft( op[1] )
	elif "delete" == op[0]:
		if op[1] in que:
			que.remove( op[1] )
	elif "deleteFirst" == op[0] :
		que.popleft( )
	elif "deleteLast" == op[0]:
		que.pop( )


print(( " ".join( que ) ))
# Original solution
n = int(input())
commands = []
for a in range(n):
    raw = input().split()
    try:
        commands.append([raw[0], int(raw[1])])
    except:
        commands.append([raw[0], 'none'])

result = []
for a in commands:
    command, x = a[0], a[1]
    if command == 'insert':
        result.append(x)
    elif command == 'delete':
        if x in result:
            if result.count(x) == 1:
                result.remove(x)
            else:
                for i in range(len(result)-1, -1, -1):
                    if result[i] == x:
                        del result[i]
                        break
        else:
            continue
    elif command == 'deleteFirst':
        del result[-1]
    else:
        del result[0]

for i in range(len(result)-1, -1, -1):
    if i == 0:
        print(result[i])
    else:
        print(result[i], end=' ')


# Optimized solution
n = int(input())
result = []
for a in range(n):
    c = input().split()
    if c[0] == 'insert':
        result.append(int(c[1]))
    elif c[0] == 'delete':
        c[1] = int(c[1])
        if c[1] in result:
            if result.count(c[1]) == 1:
                result.remove(c[1])
            else:
                for i in range(len(result)-1, -1, -1):
                    if result[i] == c[1]:
                        del result[i]
                        break
        else:
            continue
    elif c[0] == 'deleteFirst':
        del result[-1]
    else:
        del result[0]

for i in range(len(result)-1, -1, -1):
    if i == 0:
        print(result[i])
    else:
        print(result[i], end=' ')
# Original solution
class Node:
    def __init__(self, key, prevNode, nextNode):
        self.key = key
        self.prevNode = prevNode
        self.nextNode = nextNode

def deleteNode(node):
    if node == fNode:
        return
    node.prevNode.nextNode = node.nextNode
    node.nextNode.prevNode = node.prevNode

def searchNode(key):
    global fNode
    node = fNode.nextNode
    while node != fNode and node.key != key:
        node = node.nextNode
    return node

def searchLast():
    global fNode
    node = fNode.nextNode
    while node != fNode:
        prevNode = node
        node = node.nextNode
    return prevNode

def nodeList():
    global fNode
    node = fNode.nextNode
    keys = []
    while node != fNode:
        keys.append(node.key)
        node = node.nextNode

    print((" ".join(keys)))

# ????????????????????????
fNode = Node(None, None, None)
fNode.prevNode = fNode
fNode.nextNode = fNode

n = int(eval(input()))

for i in range(0, n):
    inputs = input().split(' ')
    command = inputs.pop(0)
    if inputs:
        key = inputs.pop(0)

    if command == 'insert':
        insertNode = Node(key, fNode, fNode.nextNode)
        fNode.nextNode.prevNode = insertNode
        fNode.nextNode = insertNode
    if command == 'delete':
        deleteNode(searchNode(key))
    if command == 'deleteFirst':
        deleteNode(fNode.nextNode)
    if command == 'deleteLast':
        deleteNode(fNode.prevNode)
        #deleteNode(searchLast())
nodeList()

# Optimized solution
class Node:
    def __init__(self, key, prevNode, nextNode):
        self.key = key
        self.prevNode = prevNode
        self.nextNode = nextNode

def deleteNode(node):
    if node == fNode:
        return
    node.prevNode.nextNode = node.nextNode
    node.nextNode.prevNode = node.prevNode

def searchNode(key):
    global fNode
    node = fNode.nextNode
    while node != fNode and node.key != key:
        node = node.nextNode
    return node

'''
def searchLast():
    global fNode
    node = fNode.nextNode
    while node != fNode:
        prevNode = node
        node = node.nextNode
    return prevNode
'''

def nodeList():
    global fNode
    node = fNode.nextNode
    keys = []
    while node != fNode:
        keys.append(node.key)
        node = node.nextNode

    print((" ".join(keys)))

# ????????????????????????
fNode = Node(None, None, None)
fNode.prevNode = fNode
fNode.nextNode = fNode

n = int(eval(input()))

for i in range(0, n):
    inputs = input().split(' ')
    command = inputs[0]

    if command == 'insert':
        insertNode = Node(inputs[1], fNode, fNode.nextNode)
        fNode.nextNode.prevNode = insertNode
        fNode.nextNode = insertNode
    if command == 'delete':
        deleteNode(searchNode(inputs[1]))
    if command == 'deleteFirst':
        deleteNode(fNode.nextNode)
    if command == 'deleteLast':
        deleteNode(fNode.prevNode)
        #deleteNode(searchLast())
nodeList()
# Original solution
import sys
res = dict()
dll = [None] * 2000000
left = 0
right = 0
n = int(eval(input()))
for inpt in sys.stdin.read().splitlines():
    i = inpt.split()
    if i[0] == "insert":
        x = int(i[1])
        dll[left] = x
        if(x in res):
            res[x].append(left)
        else:
            res[x] = [left]
        left += 1
    if i[0] == "delete":
        x = int(i[1])
        if(x in res):
            ind = max(res[x])
            dll[ind] = None
            res[x].remove(ind)
            if(len(res[x]) == 0):
                del res[x]
            if(ind == (left - 1)):
                left = ind
            if(ind == right):
                right += 1
    if i[0] == "deleteFirst":
        left -= 1
        x = dll[left]
        res[x].remove(left)
        if(len(res[x]) == 0):
            del res[x]
        dll[left] = None
    if i[0] == "deleteLast":
        right += 1
    # print(dll[right:left])
ret = []
for x in dll[right:left]:
    if(x is not None):
        ret.append(str(x))
ret.reverse()
print((" ".join(ret)))

# Optimized solution
import sys
res = dict()
dll = [None] * 2000000
left = 0
right = 0
n = int(eval(input()))
for inpt in sys.stdin.read().splitlines():
    i = inpt.split()
    if i[0] == "insert":
        x = int(i[1])
        dll[left] = x
        if(x in res):
            res[x].add(left)
        else:
            res[x] = set([left])
        left += 1
    if i[0] == "delete":
        x = int(i[1])
        if(x in res):
            ind = max(res[x])
            dll[ind] = None
            res[x].remove(ind)
            if(len(res[x]) == 0):
                del res[x]
            if(ind == (left - 1)):
                left = ind
            if(ind == right):
                right += 1
    if i[0] == "deleteFirst":
        left -= 1
        x = dll[left]
        res[x].remove(left)
        if(len(res[x]) == 0):
            del res[x]
        dll[left] = None
    if i[0] == "deleteLast":
        right += 1
    # print(dll[right:left])
ret = []
for x in dll[right:left]:
    if(x is not None):
        ret.append(str(x))
ret.reverse()
print((" ".join(ret)))
# Original solution
# -*- coding: utf-8 -*-
from collections import deque

n = int(input())
key = deque()

for i in range(n):
    command = list(input().split())

    if command[0] == 'insert':
        key.insert(0, command[1])
    elif command[0] == 'delete' and command[1] in key:
        key.remove(command[1])
    elif command[0] == 'deleteFirst':
        del key[0]
    elif command[0] == 'deleteLast':
        del key[-1]

for i in range(len(key)):
    if i == len(key) - 1:
        print('{0}'.format(key[i]))
    else:
        print('{0}'.format(key[i]), end=' ')



# Optimized solution
# -*- coding: utf-8 -*-
from collections import deque

n = int(input())
key = deque()

for i in range(n):
    command = list(input().split())

    if command[0] == 'insert':
        key.insert(0, command[1])
    elif command[0] == 'delete' and command[1] in key:
        key.remove(command[1])
    elif command[0] == 'deleteFirst':
        key.popleft()
    elif command[0] == 'deleteLast':
        key.pop()

for i in range(len(key)):
    if i == len(key) - 1:
        print('{0}'.format(key[i]))
    else:
        print('{0}'.format(key[i]), end=' ')
# Original solution
# -*- coding: utf-8 -*-
from collections import deque

n = int(input())
key = deque()

for i in range(n):
    command = list(input().split())

    if command[0] == 'insert':
        key.insert(0, command[1])
    elif command[0] == 'delete' and command[1] in key:
        key.remove(command[1])
    elif command[0] == 'deleteFirst':
        key.popleft()
    elif command[0] == 'deleteLast':
        key.pop()

for i in range(len(key)):
    if i == len(key) - 1:
        print('{0}'.format(key[i]))
    else:
        print('{0}'.format(key[i]), end=' ')



# Optimized solution
# -*- coding: utf-8 -*-
from collections import deque

n = int(input())
key = deque()

for i in range(n):
    command = list(input().split())

    if command[0] == 'insert':
        key.appendleft(command[1])
    elif command[0] == 'delete':
        try:
            key.remove(command[1])
        except:
            pass
    elif command[0] == 'deleteFirst':
        key.popleft()
    elif command[0] == 'deleteLast':
        key.pop()

for i in range(len(key)):
    if i == len(key) - 1:
        print('{0}'.format(key[i]))
    else:
        print('{0}'.format(key[i]), end=' ')
# Original solution
n = int(eval(input()))
A = [list(map(str,input().split())) for _ in range(n)]
B = []

for i in range(n):
    if A[i][0] == 'insert':
        B.insert(0,int(A[i][1]))
    elif A[i][0] == 'delete':
        if int(A[i][1]) in B:
            B.remove(int(A[i][1]))
    elif A[i][0] == 'deleteFirst':
        del B[0]
    elif A[i][0] == 'deleteLast':
        del B[-1]
  

print((' '.join(map(str,B))))


# Optimized solution
n = int(eval(input()))
B = []

for i in range(n):
    A = list(map(str,input().split()))
    if A[0] == 'insert':
        B.insert(0,int(A[1]))
    elif A[0] == 'delete':
        if int(A[1]) in B:
            B.remove(int(A[1]))
    elif A[0] == 'deleteFirst':
        del B[0]
    elif A[0] == 'deleteLast':
        del B[-1]
  

print((' '.join(map(str,B))))
# Original solution
from collections import deque
def insert():
    a.appendleft(command[1])

def delete():
    try:
        a.remove(command[1])
    except ValueError:
        pass

def deleteFirst():
    a.popleft()

def deleteLast():
    a.pop()

n = int(input())
a = deque([])
for i in range(n):
    command = input().split()
    if command[0] == "insert":
        insert()
    elif command[0] == "delete":
        delete()
    elif command[0] == "deleteFirst":
        deleteFirst()
    else:
        deleteLast()

for i, e in enumerate(a):
    if i == len(a) - 1:
        print(e)
    else:
        print(e, end=' ')



# Optimized solution
from collections import deque
a = deque([])
for i in range(int(input())):
    c = input().split()
    if c[0] == "insert":
        a.appendleft(c[1])
    elif c[0] == "delete":
        try:
            a.remove(c[1])
        except ValueError:
            pass
    elif c[0] == "deleteFirst":
        a.popleft()
    else:
        a.pop()
for i,e in enumerate(a):
    if i == len(a) - 1:
        print(e)
    else:
        print(e, end=" ")
# Original solution
from collections import deque

class MyList(list):
    def __init__(self):
        self.__init__ = list

        self.d = {'deleteFirst':self.delF, 'deleteLast':self.delL, 'insert':self.insX, 'delete':self.delX}
    def cmd(self,command):
        if ' ' in command:
            ope, num = command.split()
            num = int(num)
            self.d[ope](num)
        else:
            self.d[command]()
            
    def delF(self):
        self.pop(0)

    def delL(self):
        self.pop(-1)

    def insX(self,num):
        self.insert(0,num)

    def delX(self,num):
        if num in self:
            self.remove(num)

if __name__ == '__main__' :
    l = MyList()
    n = eval(input())
    
    for i in range(n):
        l.cmd(input())

    q = deque(l)
    for i in range(len(l)-1):
        print(q.popleft(), end=' ')
    print(l[-1])

# Optimized solution
from collections import deque

class MyList(deque):
    def __init__(self):
        self.__init__ = deque
        self.d = {'deleteFirst':self.delF, 'deleteLast':self.delL, 'insert':self.insX, 'delete':self.delX}
    def cmd(self,command):
        if ' ' in command:
            ope, num = command.split()
            num = int(num)
            self.d[ope](num)
        else:
            self.d[command]()
            
    def delF(self):
        self.popleft()

    def delL(self):
        self.pop()

    def insX(self,num):
        self.appendleft(num)

    def delX(self,num):
        if num in self:
            self.remove(num)

if __name__ == '__main__' :
    l = MyList()
    n = eval(input())
    
    for i in range(n):
        l.cmd(input())

    q = deque(l)
    for i in range(len(l)-1):
        print(q.popleft(), end=' ')
    print(l[-1])
# Original solution
from collections import deque

n = int(input())
d = deque()
for _i in range(n):
    line = input().split()
    order = line[0]
    if order in ('insert', 'delete'):
        key = int(line[1])
    if order == 'insert':
        d.appendleft(key)
    elif order == 'delete':
        try:
            d.remove(key)
        except ValueError:
            pass
    elif order == 'deleteFirst':
        d.popleft()
    elif order == 'deleteLast':
        d.pop()
    else:
        raise ValueError('Invalid order: {order}')

i = 0
while True:
    try:
        if i == 0:
            print(d.popleft(), end='')
        else:
            print(f' {d.popleft()}', end='')
        i += 1
    except IndexError:
        break
print()


# Optimized solution
from collections import deque

n = int(eval(input()))
d = deque()
for _i in range(n):
    line = input().split()
    order = line[0]
    if order in ('insert', 'delete'):
        key = line[1]
    if order == 'insert':
        d.appendleft(key)
    elif order == 'delete':
        try:
            d.remove(key)
        except ValueError:
            pass
    elif order == 'deleteFirst':
        d.popleft()
    elif order == 'deleteLast':
        d.pop()
    else:
        raise ValueError('Invalid order: {order}')

print((' '.join(d)))
# Original solution
from collections import deque

n = int(eval(input()))
d = deque()
for _i in range(n):
    line = input().split()
    order = line[0]
    if order in ('insert', 'delete'):
        key = line[1]
    if order == 'insert':
        d.appendleft(key)
    elif order == 'delete':
        try:
            d.remove(key)
        except ValueError:
            pass
    elif order == 'deleteFirst':
        d.popleft()
    elif order == 'deleteLast':
        d.pop()
    else:
        raise ValueError('Invalid order: {order}')

print((' '.join(d)))



# Optimized solution
from collections import deque

n = int(eval(input()))
d = deque()
for _i in range(n):
    line = input().split()
    order = line[0]
    if order == 'deleteFirst':
        d.popleft()
    elif order == 'deleteLast':
        d.pop()
    else:
        key = line[1]
        if order == 'insert':
            d.appendleft(key)
        elif order == 'delete':
            try:
                d.remove(key)
            except ValueError:
                pass
        else:
            raise ValueError('Invalid order: {order}')

print((' '.join(d)))
# Original solution
from collections import deque

n = int(eval(input()))
output = deque()
for i in range(n):
    li = input().split(' ')
    if(li[0] == 'insert'):
        output.appendleft(int(li[1]))
    elif(li[0] == 'delete'):
        try:
            output.remove(int(li[1]))
        except:
            pass
    elif(li[0] == 'deleteFirst'):
        output.popleft()
    elif(li[0] == 'deleteLast'):
        output.pop()
str_l = [str(o) for o in output]
print((' '.join(str_l)))



# Optimized solution
from collections import deque
n = int(eval(input()))
output = deque()
for i in range(n):
    li = input().split(' ')
    if(li[0] == 'insert'):
        output.appendleft(li[1])
    elif(li[0] == 'deleteFirst'):
        output.popleft()
    elif(li[0] == 'deleteLast'):
        output.pop()
    elif(li[0] == 'delete'):
        try:
            output.remove(li[1])
        except:
            pass
print((' '.join(output)))
# Original solution
from collections import deque

def doubly_lined_list(n, A):
	Q = deque()

	for i in range(n):
		if A[i][0] == 'insert':
			Q.appendleft(A[i][1])
		elif A[i][0] == 'delete':
			try:
				Q.remove(A[i][1])
			except:
				pass
		elif A[i][0] == 'deleteFirst':
			Q.popleft()
		elif A[i][0] == 'deleteLast':
			Q.pop()

	print((' '.join(Q)))

if __name__ == '__main__':
	n = int(eval(input()))
	A = []

	for i in range(n):
		A.append(input().split())

	doubly_lined_list(n, A)

# Optimized solution
import sys
from collections import deque

def doubly_lined_list():
	n = int(eval(input()))
	Q = deque()

	for i in range(n):
		line = sys.stdin.readline()
		command = line.split()[0]

		if command == 'insert':
			Q.appendleft(line.split()[1])
		elif command == 'delete':
			try:
				Q.remove(line.split()[1])
			except:
				pass
		elif command == 'deleteFirst':
			Q.popleft()
		elif command == 'deleteLast':
			Q.pop()

	print((' '.join(Q)))

if __name__ == '__main__':
	doubly_lined_list()
# Original solution
#coding:utf-8
#1_3_C
from collections import deque
n = int(eval(input()))
ary = deque()
for i in range(n):
    cmd = input().split()
    if cmd[0] == "insert":
        ary.appendleft(cmd[1])
    elif cmd[0] == "delete":
        try:
            ary.remove(cmd[1])
        except ValueError:
            pass
    elif cmd[0] == "deleteFirst":
        ary.popleft()
    elif cmd[0] == "deleteLast":
        ary.pop()

print((" ".join(ary)))

# Optimized solution
#coding:utf-8
#1_3_C
from collections import deque
n = int(eval(input()))
q = deque()
for i in range(n):
    cmd = input().split()
    if cmd[0] == "insert":
        q.appendleft(cmd[1])
    elif cmd[0] == "delete":
        try:
            q.remove(cmd[1])
        except ValueError:
            pass
    elif cmd[0] == "deleteFirst":
        q.popleft()
    elif cmd[0] == "deleteLast":
        q.pop()

print((" ".join(q)))
# Original solution
# 2019-11-23 01:28:44(JST)
import sys
from string import ascii_lowercase as alphabet


def main():
    n, s, k = sys.stdin.read().split()
    n, k = list(map(int, [n, k]))

    c = s[k-1]
    for l in alphabet:
        if l != c:
            s = s.replace(l, '*')
    
    print(s)
    

if __name__ == '__main__':
    main()


# Optimized solution
# 2019-11-23 01:28:44(JST)
import sys

def main():
    n, s, k = sys.stdin.read().split()
    n, k = list(map(int, [n, k]))

    c = s[k-1]
    letters = set(s) - set(c)
    for l in letters:
        s = s.replace(l, '*')
    
    print(s)
    

if __name__ == '__main__':
    main()