Today Sonya learned about long integers and invited all her friends to share the fun. Sonya has an initially empty multiset with integers. Friends give her t queries, each of one of the following type:

  1. +  ai — add non-negative integer ai to the multiset. Note, that she has a multiset, thus there may be many occurrences of the same integer. 
  2. -  ai — delete a single occurrence of non-negative integer ai from the multiset. It's guaranteed, that there is at least one ai in the multiset. 
  3. ? s — count the number of integers in the multiset (with repetitions) that match some pattern s consisting of 0 and 1. In the pattern, 0 stands for the even digits, while 1 stands for the odd. Integer x matches the pattern s, if the parity of the i-th from the right digit in decimal notation matches the i-th from the right digit of the pattern. If the pattern is shorter than this integer, it's supplemented with 0-s from the left. Similarly, if the integer is shorter than the pattern its decimal notation is supplemented with the 0-s from the left. 



For example, if the pattern is s = 010, than integers 92, 2212, 50 and 414 match the pattern, while integers 3, 110, 25 and 1030 do not.

Input

The first line of the input contains an integer t (1 ≤ t ≤ 100 000) — the number of operation Sonya has to perform.

Next t lines provide the descriptions of the queries in order they appear in the input file. The i-th row starts with a character ci — the type of the corresponding operation. If ci is equal to '+' or '-' then it's followed by a space and an integer ai (0 ≤ ai < 1018) given without leading zeroes (unless it's 0). If ci equals '?' then it's followed by a space and a sequence of zeroes and onse, giving the pattern of length no more than 18.

It's guaranteed that there will be at least one query of type '?'.

It's guaranteed that any time some integer is removed from the multiset, there will be at least one occurrence of this integer in it.

Output

For each query of the third type print the number of integers matching the given pattern. Each integer is counted as many times, as it appears in the multiset at this moment of time.

Examples

Input

12
+ 1
+ 241
? 1
+ 361
- 241
? 0101
+ 101
? 101
- 101
? 101
+ 4000
? 0


Output

2
1
2
1
1


Input

4
+ 200
+ 200
- 200
? 0


Output

1

Note

Consider the integers matching the patterns from the queries of the third type. Queries are numbered in the order they appear in the input. 

  1. 1 and 241. 
  2. 361. 
  3. 101 and 361. 
  4. 361. 
  5. 4000.

Difficulty: MEDIUM

Solutions:
from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(str, input().split())

def li():
	return list(mi())

def read():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
mod = 1000000007
import math

def main():
	t = ii()
	di = {}
	for _ in range(t):
		(c, a) = mi()
		s = ''
		for i in range(len(a)):
			s += str(int(a[i]) % 2)
		d = 18 - len(a)
		s = d * '0' + s
		if c == '+':
			if s in di:
				di[s] += 1
			else:
				di[s] = 1
		elif c == '-':
			di[s] -= 1
		else:
			d = 18 - len(a)
			a = d * '0' + a
			if a in di:
				print(di[a])
			else:
				print(0)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


from collections import defaultdict
from sys import stdin
from sys import stdout

def main():
	n = int(stdin.readline())
	d = defaultdict(int)
	for i in range(n):
		(s, x) = stdin.readline().split()
		y = ''.join(['1' if c in ['1', '3', '5', '7', '9'] else '0' for c in x]).zfill(18)
		if s == '+':
			d[y] += 1
		elif s == '-':
			d[y] -= 1
		else:
			stdout.write(str(d[y]) + '\n')
main()


n = int(input())
ans = [0] * 2 ** 18
trantab = str.maketrans('0123456789', '0101010101')
for i in range(n):
	(ch, s) = map(str, input().split())
	if ch == '+':
		ans[int(s.translate(trantab), 2)] += 1
	elif ch == '-':
		ans[int(s.translate(trantab), 2)] -= 1
	else:
		print(ans[int(s.translate(trantab), 2)])


import sys
import re

def mask2(s):
	m = int('0', 2)
	while len(s) > 0:
		m *= 2
		m += int(s[0]) % 2
		s = s[1:]
	return m

def mask(s):
	return int(re.sub('[02468]', '0', re.sub('[13579]', '1', s)), 2)

def solve():
	d = dict()
	n = int(sys.stdin.readline().strip())
	ans = ''
	for line in sys.stdin:
		(op, i) = line.strip().split(' ')
		m = mask(i)
		if op == '+':
			d.setdefault(m, 0)
			d[m] += 1
		if op == '-':
			d[m] -= 1
		if op == '?':
			ans += '{:d}\n'.format(d.get(m, 0))
	return ans
ans = solve()
print(ans)


from __future__ import division, print_function
import sys
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
import os, sys, bisect, copy
from collections import defaultdict, Counter, deque
if os.path.exists('in.txt'):
	sys.stdin = open('in.txt', 'r')
if os.path.exists('out.txt'):
	sys.stdout = open('out.txt', 'w')

def input():
	return sys.stdin.readline()

def mapi(arg=0):
	return map(int if arg == 0 else str, input().split())
mp = defaultdict(int)

def key(x):
	res = 0
	for i in range(len(x)):
		res = 2 * res + int(x[i]) % 2
	return res
for _ in range(int(input())):
	a = input().strip().split()
	if a[0] == '+':
		mp[key(a[1])] += 1
	elif a[0] == '-':
		mp[key(a[1])] -= 1
		pass
	else:
		print(mp[key(a[1])])


import sys
from collections import Counter
from sys import stdin
input()
c = [0] * 2 ** 18
deg = [0] * 18
for i in range(18):
	deg[i] = 2 ** i
t = str.maketrans('0123456789', '0101010101')
for (ch, n) in map(str.split, stdin):
	if ch == '?':
		print(c[int(n, 2)])
	n = n.translate(t)
	if ch == '+':
		c[int(n, 2)] += 1
	if ch == '-':
		c[int(n, 2)] -= 1


num = int(input())
multiset = [0] * 2 ** 18
t = str.maketrans('0123456789', '0101010101')
while num:
	opr = input().split()
	if opr[0] == '+':
		multiset[int(opr[1].translate(t), 2)] += 1
	elif opr[0] == '-':
		multiset[int(opr[1].translate(t), 2)] -= 1
	elif opr[0] == '?':
		print(multiset[int(opr[1], 2)])
	num -= 1


t = int(input())
dc = [0] * 2 ** 19
tt = str.maketrans('0123456789', '0101010101')
for i in range(0, t):
	st = input().split()
	if st[0] == '+':
		dc[int(st[1].translate(tt), 2)] += 1
	elif st[0] == '-':
		dc[int(st[1].translate(tt), 2)] -= 1
	else:
		mu = int(st[1], 2)
		print(dc[mu])


t = int(input())
ans = [0] * 2 ** 18
y = str.maketrans('0123456789', '0101010101')
for i in range(t):
	(x, s) = map(str, input().split())
	if x == '+':
		ans[int(s.translate(y), 2)] += 1
	elif x == '-':
		ans[int(s.translate(y), 2)] -= 1
	else:
		print(ans[int(s.translate(y), 2)])


from sys import stdin, stdout
quests = int(stdin.readline().rstrip())
multi_set = {}
p = str.maketrans('0123456789', '0101010101')
for i in range(quests):
	(quest, core) = stdin.readline().rstrip().split()
	pattern = int(core.translate(p))
	if quest == '+':
		if pattern in multi_set.keys():
			multi_set[pattern] += 1
		else:
			multi_set[pattern] = 1
	elif quest == '-':
		multi_set[pattern] -= 1
	elif pattern in multi_set:
		stdout.write(str(multi_set[pattern]) + '\n')
	else:
		stdout.write('0\n')


present = {}
coded = {}
cc = {}

def encode(s):
	a = ''
	for i in range(len(s)):
		if int(s[i]) % 2 == 0:
			a += '0'
		else:
			a += '1'
	x = ''
	for i in range(18 - len(a)):
		x += '0'
	x += a
	return x

def add(num):
	present[num] = present.get(num, 0) + 1
	x = encode(num)
	cc[num] = x
	coded[x] = coded.get(x, 0) + 1

def delete(num):
	present[num] -= 1
	coded[cc[num]] -= 1

def query(patt):
	x = ''
	for i in range(18 - len(patt)):
		x += '0'
	x = x + patt
	if x in coded:
		print(coded[x])
	else:
		print(0)
t = int(input())
for q in range(t):
	(ty, i) = input().split()
	if ty == '+':
		add(i)
	if ty == '-':
		delete(i)
	if ty == '?':
		query(i)


import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcdefghijklmnopqrstuvwxyz'
M = 10 ** 9 + 7
EPS = 1e-06

def Ceil(a, b):
	return a // b + int(a % b > 0)

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]

def getID(n):
	n = int(n)
	s = []
	for i in range(18):
		here = n % 10
		n //= 10
		s.append(str(here % 2))
	return ''.join(s)[::-1]
have = defaultdict(int)
for _ in range(Int()):
	(t, n) = input().split()
	if t == '+':
		have[getID(n)] += 1
	elif t == '-':
		have[getID(n)] -= 1
	else:
		n = '0' * (18 - len(n)) + n
		print(have[n])


t = int(input())
trantab = str.maketrans('0123456789', '0101010101')
a = {}
for i in range(t):
	string = input()
	(oper, number) = string.split()
	pattern = int(number.translate(trantab))
	if oper == '+':
		a[pattern] = a.get(pattern, 0) + 1
	elif oper == '-':
		a[pattern] -= 1
		if not a[pattern]:
			del a[pattern]
	elif pattern in a:
		print(a[pattern])
	else:
		print(0)


from sys import stdin
input()
cnt = [0] * 2 ** 18
t = str.maketrans('0123456789', '0101010101')
for (ch, s) in map(str.split, stdin):
	if ch == '?':
		print(cnt[int(s, 2)])
	else:
		cnt[int(s.translate(t), 2)] += 1 if ch == '+' else -1


import sys
import math
import collections
import heapq
input = sys.stdin.readline
d = {}
t = int(input())
for w in range(t):
	(x, y) = (i for i in input().split())
	y = list(y)
	k = len(y)
	for i in range(k):
		if int(y[i]) % 2 == 0:
			y[i] = '0'
		else:
			y[i] = '1'
	y = ''.join(y)
	if k < 30:
		y = '0' * (30 - k) + y
	if x == '+':
		if y in d:
			d[y] += 1
		else:
			d[y] = 1
	elif x == '-':
		d[y] -= 1
	elif y in d:
		print(d[y])
	else:
		print(0)