string-query-22
Source: hackerearth
Difficulty: MEDIUM

Given a string s and m queries. For each query delete the K-th occurence of a character x.

Input:
The first line contains the string s followed by an integer m.
The string consists of lowercase letters.
After that m lines follow each line containing the integer K and the character x.

Output:
Print the string after all the m queries.

Constraints:
1 ≤ string length ≤2*10^5
1 ≤ m ≤ 40000

Note: 
It is guaranteed that the operations are correct, that is , the letter to be deleted always exists and the string is never empty.

SAMPLE INPUT
abcdbcaab
5
2 a
1 c
1 d
3 b
2 a

SAMPLE OUTPUT
abbc

Explanation

After query 1: 
abcdbcab

After query 2:
abdbcab

After query 3:
abbcab

After query 4:
abbca 

After query 5:
abbc


q_string = input()

word_list = list(q_string)

word_dict = {}
word_set = set(q_string)


for i in word_set:
	position_list = []
	for j in range(len(word_list)):
		if i == word_list[j]:
			position_list.append(j)
	word_dict[i] = position_list


num_queries = input()


for i in range(int(num_queries)):
	data = input()
	data = data.split()
	index = word_dict[data[1]][(int(data[0])-1)]
	del(word_dict[data[1]][(int(data[0])-1)])
	word_list[index] = -1

result = [x for x in word_list if x != -1]
print(''.join(result))


asc=[]
for i in range(0,124):
	asc.append(0)
#print asc
mp=[[0 for i in range(1)] for i in range(124)]
#print mp
st=input()
st=list(st)
l=len(st)
for i in range(0,l):
	#c=str[i]
	aval=ord(st[i])
	asc[aval]+=1
	mp[aval].append(i)
q=eval(input())
for j in range(0,q):
	s=input()
	s=s.split(' ')
	k=int(s[0])
	ch=s[1]
	aval=ord(ch)
	ind=mp[aval][k]
	st[ind]='*'
	del(mp[aval][k])
	#print st
ans=''
for each in st:
	if each !='*':
		ans=ans+each
print(ans)
	
	
	
	



s=input()
a=[[] for i in range(26)]
l=len(s)
for i in range(l):
	a[ord(s[i])-ord('a')].append(i)
ct=[0]*l
g=[0]*l
n=int(input())
for i in range(n):
	p,c=input().split()
	p=int(p)
	g[a[ord(c)-ord('a')][p-1]]=1
	a[ord(c)-ord('a')].pop(p-1)
t=''
for i in range(l):
	if not g[i]:
		t+=s[i]
print(t)


def getInput():
	return input().rstrip('\n').rstrip('\r').rstrip('\n\r').rstrip('\r\n')

s = list(getInput())
m = int(getInput())
qs = []
for i in range(m):
	qs.append(getInput().split(' '))

# s =list("abcdbcaab")

# m = 5
# qs =[
# 	['2', 'a' ],
# 	['1', 'c' ],
# 	['1', 'd' ],
# 	['3', 'b' ],
# 	['2', 'a' ]
# ]

d = {}

for ix in range(len(s)):
	c = s[ix]
	if d.get(c) is None:
		d[c] = list()
	d[c].append(ix)

for i in range(m):
	query = qs[i]
	c = query[1] # char
	occ = int(query[0]) # which occurence of char 'c'
	sidx = d[c].pop(occ-1) # id of char 'c' in string 's'
	s[sidx] = '-'

finalStr = ''

for c in s:
	if c != '-':
		finalStr += c

print(finalStr)


def main():
	string = input()
	frequency = {'a':[], 'b':[], 'c':[], 'd':[], 'e':[], 'f':[], 'g':[], 'h':[], 'i':[], 'j':[], 'k':[], 'l':[], 'm':[], 'n':[], 'o':[], 'p':[], 'q':[], 'r':[], 's':[], 't':[], 'u':[], 'v':[], 'w':[], 'x':[], 'y':[], 'z':[] }
	
	for i in range(len(string)):
		frequency[string[i]].append(i)
	
	for j in range(eval(input())):
		a, b = input().split()
		del(frequency[b][int(a) - 1])
	
	list1 = ['*']*len(string)
	for key, values in frequency.items():
		for value in values:
			list1[value] = key
			
	list2 = []
	for char in list1:
		if char != "*":
			list2.append(char) 
	
	print("".join(map(str, list2)))
	
	return 0

if __name__ == "__main__":
	main()
	
	


s=input()
a=[[] for i in range(26)]
l=len(s)
for i in range(l):
	a[ord(s[i])-ord('a')].append(i)
ct=[0]*l
g=[0]*l
n=int(input())
for i in range(n):
	p,c=input().split()
	p=int(p)
	g[a[ord(c)-ord('a')][p-1]]=1
	a[ord(c)-ord('a')].pop(p-1)
t=''
for i in range(l):
	if not g[i]:
		t+=s[i]
print(t)