Palo Alto is an unusual city because it is an endless coordinate line. It is also known for the office of Lyft Level 5.

Lyft has become so popular so that it is now used by all $m$ taxi drivers in the city, who every day transport the rest of the city residents — $n$ riders.

Each resident (including taxi drivers) of Palo-Alto lives in its unique location (there is no such pair of residents that their coordinates are the same).

The Lyft system is very clever: when a rider calls a taxi, his call does not go to all taxi drivers, but only to the one that is the closest to that person. If there are multiple ones with the same distance, then to taxi driver with a smaller coordinate is selected.

But one morning the taxi drivers wondered: how many riders are there that would call the given taxi driver if they were the first to order a taxi on that day? In other words, you need to find for each taxi driver $i$ the number $a_{i}$ — the number of riders that would call the $i$-th taxi driver when all drivers and riders are at their home?

The taxi driver can neither transport himself nor other taxi drivers.


-----Input-----

The first line contains two integers $n$ and $m$ ($1 \le n,m \le 10^5$) — number of riders and taxi drivers.

The second line contains $n + m$ integers $x_1, x_2, \ldots, x_{n+m}$ ($1 \le x_1 < x_2 < \ldots < x_{n+m} \le 10^9$), where $x_i$ is the coordinate where the $i$-th resident lives. 

The third line contains $n + m$ integers $t_1, t_2, \ldots, t_{n+m}$ ($0 \le t_i \le 1$). If $t_i = 1$, then the $i$-th resident is a taxi driver, otherwise $t_i = 0$.

It is guaranteed that the number of $i$ such that $t_i = 1$ is equal to $m$.


-----Output-----

Print $m$ integers $a_1, a_2, \ldots, a_{m}$, where $a_i$ is the answer for the $i$-th taxi driver. The taxi driver has the number $i$ if among all the taxi drivers he lives in the $i$-th smallest coordinate (see examples for better understanding).


-----Examples-----
Input
3 1
1 2 3 10
0 0 1 0

Output
3 
Input
3 2
2 3 4 5 6
1 0 0 0 1

Output
2 1 
Input
1 4
2 4 6 10 15
1 1 1 1 0

Output
0 0 0 1 


-----Note-----

In the first example, we have only one taxi driver, which means an order from any of $n$ riders will go to him.

In the second example, the first taxi driver lives at the point with the coordinate $2$, and the second one lives at the point with the coordinate $6$. Obviously, the nearest taxi driver to the rider who lives on the $3$ coordinate is the first one, and to the rider who lives on the coordinate $5$ is the second one. The rider who lives on the $4$ coordinate has the same distance to the first and the second taxi drivers, but since the first taxi driver has a smaller coordinate, the call from this rider will go to the first taxi driver.

In the third example, we have one rider and the taxi driver nearest to him is the fourth one.

Difficulty: EASY
Tags: Sorting

Implementation
Skill types: Sorting
Expected Time Complexity: O(N)

Starter code:

Solutions:
(n, m) = map(int, input().split())
x = list(map(int, input().split()))
t = list(map(int, input().split()))
ans = [0 for i in range(m)]
tax = []
for i in range(n + m):
	if t[i] == 1:
		tax.append(x[i])
j = 0
for i in range(n + m):
	if t[i] == 0:
		while j < m - 1 and abs(x[i] - tax[j]) > abs(x[i] - tax[j + 1]):
			j += 1
		ans[j] += 1
print(' '.join(list(map(str, ans))))
exit(0)
i = 0
c = 0
while t[i] == 0:
	c += 1
	i += 1
ans[i] = c
lt = i
i += 1
while i < n + m:
	c = 0
	while i < n + m and t[i] == 0:
		c += 1
		i += 1
	if i < n + m:
		ans[lt] += c // 2 + c % 2
		ans[i] += c // 2
	else:
		ans[lt] += c
	lt = i
	i += 1
for i in range(n + m):
	if t[i] == 1:
		print(ans[i], end=' ')
print()


(n, m) = map(int, input().split())
q = list(map(int, input().split()))
k = list(map(int, input().split()))
if m == 1:
	print(n)
else:
	x = []
	for i in range(n + m):
		if k[i] == 1:
			x.append(i)
	l = [0] * m
	i = 0
	while i < m:
		if i == 0:
			l[i] += x[i]
		if i == m - 1:
			l[i] += m + n - 1 - x[i]
			i += 1
			continue
		a = q[x[i]]
		b = q[x[i + 1]]
		x1 = x[i] + 1
		y1 = x[i + 1]
		for j in range(x1, y1):
			d = q[j]
			if d - a <= b - d:
				l[i] += 1
			else:
				l[i + 1] += 1
		i += 1
	for i in l:
		print(i, end=' ')


(n, m) = map(int, input().split())
dist = list(map(int, input().split()))
taxists = list(map(int, input().split()))
left = [0] * (n + m)
right = [0] * (n + m)
MAX = 10000000000000000000
value = -MAX
cnt = 0
for i in range(n + m):
	if taxists[i] == 1:
		cnt += 1
		value = i
	left[i] = value
value = MAX
for i in range(n + m - 1, -1, -1):
	if taxists[i] == 1:
		value = i
	right[i] = value
answer = [0] * (n + m)
for i in range(n + m):
	if left[i] == -MAX:
		answer[right[i]] += 1
		continue
	if right[i] == MAX:
		answer[left[i]] += 1
		continue
	if abs(dist[left[i]] - dist[i]) <= abs(dist[i] - dist[right[i]]):
		answer[left[i]] += 1
	else:
		answer[right[i]] += 1
for i in answer:
	if i:
		print(i - 1, end=' ')


def print_answer(ans):
	import sys
	sys.stdout.write(' '.join([str(x) for x in ans]))
(n, m) = [int(x) for x in input().strip().split(' ')]
people = [int(x) for x in input().strip().split(' ')]
is_taxist = [int(x) > 0 for x in input().strip().split(' ')]
result = []
buf = []
prev_tax = None
for i in range(n + m):
	if not is_taxist[i]:
		buf.append(people[i])
		continue
	if prev_tax is None:
		result.append(len(buf))
	else:
		split_val = (people[i] - prev_tax) / 2 + prev_tax
		for j in range(len(buf)):
			if buf[j] <= split_val:
				result[-1] += 1
			else:
				result.append(len(buf) - j)
				break
		else:
			result.append(0)
	prev_tax = people[i]
	buf = []
result[-1] += len(buf)
print_answer(result)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
sta = list(map(int, input().split()))
taxi = []
ans = [0 for i in range(m)]
for i in range(n + m):
	if sta[i] == 1:
		taxi.append(a[i])
for i in range(n + m):
	if sta[i] == 0:
		l = 0
		r = m - 1
		tmp = -1
		while r >= l:
			mid = (l + r) // 2
			if taxi[mid] >= a[i]:
				r = mid - 1
				tmp = mid
			else:
				l = mid + 1
		if tmp == -1:
			ans[m - 1] += 1
		if tmp == 0:
			ans[0] += 1
		if tmp > 0:
			if a[i] - taxi[tmp - 1] <= taxi[tmp] - a[i]:
				ans[tmp - 1] += 1
			else:
				ans[tmp] += 1
for i in range(m):
	print(ans[i], end=' ')


from bisect import bisect_left
from math import inf
I = lambda : map(int, input().split())
(_, m) = I()
XT = list(zip(I(), I()))
T = [-inf] + [x for (x, t) in XT if t] + [inf]
C = [0] * m
for (x, t) in XT:
	if t < 1:
		i = bisect_left(T, x) - 1
		C[i - (abs(T[i] - x) <= abs(T[i + 1] - x))] += 1
print(*C)


from collections import Counter
(n, m) = list(map(int, input().split()))
x = list(map(int, input().split()))
t = list(map(int, input().split()))
a = [0] * (n + m)
l = t.index(1)
r = n + m - 1 - t[::-1].index(1)
for i in range(n + m - 1, r - 1, -1):
	a[i] = r
for i in range(l + 1):
	a[i] = l
prevl = l
for i in range(l + 1, r):
	if t[i] == 0:
		a[i] = prevl
	else:
		a[i] = i
		prevl = i
prevr = r
for i in range(r - 1, l, -1):
	if t[i] == 0:
		if x[prevr] - x[i] < x[i] - x[a[i]]:
			a[i] = prevr
	else:
		prevr = i
out = Counter([a[i] for i in range(n + m) if t[i] == 0])
d = [i for i in range(n + m) if t[i] == 1]
output = []
for i in d:
	if i in out:
		output.append(out[i])
	else:
		output.append(0)
print(*output)


import sys
from math import *

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())
(n, m) = mints()
a = list(mints())
b = list(mints())
l = [None] * (n + m)
r = [None] * (n + m)
c = [0] * (n + m)
x = None
for i in range(len(a)):
	l[i] = x
	if b[i] == 1:
		x = i
x = None
for i in range(len(a) - 1, -1, -1):
	r[i] = x
	if b[i] == 1:
		x = i
for i in range(len(a)):
	if b[i] == 0:
		aa = a[i]
		ll = l[i]
		rr = r[i]
		if ll == None:
			if rr != None:
				c[rr] += 1
		elif rr == None:
			c[ll] += 1
		elif aa - a[ll] <= a[rr] - aa:
			c[ll] += 1
		else:
			c[rr] += 1
for i in range(len(a)):
	if b[i] == 1:
		print(c[i], end=' ')


(n, m) = map(int, input().split(' '))
distances = list(map(int, input().split(' ')))
taxiDriver = list(map(int, input().split(' ')))
people = []
drivers = []
result = [0] * m
for i in range(len(distances)):
	if taxiDriver[i]:
		drivers.append(distances[i])
	else:
		people.append(distances[i])
j = 0
for person in people:
	if j + 1 < len(drivers):
		while j + 1 < len(drivers) and drivers[j] - person < person - drivers[j + 1]:
			j += 1
		result[j] += 1
	else:
		result[j] += 1
print(' '.join(map(str, result)))


import sys
(n, m) = list(map(lambda x: int(x), sys.stdin.readline().split(' ')))
s = list(map(lambda x: int(x), sys.stdin.readline().split(' ')))
t = list(map(lambda x: int(x), sys.stdin.readline().split(' ')))
r = []
t1 = None
for (i, taxi) in enumerate(t, start=0):
	if t[i] == 1:
		if not t1:
			t1 = s[i]
		else:
			r.append((t1 + s[i]) / 2)
			t1 = s[i]
ct = []
rc = 0
c = 0
for (i, sit) in enumerate(s, start=0):
	if rc == len(r):
		c += 1
	else:
		if s[i] > r[rc]:
			ct.append(c - 1)
			c = 0
			rc += 1
		if rc == len(r):
			c += 1
		elif s[i] <= r[rc]:
			c += 1
ct.append(c - 1)
print(' '.join((str(c) for c in ct)))


(n, m) = map(int, input().split(' '))
cds = list(map(int, input().split(' ')))
istaxi = list(map(int, input().split(' ')))
l = n + m
r = [0] * m
s = 0
while not istaxi[s]:
	s += 1
r[0] = s
e = l - 1
while not istaxi[e]:
	e -= 1
r[-1] += l - e - 1
lt = s
l = []
p = 0
for i in range(s + 1, e + 1):
	if istaxi[i] == 0:
		l += [2 * cds[i] - cds[lt]]
	if istaxi[i] == 1:
		for j in l:
			if j <= cds[i]:
				r[p] += 1
			else:
				r[p + 1] += 1
		lt = i
		p += 1
		l = []
print(' '.join(map(str, r)))


(n, m) = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
t = [int(i) for i in input().split()]
ti = [k for k in range(n + m) if t[k] == 1]
pi = [k for k in range(n + m) if t[k] == 0]
tc = [0] * (m + n)
tc[ti[0]] += ti[0]
tc[ti[m - 1]] += m + n - 1 - ti[m - 1]
for i in range(m - 1):
	ti1 = ti[i]
	ti2 = ti[i + 1]
	tx1 = x[ti[i]]
	tx2 = x[ti[i + 1]]
	for k in range(ti1 + 1, ti2):
		if x[k] - tx1 <= tx2 - x[k]:
			tc[ti[i]] += 1
		else:
			tc[ti[i + 1]] += 1
print(*[tc[k] for k in range(n + m) if t[k] == 1])


(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))
s = list(map(int, input().split()))
d = [0] * m
f = []
for q in range(len(s)):
	if s[q] == 1:
		f.append(a[q])
(q2, q1) = (-float('inf'), f[0])
(q3, q4) = (-1, 0)
for q in range(len(a)):
	if s[q] == 1:
		(q2, q1) = (a[q], f[q4 + 1] if len(f) > q4 + 1 else float('inf'))
		(q3, q4) = (q3 + 1, q4 + 1)
	elif q2 == -float('inf'):
		d[q4] += 1
	elif q1 == float('inf'):
		d[q3] += 1
	elif a[q] - q2 <= q1 - a[q]:
		d[q3] += 1
	else:
		d[q4] += 1
print(*d)


N = int(200000.0 + 5)
ans = [0] * N
(n, m) = map(int, input().split())
n += m
a = list(map(int, input().split()))
b = list(map(int, input().split()))
lv = -1
for i in range(n):
	if b[i] == 0:
		ans[i] = lv
	else:
		lv = i
lv = n
for i in range(n - 1, -1, -1):
	if b[i] == 0:
		if ans[i] == -1 or (lv != n and a[lv] - a[i] < a[i] - a[ans[i]]):
			ans[i] = lv
		ans[ans[i]] += 1
	else:
		lv = i
for i in range(n):
	if b[i] != 0:
		print(ans[i], end=' ')


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
dict1 = {}
taxi = []
ans = []
for i in range(n + m):
	if b[i] == 1:
		dict1[a[i]] = i
		taxi.append(a[i])
		ans.append(0)
ans[0] += b.index(1)
for i in range(m - 1):
	temp = (taxi[i] + taxi[i + 1]) / 2
	for j in range(dict1[taxi[i]] + 1, dict1[taxi[i + 1]]):
		if a[j] <= temp:
			ans[i] += 1
		else:
			ans[i + 1] += 1
ans[m - 1] = ans[m - 1] + n + m - 1 - dict1[taxi[m - 1]]
for i in range(m):
	print(ans[i], end=' ')


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

def next(k, a):
	i = k + 1
	while a[i] != 1:
		i += 1
	return i
ans = [0] * (m + 1)
k = -1
k = next(k, b)
ans[1] = k
for i in range(2, m + 1):
	kk = next(k, b)
	for j in range(k + 1, kk):
		if a[j] - a[k] <= a[kk] - a[j]:
			ans[i - 1] += 1
		else:
			ans[i] += 1
	k = kk
ans[m] += n + m - 1 - k
for i in range(1, m + 1):
	print(ans[i], end=' ')


(n, m) = map(int, input().strip().split())
x = [int(x) for x in input().strip().split()]
t = [int(x) for x in input().strip().split()]
taxists = [i for i in range(n + m) if t[i] == 1]
clients = [0] * m
prev = -1
curr = 0
for i in range(n + m):
	if t[i] == 1:
		if curr < m - 1:
			prev = curr
			curr = curr + 1
		else:
			prev = curr
			curr = -1
	elif prev == -1:
		clients[curr] += 1
	elif curr == -1:
		clients[prev] += 1
	else:
		prevDist = x[i] - x[taxists[prev]]
		currDist = x[taxists[curr]] - x[i]
		if currDist < prevDist:
			clients[curr] += 1
		else:
			clients[prev] += 1
for numc in clients:
	print(numc, end=' ')
print()


import sys, bisect
(n, m) = map(int, sys.stdin.readline().split())
arr = list(map(int, sys.stdin.readline().split()))
temp = list(map(int, sys.stdin.readline().split()))
taxi = []
rider = []
for i in range(n + m):
	if temp[i]:
		taxi.append(arr[i])
	else:
		rider.append(arr[i])
ans = [0] * m
for i in rider:
	idx = bisect.bisect_left(taxi, i)
	if idx == 0:
		ans[idx] += 1
	elif idx == m:
		ans[idx - 1] += 1
	else:
		left_dist = i - taxi[idx - 1]
		right_dist = taxi[idx] - i
		if left_dist <= right_dist:
			ans[idx - 1] += 1
		else:
			ans[idx] += 1
print(' '.join(map(str, ans)))


import bisect
(n, m) = tuple(map(int, input().split()))
d = list(map(int, input().split()))
typ = list(map(int, input().split()))
N = n + m
r = [0] * m
driver = [d[i] for i in range(N) if typ[i] == 1]
mids = [0] * (m - 1)
for i in range(m - 1):
	mids[i] = (driver[i + 1] + driver[i]) / 2
for (i, t) in enumerate(typ):
	if t == 0:
		r[bisect.bisect_left(mids, d[i])] += 1
for i in r:
	print(i, end=' ')


from collections import defaultdict
num = input()
rider_num = int(num.split()[0])
driver_num = int(num.split()[1])
cors = input().split()
flags = input().split()
rider_dict = defaultdict(list)
pre_d_s = -1
d_s = -1
for (i, f) in enumerate(flags):
	if f == '1':
		d_s = i
		for j in range(pre_d_s + 1, d_s):
			rider_dict[j].append(d_s)
		pre_d_s = d_s
	if f == '0':
		if pre_d_s > -1:
			rider_dict[i].append(pre_d_s)
driver_list = [0] * len(flags)
for item in rider_dict:
	if len(rider_dict[item]) == 1:
		driver_list[int(rider_dict[item][0])] += 1
	if len(rider_dict[item]) == 2:
		rider_cor = int(cors[item])
		driver_1_pos = int(rider_dict[item][0])
		driver_2_pos = int(rider_dict[item][1])
		driver_1_cor = int(cors[driver_1_pos])
		driver_2_cor = int(cors[driver_2_pos])
		if abs(rider_cor - driver_1_cor) <= abs(rider_cor - driver_2_cor):
			driver_list[driver_1_pos] += 1
		else:
			driver_list[driver_2_pos] += 1
res = ''
for (i, flag) in enumerate(flags):
	if flag == '1':
		res += str(driver_list[i])
		res += ' '
print(res)


(n, m) = [int(x) for x in input().split()]
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = [0] * (n + m)
d = dict()
for i in range(n + m):
	d[a[i]] = 0
	if b[i] == 0:
		continue
	j = i - 1
	while j >= 0 and b[j] != 1:
		if ans[j] == 0:
			ans[j] = a[i]
		elif abs(a[i] - a[j]) < abs(ans[j] - a[j]):
			ans[j] = a[i]
		j -= 1
	j = i + 1
	while j < n + m and b[j] != 1:
		if ans[j] == 0:
			ans[j] = a[i]
		elif abs(a[i] - a[j]) < abs(ans[j] - a[j]):
			ans[j] = a[i]
		j += 1
for i in range(n + m):
	if ans[i] == 0:
		continue
	d[ans[i]] += 1
for i in range(n + m):
	if b[i]:
		print(d[a[i]], end=' ')


(a, b) = map(int, input().split())
listik1 = list(map(int, input().split()))
listik2 = list(map(int, input().split()))
residents = []
taxi = [[], []]
for _ in range(a + b):
	if listik2[_] == 0:
		residents.append(listik1[_])
	else:
		taxi[0].append(listik1[_])
taxi[1] = [int(0) for i in range(b)]
if b == 1:
	print(a)
else:
	counter = 0
	for _ in range(b):
		while True:
			if counter == a:
				break
			if _ == b - 1:
				taxi[1][_] += a - counter
				break
			if abs(taxi[0][_] - residents[counter]) <= abs(taxi[0][_ + 1] - residents[counter]):
				taxi[1][_] += 1
				counter += 1
			else:
				break
	print(*taxi[1])


import sys

def parseLine():
	return list(map(lambda x: int(x), sys.stdin.readline().split()))
(m, n) = parseLine()
xis = [-1000000001] + parseLine()
taxis = [1] + parseLine()

def next(arr, i):
	j = i + 1
	while j < len(arr) and arr[j] == 0:
		j += 1
	return j
(left, right) = (0, 0)
for i in range(m + n + 1):
	if taxis[i] >= 1:
		if left > 0:
			print(taxis[left] - 1, end=' ')
		left = i
		if i == right:
			right = next(taxis, i)
	elif right == m + n + 1 or xis[i] - xis[left] <= xis[right] - xis[i]:
		taxis[left] += 1
	else:
		taxis[right] += 1
print(taxis[left] - 1)


import sys
(num_riders, _) = list(map(int, next(sys.stdin).split()))
houses = list(map(int, next(sys.stdin).split()))
is_rider = list(map(int, next(sys.stdin).split()))
current_left_driver = None
current_citizens = []
result = []
for (house, is_rider) in zip(houses, is_rider):
	if is_rider:
		if current_left_driver is None:
			result.append(len(current_citizens))
		else:
			result.append(0)
			for citizen in current_citizens:
				if abs(citizen - current_left_driver) <= abs(citizen - house):
					result[-2] += 1
				else:
					result[-1] += 1
		current_citizens = []
		current_left_driver = house
	else:
		current_citizens.append(house)
result[-1] += len(current_citizens)
print(' '.join(map(str, result)))


def dist(taxi_array, people_array):
	counters = [0] * len(taxi_array)
	for i in range(len(people_array)):
		idx = bin_search(taxi_array, people_array[i])
		counters[idx] += 1
	return counters

def bin_search(taxi_array, value):
	left_bound = 0
	right_bound = len(taxi_array) - 1
	while right_bound - left_bound > 1:
		middle = (right_bound + left_bound) // 2
		if taxi_array[middle] - value <= 0:
			left_bound = middle
		else:
			right_bound = middle
	if abs(taxi_array[right_bound] - value) >= abs(taxi_array[left_bound] - value):
		return left_bound
	else:
		return right_bound
(amount_people, amount_taxi) = [int(s) for s in input().split()]
distances = [int(s) for s in input().split()]
flags = [int(s) for s in input().split()]
taxi_array = []
people_array = []
for i in range(len(distances)):
	if flags[i]:
		taxi_array.append(distances[i])
	else:
		people_array.append(distances[i])
print(' '.join([str(s) for s in dist(taxi_array, people_array)]))


from sys import stdin, stdout
n = sum([int(x) for x in stdin.readline().split()])
x = [int(x) for x in stdin.readline().split()]
t = [int(x) for x in stdin.readline().split()]
ans = [[i, 0] for i in range(n) if t[i] == 1]
l = 0
r = 0
if len(ans) >= 2:
	r = 1
ans[0][1] += ans[0][0]
for i in range(ans[0][0] + 1, n):
	if t[i] == 1:
		l = r
		if r != len(ans) - 1:
			r += 1
	elif abs(x[ans[l][0]] - x[i]) <= abs(x[ans[r][0]] - x[i]):
		ans[l][1] += 1
	else:
		ans[r][1] += 1
for a in ans:
	stdout.write(str(a[1]) + ' ')


def binary_search(array, target):
	lower = 0
	upper = len(array) - 1
	if upper == lower:
		return 0
	while lower < upper:
		x = lower + (upper - lower) // 2
		val = array[x]
		if target == val:
			return x
		elif target > val:
			if lower == x:
				dist_left = target - array[lower]
				dist_right = array[upper] - target
				if dist_left == dist_right or dist_left < dist_right:
					return lower
				elif dist_left > dist_right:
					return upper
			lower = x
		elif target < val:
			upper = x
			if lower == upper:
				return lower
R = input()
x = list(map(int, input().split()))
t = list(map(int, input().split()))
passengers = []
taxis = []
for (idx, val) in enumerate(t):
	if val == 0:
		passengers.append(x[idx])
	elif val == 1:
		taxis.append(x[idx])
passengers.sort()
taxis.sort()
answer = [0] * len(taxis)
for i in passengers:
	index = binary_search(taxis, i)
	answer[index] += 1
print(' '.join((str(x) for x in answer)))


def test_2():
	import math
	from collections import Counter
	(n, m) = list(map(int, input().split(' ')))
	data1 = list(map(int, input().split(' ')))
	data2 = list(map(int, input().split(' ')))
	t_1 = {}
	p_1 = {}
	left = -1
	for i in range(n + m):
		if data2[i] == 1:
			t_1[data1[i]] = 0
			left = data1[i]
		else:
			p_1[i] = [left, data1[i], 0]
	right = -1
	for i in range(n + m - 1, -1, -1):
		if data2[i] == 1:
			right = data1[i]
		else:
			p_1[i][2] = right
	for (k, v) in p_1.items():
		id = v[1]
		if v[0] == -1:
			t_1[v[2]] += 1
		elif v[2] == -1:
			t_1[v[0]] += 1
		elif id - v[0] <= v[2] - id:
			t_1[v[0]] += 1
		else:
			t_1[v[2]] += 1
	print(' '.join(map(str, list(t_1.values()))))
test_2()


from collections import OrderedDict
(n, m) = map(int, input().split())
peoples = list(map(int, input().split()))
taxiFlag = list(map(int, input().split()))
taxi = list()
res = OrderedDict()
count = n + m
for i in range(count):
	if taxiFlag[i] == 1:
		res[peoples[i]] = 0
		taxi.append(peoples[i])
pos = 0
for i in range(count):
	if taxiFlag[i] == 0:
		way = abs(peoples[i] - taxi[pos])
		for j in range(pos + 1, len(taxi)):
			newWay = abs(peoples[i] - taxi[j])
			if newWay < way:
				way = newWay
				pos = j
			else:
				break
		res[taxi[pos]] += 1
for k in res.values():
	print(k, end=' ')


(n, m) = map(int, input().split())
dist = [int(x) for x in input().split()]
taxi = [int(x) for x in input().split()]
dists = {}
d = []
for person in range(len(taxi)):
	if taxi[person]:
		dists[dist[person]] = 0
		d.append(dist[person])
start = 0
d.append(10 ** 11)
for person in range(len(taxi)):
	if taxi[person] == 0:
		while dist[person] > d[start + 1]:
			start += 1
		if abs(dist[person] - d[start]) <= abs(dist[person] - d[start + 1]):
			dists[d[start]] += 1
		else:
			dists[d[start + 1]] += 1
for d in dists:
	print(dists[d] if d != 10 ** 11 else '', end=' ')


import sys
(n, m) = tuple(map(int, sys.stdin.readline().split()))
I = list(map(int, sys.stdin.readline().split()))
T = list(map(int, sys.stdin.readline().split()))
left = [0 for i in range(len(I))]
right = [0 for i in range(len(T))]
M = {}
if T[0] == 1:
	left[0] = I[0]
for i in range(1, n + m):
	left[i] = left[i - 1]
	if T[i] == 1:
		M[I[i]] = 0
		left[i] = I[i]
if T[n + m - 1] == 1:
	right[i] = I[i]
for i in range(n + m - 2, -1, -1):
	right[i] = right[i + 1]
	if T[i] == 1:
		M[I[i]] = 0
		right[i] = I[i]
for i in range(n + m):
	if T[i] != 1:
		if abs(I[i] - left[i]) <= abs(I[i] - right[i]):
			if left[i] != 0:
				M[left[i]] += 1
			else:
				M[right[i]] += 1
		elif right[i] != 0:
			M[right[i]] += 1
		else:
			M[left[i]] += 1
[print(i[1], end=' ') for i in sorted(M.items())]


counts = list(map(int, input().split()))
coords = list(map(int, input().split()))
driver_flg = list(map(int, input().split()))
N = 0
driver_idx = []
for i in range(len(driver_flg)):
	if driver_flg[i] == 1:
		driver_idx.append(i)
		N += 1

def get_interval(i, N):
	if i == 0:
		c_min = coords[0]
		if N > 1:
			c_max = (coords[driver_idx[0]] + coords[driver_idx[1]]) / 2
		else:
			c_max = coords[-1]
	elif i + 1 == N:
		c_max = coords[-1]
		c_min = (coords[driver_idx[i - 1]] + coords[driver_idx[i]]) / 2
	else:
		c_min = (coords[driver_idx[i - 1]] + coords[driver_idx[i]]) / 2
		c_max = (coords[driver_idx[i]] + coords[driver_idx[i + 1]]) / 2
	return [c_min, c_max]

def count_citizens(N):
	answer = []
	idx = 0
	for i in range(N):
		cnt = 0
		(c_min, c_max) = get_interval(i, N)
		while coords[idx] <= c_max:
			if driver_flg[idx] == 0:
				cnt += 1
			if idx + 1 == len(coords):
				break
			else:
				idx += 1
		answer.append(cnt)
	return answer
for x in count_citizens(N):
	print(x)


(n, m) = map(int, input().split())
xi = list(map(int, input().split()))
ti = list(map(int, input().split()))
ai = [0] * (m + 2)
ar = [0] * (m + 2)
ar[-1] = 10 ** 11
ar[0] = -100000000000
j = 1
n2 = n + m
for i in range(n2):
	if ti[i] == 1:
		ar[j] = xi[i]
		j += 1
i1 = 0
i2 = 1
for i in range(n2):
	if ti[i] == 1:
		i2 += 1
		i1 += 1
		continue
	num = xi[i] - ar[i1]
	num2 = ar[i2] - xi[i]
	if num <= num2:
		ai[i1] += 1
	else:
		ai[i2] += 1
for i in range(1, m + 1):
	print(ai[i], end=' ')


from collections import deque

def figure_out(coords, is_taxis):
	queue = deque()
	result = []
	prev_taxi = None
	for (coord, is_taxi) in zip(coords, is_taxis):
		if is_taxi:
			if prev_taxi is not None:
				while queue and abs(queue[0] - prev_taxi) <= coord - queue[0]:
					result[-1] += 1
					queue.popleft()
			result.append(0)
			prev_taxi = coord
		else:
			queue.append(coord)
	result[-1] += len(queue)
	return result

def main():
	(n, m) = map(int, input().split())
	coords = map(int, input().split())
	is_taxi = map(int, input().split())
	res = figure_out(coords, is_taxi)
	print(' '.join(map(str, res)))
main()


(n, m) = map(int, input().split())
person = [int(v) for v in input().split()]
T1 = [int(v) for v in input().split()]
driver = []
passenger = []
j = 0
if m == 1:
	print(n)
else:
	for i in range(n + m):
		(driver if T1[i] == 1 else passenger).append(person[i])
	ans = [0] * m
	for pi in passenger:
		while j < m - 1 and pi > (driver[j] + driver[j + 1]) / 2:
			j += 1
		ans[j] += 1
	print(*ans, end=' ')


from typing import Dict, List, Tuple

def input_lst() -> List[int]:
	return [int(x) for x in input().split()]

def print_out(res: List[int]):
	print(' '.join([str(x) for x in res]))

def main():
	(n, m) = (int(x) for x in input().split())
	coords = input_lst()
	is_taxist = input_lst()
	if m == 1:
		print(n)
		return
	drivers_coords = []
	for (i, flag) in enumerate(is_taxist):
		if flag == 1:
			drivers_coords.append(coords[i])
	res = [0] * m
	driver_id = 0
	for i in range(n + m):
		if is_taxist[i] == 0:
			if driver_id == m - 1:
				res[driver_id] += 1
			elif abs(drivers_coords[driver_id] - coords[i]) <= abs(drivers_coords[driver_id + 1] - coords[i]):
				res[driver_id] += 1
			else:
				res[driver_id + 1] += 1
		elif driver_id < m - 1:
			if coords[i] == drivers_coords[driver_id + 1]:
				driver_id += 1
	print_out(res)
main()


(n, m) = map(int, input().split())
people = list(map(int, input().split()))
cor = list(map(int, input().split()))
cor.insert(0, 1)
cor.append(1)
people.insert(0, -100000000000000)
people.append(100000000000000)
otv = [0] * m
taxi = []
for i in range(n + m + 2):
	if cor[i] == 1:
		taxi.append(people[i])
k = -1
j = 0
d = {}
for i in range(n + m + 1):
	if cor[i] == 1:
		k += 1
		j += 1
		left = taxi[k]
		right = taxi[j]
	elif people[i] - left <= right - people[i]:
		otv[k - 1] += 1
	else:
		otv[j - 1] += 1
print(*otv)


import sys
import string
from math import gcd
import getpass
import math
from decimal import Decimal
import pprint

def ria():
	return [int(i) for i in input().split()]
if getpass.getuser() != 'frohenk':
	filename = 'half'
else:
	sys.stdin = open('input.txt')
(n, m) = ria()
ar = ria()
arc = []
art = []
res = []
for (n, i) in enumerate(ria()):
	if i == 1:
		art.append(ar[n])
		res.append(0)
	else:
		arc.append(ar[n])
nt = 0
for i in arc:
	while nt != len(art) - 1 and abs(art[nt] - i) > abs(art[nt + 1] - i):
		nt += 1
	res[nt] += 1
for i in res:
	print(i, end=' ')


(h, m) = map(int, input().split())
a = [int(i) for i in input().split()]
b = []
c = [int(i) for i in input().split()]
for i in range(h + m):
	if c[i] == 1:
		b.append(i)
x = len(b)
r = [0] * x
n = -1
for i in range(h + m):
	if c[i] == 0:
		if n == -1:
			r[0] += 1
		elif n == x - 1:
			r[n] += 1
		else:
			L = a[b[n]]
			R = a[b[n + 1]]
			if a[i] - L <= R - a[i]:
				r[n] += 1
			else:
				r[n + 1] += 1
	else:
		n += 1
print(*r)


from collections import deque as de
import math
import re
from collections import Counter as cnt
from functools import reduce
from typing import MutableMapping
from itertools import groupby as gb
from fractions import Fraction as fr
from bisect import bisect_left as bl, bisect_right as br

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

class My_stack:

	def __init__(self):
		self.data = []

	def my_push(self, x):
		return self.data.append(x)

	def my_pop(self):
		return self.data.pop()

	def my_peak(self):
		return self.data[-1]

	def my_contains(self, x):
		return self.data.count(x)

	def my_show_all(self):
		return self.data

	def isEmpty(self):
		return len(self.data) == 0
arrStack = My_stack()

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def binarytodecimal(n):
	return int(n, 2)

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def get_prime_factors(number):
	prime_factors = []
	while number % 2 == 0:
		prime_factors.append(2)
		number = number / 2
	for i in range(3, int(math.sqrt(number)) + 1, 2):
		while number % i == 0:
			prime_factors.append(int(i))
			number = number / i
	if number > 2:
		prime_factors.append(int(number))
	return prime_factors

def get_frequency(list):
	dic = {}
	for ele in list:
		if ele in dic:
			dic[ele] += 1
		else:
			dic[ele] = 1
	return dic

def Log2(x):
	return math.log10(x) / math.log10(2)

def getProduct(n):
	product = 1
	while n != 0:
		product = product * (n % 10)
		n = n // 10
	return product

def dupconscount(nums):
	element = []
	freque = []
	if not nums:
		return element
	running_count = 1
	for i in range(len(nums) - 1):
		if nums[i] == nums[i + 1]:
			running_count += 1
		else:
			freque.append(running_count)
			element.append(nums[i])
			running_count = 1
	freque.append(running_count)
	element.append(nums[i + 1])
	return (element, freque)

def isPowerOfTwo(n):
	return math.ceil(Log2(n)) == math.floor(Log2(n))

def ceildiv(x, y):
	return (x + y - 1) // y

def di():
	return map(int, input().split())

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

def li():
	return list(map(int, input().split()))

def si():
	return list(map(str, input()))
(n, m) = di()
resi = li()
conf = li()
if m == 1:
	print(n)
else:
	driind = []
	resiind = []
	for i in range(n + m):
		if conf[i] == 1:
			driind.append(resi[i])
		else:
			resiind.append(resi[i])
	ans = {}
	dic = {}
	for i in range(m):
		dic[i] = driind[i]
		ans[driind[i]] = 0
	for i in range(n):
		ii = bl(driind, resiind[i])
		if ii == 0:
			ans[dic[0]] += 1
		elif ii == m:
			ans[dic[m - 1]] += 1
		else:
			if abs(dic[ii] - resiind[i]) > abs(dic[ii - 1] - resiind[i]):
				mn = dic[ii - 1]
			elif abs(dic[ii] - resiind[i]) < abs(dic[ii - 1] - resiind[i]):
				mn = dic[ii]
			else:
				mn = min(dic[ii], dic[ii - 1])
			ans[mn] += 1
	anslist = []
	for (key, val) in ans.items():
		anslist.append([key, val])
	anslist.sort()
	for row in anslist:
		print(row[1], end=' ')


(n, m) = map(int, input().split())
s = list(map(int, input().split()))
f = list(map(int, input().split()))
r = [0] * m
a = 0
b = 0
for i in range(n + m):
	if f[i] == 1:
		if b == 0:
			r[b] += i - a
			a = i
		else:
			for j in range(a + 1, i):
				if s[j] - s[a] <= s[i] - s[j]:
					r[b - 1] += 1
				else:
					r[b] += 1
			a = i
		b += 1
	else:
		pass
r[-1] += max(0, n + m - a - 1)
print(' '.join(map(str, r)))


__author__ = 'tanunia'
import sys
(n, m) = [int(p) for p in sys.stdin.readline().split()]
x = [int(p) for p in sys.stdin.readline().split()]
t = [int(p) for p in sys.stdin.readline().split()]
res = []
for i in range(n + m):
	res.append({'pos': x[i], 'isdriver': t[i], 'ind': i})
sorted(res, key=lambda xx: xx['pos'])
closest = [{'pos': -1, 'ind': -1} for _ in range(m + n)]
coord_driver = {'pos': -1, 'ind': -1}
for i in range(len(res)):
	if res[i]['isdriver'] == 1:
		coord_driver = {'pos': res[i]['pos'], 'ind': res[i]['ind']}
	if closest[i]['pos'] == -1 or abs(closest[i]['pos'] - res[i]['pos']) > abs(coord_driver['pos'] - res[i]['pos']):
		closest[i] = coord_driver
coord_driver = {'pos': -1, 'ind': -1}
for i in range(len(res) - 1, -1, -1):
	if res[i]['isdriver'] == 1:
		coord_driver = {'pos': res[i]['pos'], 'ind': res[i]['ind']}
	if closest[i]['pos'] == -1 or abs(closest[i]['pos'] - res[i]['pos']) > abs(coord_driver['pos'] - res[i]['pos']):
		closest[i] = coord_driver
res2 = [0 for _ in range(m + n)]
for i in range(len(res)):
	if res[i]['isdriver'] != 1:
		res2[closest[i]['ind']] += 1
ans = ''
for i in range(len(res2)):
	if res[i]['isdriver'] == 1:
		ans += str(res2[i]) + ' '
print(ans)


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
t = list(map(int, input().split()))
a = [0] * m
t0 = t.index(1)
a[0] = t0
if m > 1:
	t0 -= 1
for i in range(m):
	if m > 1:
		t0 = t.index(1, t0 + 1, len(t))
	if i != m - 1:
		t1 = t.index(1, t0 + 1, len(t))
		for k in range(t0 + 1, t1):
			if x[k] <= (x[t0] + x[t1]) / 2:
				a[i] += 1
			else:
				a[i + 1] += 1
	else:
		a[i] += m + n - 1 - t0
for i in a:
	print(i)


(n, m) = list(map(int, input().split()))
l1 = [100000000000] + list(map(int, input().split())) + [10000000000]
l2 = [1] + list(map(int, input().split())) + [1]
sums = [0] * (n + m + 2)
uk1 = 0
uk2 = 1
while l2[uk2] != 1:
	uk2 += 1
while True:
	for i in range(uk1 + 1, uk2):
		if abs(l1[uk1] - l1[i]) <= abs(l1[uk2] - l1[i]):
			sums[uk1] += 1
		else:
			sums[uk2] += 1
	uk1 = uk2
	uk2 += 1
	while uk2 <= n + m + 1:
		if l2[uk2] == 1:
			break
		else:
			uk2 += 1
	if uk2 == n + m + 2:
		break
for i in range(1, len(sums) - 1):
	if l2[i] == 1:
		print(sums[i], end=' ')


(n, m) = input().split()
n = int(n)
m = int(m)
inp = input()
res = [int(ele) for ele in inp.split()]
inp = input()
typeR = [int(ele) for ele in inp.split()]
TD = []
sol = []
for i in range(len(typeR)):
	if typeR[i] == 1:
		TD.append(res[i])
for i in range(len(TD)):
	sol.append(0)
dl = -1
count = 0
for i in range(len(res)):
	if typeR[i] == 1:
		dl = i
		count += 1
	elif dl == -1:
		sol[0] += 1
	else:
		ind = count - 1
		if ind < len(TD) - 1:
			if res[i] - res[dl] > TD[ind + 1] - res[i]:
				sol[ind + 1] += 1
			else:
				sol[ind] += 1
		else:
			sol[ind] += 1
print(' '.join((str(ele) for ele in sol)))


I = lambda : map(int, input().split())
(x, y) = map(int, input().split())
li1 = list(I())
li2 = list(I())
l3 = []
l4 = []
for (i, j) in enumerate(li2):
	if j == 1:
		l3.append(i)
t = 0
d = {}
d = {i: 0 for i in range(len(l3))}
for (i, j) in enumerate(li2):
	if j == 1:
		t += 1
		if t >= len(l3):
			break
		continue
	if t == 0:
		d[t] = d.get(t, 0) + 1
	elif li1[l3[t]] - li1[i] < li1[i] - li1[l3[t - 1]]:
		d[t] = d.get(t, 0) + 1
	else:
		d[t - 1] = d.get(t - 1, 0) + 1
d[t - 1] = d.get(t - 1, 0) + x + y - 1 - l3[-1]
for i in d:
	print(d[i], end=' ')


R = lambda : map(int, input().split())
(n, m) = R()
a = [[], []]
for (x, y) in zip(R(), R()):
	a[y] += [x]
d = [(x + y) // 2 for (x, y) in zip(a[1], a[1][1:])] + [1 << 30]
s = [0] * m
i = 0
for x in a[0]:
	while x > d[i]:
		i += 1
	s[i] += 1
print(*s)


import bisect
(n, m) = map(int, input().split())
rid = [None for i in range(n)]
tax = [None for i in range(m)]
res = [0 for i in range(m)]
ss = input().split()
s = input().split()
indrid = 0
indtax = 0
for i in range(n + m):
	if s[i] == '0':
		rid[indrid] = int(ss[i])
		indrid += 1
	else:
		tax[indtax] = int(ss[i])
		indtax += 1
for x in rid:
	ind = bisect.bisect_left(tax, x)
	if ind == 0:
		res[0] += 1
		continue
	if ind == m:
		res[m - 1] += 1
		continue
	if tax[ind] - x < x - tax[ind - 1]:
		res[ind] += 1
	else:
		res[ind - 1] += 1
for i in res:
	print(i, end=' ')
print('')


(m, n) = map(int, input().split())
a = [0 for i in range(n + m)]
t = [0 for i in range(n + m)]
z = [0 for i in range(n)]
c = [0 for i in range(n)]
d = [0 for i in range(n)]
a = input().split()
t = input().split()
y = 0
for i in range(n + m):
	a[i] = int(a[i])
	t[i] = int(t[i])
	if t[i] == 1:
		c[y] = a[i]
		d[y] = i
		y += 1
z[0] += d[0]
if n != 0:
	point = 0
	if m != 0:
		for i in range(d[0] + 1, n + m):
			if t[i] == 1:
				point += 1
				if point == n - 1:
					z[point] += n + m - i - 1
					break
			elif point != n - 1:
				if a[i] - a[d[point]] <= a[d[point + 1]] - a[i]:
					z[point] += 1
				else:
					z[point + 1] += 1
			else:
				z[point] += n + m - i
				break
for i in range(n):
	print(z[i], end=' ')


(n, m) = list(map(int, input().split()))
x = list(map(int, input().split()))
t = list(map(int, input().split()))
arr = []
pep = {}
for i in range(n + m):
	if t[i] == 0:
		arr.append(i)
		pep[x[i]] = 0
	else:
		for j in arr:
			pep[x[j]] = i
		arr = []
for i in range(n + m - 1, -1, -1):
	if t[i] == 0:
		arr.append(i)
	else:
		for j in arr:
			if abs(x[j] - x[i]) <= abs(x[pep[x[j]]] - x[j]):
				pep[x[j]] = i
		arr = []
ans = []
for i in range(n + m):
	if t[i]:
		ans.append(1)
	else:
		ans.append(0)
for i in pep:
	ans[pep[i]] += 1
for i in ans:
	if i:
		print(i - 1, end=' ')


(n, m) = map(int, input().split())
xs = list(map(int, input().split()))
ts = list(map(int, input().split()))
ps = [x for (x, t) in zip(xs, ts) if t == 0]
ds = [x for (x, t) in zip(xs, ts) if t == 1]
ans = [0] * m
di = 0
for (pi, p) in enumerate(ps):
	while di < m - 1 and abs(ds[di] - p) > abs(ds[di + 1] - p):
		di += 1
	if di >= m:
		ans[m - 1] += n - pi
		break
	ans[di] += 1
print(' '.join(map(str, ans)))


from collections import Counter
from bisect import bisect_left

def readint():
	return int(input())

def readline():
	return [int(c) for c in input().split()]

def main():
	(n, m) = readline()
	(X, Y) = (readline(), readline())
	(riders, taxis) = ([], [])
	for (x, y) in zip(X, Y):
		if y == 1:
			taxis.append(x)
		else:
			riders.append(x)
	cnt = Counter()
	for r in riders:
		if taxis[0] < r < taxis[-1]:
			pos = bisect_left(taxis, r)
			(dleft, dright) = (r - taxis[pos - 1], taxis[pos] - r)
			taxi = taxis[pos - 1] if dleft <= dright else taxis[pos]
		else:
			taxi = taxis[0] if r < taxis[0] else taxis[-1]
		cnt[taxi] += 1
	res = [str(cnt[t]) for t in taxis]
	print(' '.join(res))
main()


(n, m) = map(int, input().split())
res = list(map(int, input().split()))
taxi = list(map(int, input().split()))
taxi.append('#')
(i, j) = (0, 0)
flag = 0
(temp1, temp2) = (0, 0)
while j < len(taxi):
	if m == 1:
		print(n, end=' ')
		break
	elif taxi[j] == 1:
		if flag == 0:
			flag = 1
			i = j
			temp1 = i
		elif flag == 1:
			for k in range(j - i - 1):
				comp1 = res[i + k + 1] - res[i]
				comp2 = res[j] - res[i + k + 1]
				if comp1 <= comp2:
					temp1 += 1
				else:
					temp2 += 1
			print(temp1, end=' ')
			temp1 = temp2
			temp2 = 0
			i = j
	elif taxi[j] == '#':
		print(temp1 + j - i - 1, end=' ')
		break
	j = j + 1


(n, m) = map(int, input().split())
arr1 = list(map(int, input().split()))
arr2 = list(map(int, input().split()))
j = 0
ansarr = [0] * m
temparr = []
for i in range(n + m):
	if arr2[i] == 1:
		temparr.append(arr1[i])
previ = -1
for i in range(n + m):
	if arr2[i] == 1:
		j += 1
	elif j == 0:
		ansarr[j] += 1
	elif j == m:
		ansarr[j - 1] += 1
	else:
		dist1 = temparr[j] - arr1[i]
		dist2 = abs(arr1[i] - temparr[j - 1])
		if dist1 >= dist2:
			ansarr[j - 1] += 1
		else:
			ansarr[j] += 1
print(*ansarr)


def solv(coords, roles) -> int:
	r_nearest = [float('inf')] * len(coords)
	l_nearest = [float('inf')] * len(coords)
	drivers = sum(roles)
	if roles[0] == 1:
		l_nearest[0] = coords[0]
	for i in range(1, len(l_nearest)):
		if roles[i] == 1:
			l_nearest[i] = coords[i]
		else:
			l_nearest[i] = l_nearest[i - 1]
	last_idx = len(coords) - 1
	if roles[last_idx] == 1:
		r_nearest[last_idx] = coords[last_idx]
	for i in range(last_idx - 1, -1, -1):
		if roles[i] == 1:
			r_nearest[i] = coords[i]
		else:
			r_nearest[i] = r_nearest[i + 1]
	idx_map = dict()
	idx = 0
	for i in range(len(coords)):
		if roles[i] == 1:
			idx_map[coords[i]] = idx
			idx += 1
	rezult = [-1] * drivers
	for i in range(len(coords)):
		if abs(coords[i] - l_nearest[i]) <= abs(coords[i] - r_nearest[i]):
			rezult[idx_map[l_nearest[i]]] += 1
		else:
			rezult[idx_map[r_nearest[i]]] += 1
	return rezult
input()
coords_str = input()
roles_str = input()
coords = [int(v) for v in coords_str.split()]
roles = [int(v) for v in roles_str.split()]
rez = solv(coords, roles)
print(' '.join(map(str, rez)))


(n, m) = map(int, input().split())
s = list(map(int, input().split()))
t = list(map(int, input().split()))
tt = []
out = []
for i in range(n + m):
	if t[i] == 1:
		tt.append(i)
temp = tt[0]
temp2 = 0
for j in range(len(tt) - 1):
	if tt[j + 1] - tt[j] > 1:
		for k in range(tt[j + 1] - tt[j] - 1):
			if s[tt[j] + k + 1] - s[tt[j]] <= s[tt[j + 1]] - s[tt[j] + k + 1]:
				temp = temp + 1
			else:
				temp2 = temp2 + 1
		out.append(temp)
		temp = temp2
		temp2 = 0
	else:
		out.append(temp)
		temp = temp2
		temp2 = 0
temp = temp + n + m - 1 - tt[len(tt) - 1]
out.append(temp)
for l in out:
	print(l, end=' ')


(n, m) = map(int, input().split())
x = [int(w) for w in input().split()]
t = [int(w) for w in input().split()]
if m == 1:
	print(n)
else:
	p = []
	tx = []
	for i in range(n + m):
		(tx if t[i] == 1 else p).append(x[i])
	a = [0] * m
	i = 0
	for pi in p:
		while i < m - 1 and pi > (tx[i] + tx[i + 1]) / 2:
			i += 1
		a[i] += 1
	print(*a, sep=' ')


def solve(n, m, x, t):
	r = [0] * n
	d = [0] * m
	ans = [0] * m
	cr = 0
	cd = 0
	for i in range(n + m):
		if t[i]:
			d[cd] = x[i]
			cd += 1
		else:
			r[cr] = x[i]
			cr += 1
	cn = 0
	for i in range(m - 1):
		mid = (d[i] + d[i + 1]) // 2
		while cn < n and r[cn] <= mid:
			cn += 1
			ans[i] += 1
	ans[-1] += n - sum(ans)
	return ' '.join((str(i) for i in ans))

def main():
	(n, m) = [int(i) for i in input().split()]
	x = [int(i) for i in input().split()]
	t = [int(i) for i in input().split()]
	print(solve(n, m, x, t))
main()


from collections import OrderedDict
(n, m) = [int(x) for x in input().split()]
arr = [int(x) for x in input().split()]
t = [int(x) for x in input().split()]
a = [[arr[i], t[i]] for i in range(n + m)]
l = [10000000000 for i in range(n + m)]
r = [10000000000 for i in range(n + m)]
a.sort()
prev = -1
c = OrderedDict()
for i in range(0, m + n):
	if a[i][1] == 1:
		c[a[i][0]] = 0
		prev = a[i][0]
	elif prev != -1:
		l[i] = abs(prev - a[i][0])
prev = -1
for i in range(m + n - 1, -1, -1):
	if a[i][1] == 1:
		prev = a[i][0]
	elif prev != -1:
		r[i] = abs(prev - a[i][0])
for i in range(m + n):
	if a[i][1] == 0:
		if l[i] > r[i]:
			c[a[i][0] + r[i]] += 1
		else:
			c[a[i][0] - l[i]] += 1
for i in c:
	print(c[i], end=' ')


(n, m) = [int(x) for x in input().split(' ')]
residents = [int(x) for x in input().split(' ')]
is_driver = [int(x) for x in input().split(' ')]
total = n + m
drivers = [0] * total

def find_next_driver(start):
	while True:
		if start >= total:
			return None
		if is_driver[start]:
			return start
		start += 1
prev_driver = None
next_driver = find_next_driver(0)
for i in range(total):
	if is_driver[i]:
		prev_driver = i
		next_driver = find_next_driver(i + 1)
	elif prev_driver is None:
		drivers[next_driver] += 1
	elif next_driver is None:
		drivers[prev_driver] += 1
	elif residents[i] - residents[prev_driver] <= residents[next_driver] - residents[i]:
		drivers[prev_driver] += 1
	else:
		drivers[next_driver] += 1
print(' '.join([str(drivers[x]) for x in range(total) if is_driver[x]]))


(n, m) = list(map(int, input().split()))
x = input().split()
t = input().split()
r = [0] * n
d = [0] * m
countr = 0
countd = 0
for i in range(n + m):
	if int(t[i]) == 1:
		d[countd] = int(x[i])
		countd += 1
	else:
		r[countr] = int(x[i])
		countr += 1
current = 0
count = [0] * m
for i in range(n):
	while current < m - 1:
		if d[current + 1] >= r[i]:
			break
		current += 1
	if current == m - 1:
		count[m - 1] += n - i
		break
	if 2 * r[i] <= d[current] + d[current + 1]:
		count[current] += 1
	else:
		count[current + 1] += 1
s = ''
for i in range(m):
	s += str(count[i]) + ' '
print(s[:-1])


def calcule(t1, t2, aux_l, distance):
	distance.append(0)
	for k in range(0, len(aux_l)):
		if aux_l[k] - t1 <= t2 - aux_l[k]:
			distance[-2] += 1
		else:
			distance[-1] += 1
	return 0
n_m = [int(x) for x in input().split(' ')]
coord = [int(x) for x in input().split(' ')]
taxi = [int(x) for x in input().split(' ')]
long = n_m[0] + n_m[1]
aux_l = []
distance = []
nb = 0
i = 0
while taxi[i] == 0:
	nb += 1
	i += 1
t1 = coord[i]
distance.append(nb)
i += 1
while i < len(coord) and len(distance) < n_m[1]:
	while taxi[i] == 0 and i < len(coord):
		aux_l.append(coord[i])
		i += 1
	t2 = coord[i]
	calcule(t1, t2, aux_l, distance)
	t1 = t2
	i += 1
	aux_l.clear()
if i < long:
	distance[-1] += long - i
for j in distance:
	print(j, end=' ')


from collections import defaultdict
(n, m) = map(int, input().split())
x = list(map(int, input().split()))
t = list(map(int, input().split()))

def find_next_driver(r):
	while r < m + n and (not t[r]):
		r += 1
	return r
ct = m * [0]
d = 1
i = find_next_driver(0)
ct[0] = i
j = find_next_driver(i + 1)
while j < m + n:
	k = i + 1
	while k < j:
		if x[j] - x[k] < x[k] - x[i]:
			ct[d] += 1
		else:
			ct[d - 1] += 1
		k += 1
	d += 1
	i = j
	j = find_next_driver(j + 1)
ct[d - 1] += j - i - 1
print(' '.join(map(str, ct)))


import sys
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if m == 1:
	print(n)
	sys.exit()
ans = [0 for _ in range(m)]
dria = [a[i] for i in range(n + m) if b[i] == 1]
drib = [i for i in range(n + m) if b[i] == 1]
ans[0] = drib[0]
ans[m - 1] = n + m - drib[m - 1] - 1
now = 0
while now < m - 1:
	(a1, a2) = (dria[now], dria[now + 1])
	(tmp1, tmp2) = (drib[now], drib[now + 1])
	for i in range(1, tmp2 - tmp1):
		if abs(a1 - a[tmp1 + i]) <= abs(a2 - a[tmp1 + i]):
			ans[now] += 1
		else:
			ans[now + 1] += 1
	now += 1
for v in ans:
	print(v, end=' ')


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
t = list(map(int, input().split()))
rec = []
N = n + m
cnt = 1
ans = [0] * (m + 2)
for i in range(N):
	if t[i] == 1:
		rec.append((cnt, x[i]))
		cnt += 1
rec.append((cnt, float('inf')))
(pre, fo) = ((0, -float('inf')), rec[0])
for i in range(N):
	if fo[1] == x[i]:
		pre = fo
		fo = rec[fo[0]]
		continue
	elif abs(pre[1] - x[i]) <= abs(fo[1] - x[i]):
		ans[pre[0]] += 1
	else:
		ans[fo[0]] += 1
print(' '.join(map(str, ans[1:-1])))


(n, m) = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
t = [int(i) for i in input().split()]
temp = ''
tpos = []
for i in range(n + m):
	if t[i] == 1:
		tpos.append(i)
l = [-1] * (n + m)
r = [-1] * (n + m)
f = 0
for i in range(tpos[0]):
	r[i] = tpos[0]
for i in range(tpos[m - 1] + 1, n + m):
	l[i] = tpos[m - 1]
for i in range(tpos[0] + 1, tpos[m - 1]):
	if t[i] == 1:
		if i != 0:
			f += 1
	else:
		l[i] = tpos[f]
		r[i] = tpos[f + 1]
ans = [-1] * (n + m)
out = [0] * (n + m)
for i in range(n + m):
	if t[i] == 0:
		if i < tpos[0]:
			ans[i] = tpos[0]
			out[tpos[0]] += 1
		elif i > tpos[m - 1]:
			ans[i] = tpos[m - 1]
			out[tpos[m - 1]] += 1
		else:
			ldist = abs(x[i] - x[l[i]])
			rdist = abs(x[i] - x[r[i]])
			if ldist <= rdist:
				ans[i] = l[i]
				out[l[i]] += 1
			else:
				ans[i] = r[i]
				out[r[i]] += 1
for tp in tpos:
	print(out[tp], end=' ')


import bisect
[n, m] = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]
t = [int(x) for x in input().split()]
taxi = []
s = [0 for i in range(0, m)]
for i in range(0, m + n):
	if t[i] == 1:
		taxi.append(l[i])
for i in range(0, m + n):
	if t[i] == 0:
		f = bisect.bisect_left(taxi, l[i])
		if f == 0:
			s[0] = s[0] + 1
		elif f == m:
			s[m - 1] = s[m - 1] + 1
		elif l[i] - taxi[f - 1] <= taxi[f] - l[i]:
			s[f - 1] = s[f - 1] + 1
		else:
			s[f] = s[f] + 1
for e in s:
	print(e, end=' ')


(n, m) = [int(i) for i in input().split()]
riders = [int(i) for i in input().split()]
drivers = [int(i) for i in input().split()]
if m == 1:
	print(n)
	exit()
driversIndex = []
for i in range(m + n):
	if drivers[i] == 1:
		driversIndex.append(i)
res = [0] * m
res[0] = driversIndex[0]
res[m - 1] = m + n - driversIndex[len(driversIndex) - 1] - 1
for i in range(len(driversIndex) - 1):
	first = driversIndex[i] + 1
	second = driversIndex[i + 1]
	for j in range(first, second):
		firstDif = riders[j] - riders[driversIndex[i]]
		secDif = riders[driversIndex[i + 1]] - riders[j]
		if firstDif <= secDif:
			res[i] += 1
		else:
			res[i + 1] += 1
for i in range(m):
	if i != m - 1:
		print(res[i], end=' ')
	else:
		print(res[i])


(n, m) = map(int, input().strip().split())
pas = []
dri = []
ar = list(map(int, input().strip().split()))
te = list(map(int, input().strip().split()))
for i in range(n + m):
	if te[i] == 0:
		pas.append(ar[i])
	else:
		dri.append(ar[i])
ans = []
c = 0
d = 10000000000
temp = 0
j = 0
for i in range(m):
	if i != m - 1:
		d = dri[i + 1]
	else:
		d = 10000000000
	while j < n:
		if abs(pas[j] - dri[i]) <= abs(pas[j] - d):
			c += 1
			temp = j + 1
		else:
			break
		j += 1
	j = temp
	ans.append(c)
	c = 0
print(*ans)


(n, m) = map(int, input().split())
loc = list(map(int, input().split()))
td = list(map(int, input().split()))
td_loc = [loc[i] for i in range(m + n) if td[i] == 1]
r_loc = [loc[i] for i in range(m + n) if td[i] == 0]
result = [0] * m
j = 0
boool = False
for i in r_loc:
	if j < m - 1:
		while abs(i - td_loc[j]) > abs(i - td_loc[j + 1]):
			j = j + 1
			if j >= m - 1:
				boool = True
				break
		if boool:
			break
		result[j] = result[j] + 1
result[-1] = result[-1] + n - sum(result)
for i in result:
	print(i, end=' ')


(n, m) = map(int, input().strip().split(' '))
x = list(map(int, input().strip().split(' ')))
t = list(map(int, input().strip().split(' ')))
l1 = []
l2 = []
for i in range(n + m):
	if t[i] == 0:
		l1.append(x[i])
	else:
		l2.append(x[i])
l1.sort()
l2.sort()
if len(l2) == 1:
	print(n)
else:
	l3 = [0] * m
	j = 0
	i = 0
	while i < n:
		if l1[i] < l2[j]:
			l3[j] += 1
			i += 1
		elif j < m - 1 and l1[i] > l2[j] and (l1[i] < l2[j + 1]):
			if l1[i] - l2[j] <= l2[j + 1] - l1[i]:
				l3[j] += 1
				i += 1
			else:
				l3[j + 1] += 1
				i += 1
		elif j == m - 1:
			l3[-1] += 1
			i += 1
		else:
			j += 1
			f = 0
			while j < m:
				if l1[i] > l2[j]:
					j += 1
				else:
					f = 1
					break
			j -= 1
	for j in range(m):
		print(l3[j], end=' ')
	print()


(n, m) = map(int, input().split())
s = n + m
x = list(map(int, input().split()))
loc = input().split()
t = []
for i in range(s):
	if loc[i] == '1':
		t.append(i)
for i in range(m):
	ans = 0
	if i != 0:
		for j in range(t[i - 1] + 1, t[i]):
			if x[j] - x[t[i - 1]] > x[t[i]] - x[j]:
				ans += 1
	else:
		ans += t[i]
	if i != m - 1:
		for j in range(t[i] + 1, t[i + 1]):
			if x[j] - x[t[i]] <= x[t[i + 1]] - x[j]:
				ans += 1
	else:
		ans += s - t[i] - 1
	print(ans, end=' ')


def taxi(x):
	for i in range(x, n + m):
		if A[i] == 1:
			return i
	return 10 ** 7
(n, m) = map(int, input().split())
X = list(map(int, input().split()))
A = list(map(int, input().split()))
Ans = [0] * (m + n)
l = -10 ** 7
r = taxi(1)
for i in range(n + m):
	if A[i] == 0:
		if l == -10 ** 7:
			Ans[r] += 1
		elif r == 10 ** 7:
			Ans[l] += 1
		elif X[i] - X[l] <= X[r] - X[i]:
			Ans[l] += 1
		else:
			Ans[r] += 1
	else:
		l = i
		r = taxi(i + 1)
for i in range(n + m):
	if A[i] == 1:
		print(Ans[i], end=' ')


import sys
(n, m) = map(int, input().split())
a = list(map(int, sys.stdin.readline().split()))
b = list(map(int, sys.stdin.readline().split()))
d = dict()
p = []
if m == 1:
	print(n)
else:
	for j in range(n + m):
		if b[j] == 1:
			p.append(a[j])
			d[a[j]] = 0
	k = 0
	for v in a:
		if v in d:
			continue
		while k < m and p[k] < v:
			k = k + 1
		if k == m:
			d[p[k - 1]] += 1
		elif k == 0:
			d[p[k]] += 1
		elif v - p[k - 1] <= p[k] - v:
			d[p[k - 1]] += 1
		else:
			d[p[k]] += 1
	an = list(d.values())
	print(' '.join(map(str, an)))


import sys
(n, m) = map(int, sys.stdin.readline().split())
X = list(map(int, sys.stdin.readline().split()))
T = list(map(int, sys.stdin.readline().split()))
Taxi = []
Res = []
for i in range(n + m):
	if T[i] == 1:
		Taxi.append(X[i])
	else:
		Res.append(X[i])
TMAP = [[0, 0] for i in range(m)]
for i in range(m - 1):
	TMAP[i][1] = (Taxi[i] + Taxi[i + 1]) // 2
	TMAP[i + 1][0] = (Taxi[i] + Taxi[i + 1]) // 2 + 1
TMAP[m - 1][1] = X[-1]
TCOUNT = [0 for i in range(m)]
i = 0
for j in Res:
	while True:
		if TMAP[i][0] <= j <= TMAP[i][1]:
			TCOUNT[i] += 1
			break
		else:
			i += 1
for t in TCOUNT:
	print(t, end=' ')


inp = lambda : map(int, input().split())
(n, m) = inp()
a = [[], []]
for (x, y) in zip(inp(), inp()):
	a[y] += [x]
s = [0] * m
(riders, drivers) = a
i = 0
for r in riders:
	while i < m - 1 and r - drivers[i] > drivers[i + 1] - r:
		i = i + 1
	s[i] = s[i] + 1
print(*s)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
t = list(map(int, input().split()))
ans = [0] * m
p = []
for i in range(n + m):
	if t[i] == 1:
		p.append(i)
ans[0] = p[0]
for i in range(m):
	if i == m - 1:
		ans[i] += n + m - p[i] - 1
	else:
		for j in range(p[i] + 1, p[i + 1]):
			if a[j] - a[p[i]] <= a[p[i + 1]] - a[j]:
				ans[i] += 1
			else:
				ans[i + 1] += 1
print(' '.join(map(str, ans)))


def find_drivers_answers(n, m, coordinates, is_driver):
	if m == 1:
		return [n]
	results = [0] * m
	drivers_coordinates = [coordinates[x] for x in range(n + m) if is_driver[x]]
	riders_coordinates = [coordinates[x] for x in range(n + m) if not is_driver[x]]
	(left_driver, right_driver) = get_bounds(drivers_coordinates, riders_coordinates[0])
	left_driver_idx = drivers_coordinates.index(left_driver)
	for rider in riders_coordinates:
		left_dist = abs(left_driver - rider)
		right_dist = abs(right_driver - rider)
		while left_dist > right_dist:
			left_driver = right_driver
			(left_driver_idx, right_driver) = get_next_driver(left_driver_idx, drivers_coordinates, m)
			left_dist = abs(left_driver - rider)
			right_dist = abs(right_driver - rider)
		results[left_driver_idx] += 1
	return results

def get_bounds(drivers_coordinates, first_rider):
	if drivers_coordinates[0] > first_rider:
		return (drivers_coordinates[0], drivers_coordinates[1])
	if drivers_coordinates[-1] <= first_rider:
		return (drivers_coordinates[-2], drivers_coordinates[-1])
	smaller_equal = list(filter(lambda x: x <= first_rider, drivers_coordinates))
	greater = list(filter(lambda x: x > first_rider, drivers_coordinates))
	return (smaller_equal[-1], greater[0])

def get_next_driver(left_driver_idx, drivers_coordinates, m):
	next_idx = left_driver_idx + 1
	if left_driver_idx + 2 == m:
		return (next_idx, -1)
	return (next_idx, drivers_coordinates[next_idx + 1])
(n, m) = [int(a) for a in input().split()]
coordinates = [int(a) for a in input().split()]
is_driver = [a == '1' for a in input().split()]
results = find_drivers_answers(n, m, coordinates, is_driver)
print(' '.join([str(x) for x in results]))


nm = input().split(' ')
n = int(nm[0])
m = int(nm[1])
cor = [int(x) for x in input().split(' ')]
tx = [int(x) for x in input().split(' ')]
txind = []
for i in range(n + m):
	if tx[i] == 1:
		txind.append(i)
res = [0 for i in range(m)]
nt = -1
for i in range(n + m):
	if tx[i] == 1:
		nt += 1
		if nt + 1 < m:
			ntx = cor[txind[nt + 1]]
			ptx = cor[i]
			mid = (ntx + ptx) // 2
	elif nt == -1:
		res[0] += 1
	elif nt >= m - 1:
		res[m - 1] += 1
	elif ptx < cor[i] <= mid:
		res[nt] += 1
	else:
		res[nt + 1] += 1
for i in range(m):
	print(res[i], end=' ')


(n, m) = [int(x) for x in input().split(' ')]
c = [int(x) for x in input().split(' ')]
t = input().split(' ')
fo = -1
r = []
for i in range(n + m):
	if t[i] == '1':
		if fo == -1:
			r.append(i)
		else:
			r.append(0)
			for j in range(fo + 1, i):
				df = c[j] - c[fo]
				dl = c[i] - c[j]
				if df <= dl:
					r[len(r) - 2] += 1
				else:
					r[len(r) - 1] += 1
		fo = i
r[len(r) - 1] += len(c) - 1 - fo
print(' '.join([str(x) for x in r]))


from bisect import bisect_left
(n, m) = map(int, input().split())
t1 = list(map(int, input().split()))
t2 = list(map(int, input().split()))
ile_1 = t2.count(1)
dist = [-999999999999]
wyn = []
przedz = []
n_dyst = 0
if ile_1 == 1:
	print(n)
	exit()
for x in range(0, len(t2), +1):
	if t2[x] == 1:
		dist.append(t1[x])
dist.append(999999999999)
for x in range(0, len(t1), +1):
	pos = bisect_left(dist, t1[x])
	if dist[pos - 1] == -999999999999:
		wyn.append(dist[pos])
	elif dist[pos] == 999999999999:
		wyn.append(dist[pos - 1])
	elif abs(t1[x] - dist[pos - 1]) <= abs(t1[x] - dist[pos]):
		wyn.append(dist[pos - 1])
	else:
		wyn.append(dist[pos])
str_wyn = ''
for x in range(0, len(wyn) - 1, +1):
	if wyn[x] != wyn[x + 1]:
		str_wyn += str(n_dyst) + ' '
		n_dyst = 0
	else:
		n_dyst += 1
str_wyn += str(n_dyst)
print(str_wyn)


from bisect import bisect_right as br
from bisect import bisect_left as bl
from math import *

def isprime(n):
	n = abs(int(n))
	if n < 2:
		return False
	if n == 2:
		return True
	if not n & 1:
		return False
	for x in range(3, int(n ** 0.5) + 1, 2):
		if n % x == 0:
			return False
	return True

def mhd(a, b, x, y):
	return abs(a - x) + abs(b - y)
ta = []
pa = []
d = {}
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
t = list(map(int, input().split()))
for i in range(n + m):
	if t[i] == 1:
		ta.append(a[i])
		d[a[i]] = 0
	else:
		pa.append(a[i])
if m == 1:
	print(n)
else:
	ta.sort()
	for i in pa:
		li = bl(ta, i)
		if li == 0:
			d[ta[li]] += 1
		elif li == m:
			d[ta[li - 1]] += 1
		else:
			x = abs(ta[li - 1] - i)
			y = abs(ta[li] - i)
			if x <= y:
				d[ta[li - 1]] += 1
			else:
				d[ta[li]] += 1
	for i in range(n + m):
		if t[i] == 1:
			print(d[a[i]], end=' ')


from collections import Counter
(n, m) = list(map(int, input().split()))
x = list(map(int, input().split()))
t = ''.join(input().split())
a = [0] * (n + m)
f1 = 0
f2 = t.find('1')
f = 0
for i in range(f2):
	a[i] = f2
while f2 != -1:
	f1 = f2
	f2 = t.find('1', f1 + 1)
	if f2 == -1:
		for i in range(f1 + 1, n + m):
			a[i] = f1
	else:
		for i in range(f1, f2):
			if x[i] - x[f1] > x[f2] - x[i]:
				a[i] = f2
			else:
				a[i] = f1
d = [i for i in range(n + m) if t[i] == '1']
d1 = Counter([a[i] for i in range(n + m) if t[i] == '0'])
output = [d1[i] for i in d]
print(*output)


(n, m) = list(map(int, input().split()))
arr = list(map(int, input().split()))
t = list(map(int, input().split()))
taxi = list()
for i in range(len(arr)):
	if t[i] == 1:
		taxi.append(arr[i])
taxi2 = list()
kek = 1
for i in range(len(taxi) - 1):
	taxi2.append([kek, taxi[i] + (taxi[i + 1] - taxi[i]) // 2])
	kek = taxi[i] + (taxi[i + 1] - taxi[i]) // 2 + 1
taxi2.append([kek, arr[-1]])
taxi3 = [0] * m
j = 0
for i in range(len(arr)):
	if arr[i] > taxi2[j][1]:
		j += 1
	if t[i] != 1:
		taxi3[j] += 1
print(' '.join(map(str, taxi3)))


(n, m) = list(map(int, input().split()))
x = list(map(int, input().split()))
t = list(map(int, input().split()))
locs = []
for i in range(n + m):
	if t[i] == 1:
		locs.append(i)
res = [0] * m
res[0] += locs[0]
res[-1] += n + m - 1 - locs[-1]

def helper(l, r, a, b):
	z = l
	while l < r:
		mid = l + (r - l + 1) // 2
		if x[mid] - a <= b - x[mid]:
			l = mid
		else:
			r = mid - 1
	if x[l] - a <= b - x[l]:
		return l - z + 1
	else:
		return 0
for i in range(1, m):
	cur = locs[i]
	pre = locs[i - 1]
	if pre == cur - 1:
		continue
	(a, b) = (x[pre], x[cur])
	num = helper(pre + 1, cur - 1, a, b)
	res[i - 1] += num
	res[i] += cur - pre - 1 - num
print(' '.join(map(str, res)))


(n, m) = map(int, input().split())
cords = map(int, input().split())
roles = map(int, input().split())
drivers = []
riders = []
for (cord, role) in zip(cords, roles):
	if role == 1:
		drivers.append(cord)
	else:
		riders.append(cord)
result = [0] * m
idx = 0
for rider in riders:
	while idx < m and drivers[idx] <= rider:
		idx += 1
	if idx == m:
		result[idx - 1] += 1
	elif idx - 1 < 0:
		result[idx] += 1
	else:
		l1 = rider - drivers[idx - 1]
		l2 = drivers[idx] - rider
		if l1 <= l2:
			result[idx - 1] += 1
		else:
			result[idx] += 1
print(*result)


(a, b) = map(int, input().split())
c = [0] + list(map(int, input().split()))
c += [c[-1] + 1]
d = [1] + list(map(int, input().split())) + [1]
z = [i for i in range(len(d)) if d[i] == 1]
ans = [0]
for i in range(len(z) - 1):
	s = 0
	p = 0
	l = c[z[i]]
	r = c[z[i + 1]]
	for k in range(z[i] + 1, z[i + 1]):
		if c[k] - l <= r - c[k]:
			s += 1
		else:
			p += 1
	ans[-1] += s
	ans += [p]
ans[1] += ans[0]
ans[-2] += ans[-1]
ans.pop(0)
ans.pop(-1)
print(*ans)


def taxiCalls(riders, drivers):
	if len(drivers) == 1:
		return [len(riders)]
	result = [0 for i in drivers]
	for i in riders:
		result[bSearch(i, drivers)] += 1
	return result

def bSearch(x, drivers):
	start = 0
	end = len(drivers) - 1
	while end - start > 1:
		mid = start + (end - start) // 2
		if x > drivers[mid]:
			start = mid
		else:
			end = mid
	if abs(drivers[end] - x) < abs(drivers[start] - x):
		return end
	return start
for i in range(1):
	x = input().strip().split()
	r = int(x[0])
	t = int(x[1])
	x = input().strip().split()
	y = input().strip().split()
	riders = []
	drivers = []
	k = 0
	for i in y:
		if i == '1':
			drivers.append(int(x[k]))
		else:
			riders.append(int(x[k]))
		k += 1
	arr = taxiCalls(riders, drivers)
	for i in arr:
		print(i, end=' ')


(n, m) = map(int, input().split())
d = list(map(int, input().split()))
a = list(map(int, input().split()))
x = -1
b = [-1] * (n + m)
for i in range(n + m):
	if a[i]:
		x = i
	else:
		b[i] = x
x = -1
for i in range(n + m - 1, -1, -1):
	if a[i]:
		x = i
	elif b[i] < 0:
		b[i] = x
	elif x >= 0 and d[x] - d[i] < d[i] - d[b[i]]:
		b[i] = x
c = [0] * (n + m)
for i in b:
	if i >= 0:
		c[i] += 1
d = [c[i] for i in range(n + m) if a[i]]
print(' '.join(map(str, d)))


import sys

def binsearch(x, arr):
	s = 0
	e = len(arr) - 1
	l = len(arr)
	if x < arr[s]:
		return s
	if x > arr[e]:
		return e
	while e - s > 4:
		m = (s + e) // 2
		if arr[m] < x:
			s = m + 1
		else:
			e = m - 1
	s = max(0, s - 1)
	e = min(e + 1, l - 1)
	mint = 1000000000 + 5
	idx = -1
	for t in range(s, e + 1):
		dist = abs(arr[t] - x)
		if dist < mint:
			mint = dist
			idx = t
	return idx
(ns, ms) = sys.stdin.readline().strip().split()
n = int(ns)
m = int(ms)
pos = [int(s) for s in sys.stdin.readline().strip().split()]
roles = [int(s) for s in sys.stdin.readline().strip().split()]
d = []
r = []
for (p, role) in zip(pos, roles):
	if role == 1:
		d.append(p)
	else:
		r.append(p)
cnt = [0] * m
for p in r:
	idx = binsearch(p, d)
	cnt[idx] += 1
print(' '.join([str(i) for i in cnt]))


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
t = list(map(int, input().split()))
tax = []
for i in range(n + m):
	if t[i] == 1:
		tax.append(x[i])
cnt = 0
pointer = 0
flag = 0
ans = m * [0]
right_index = t[::-1].index(1)
for j in range(t.index(1), n + m):
	if t[j] == 1:
		if flag == 0:
			ans[0] = t.index(1)
			flag = 1
		else:
			ans[pointer] = cnt
			cnt = 0
		pointer += 1
	else:
		try:
			if x[j] - tax[pointer - 1] <= tax[pointer] - x[j]:
				ans[pointer - 1] += 1
			else:
				cnt += 1
		except IndexError:
			ans[pointer - 1] += right_index
			break
print(*ans)


(n, m) = map(int, input().split())
coords = list(map(int, input().split()))
drivers = list(map(int, input().split()))
res = [0] * m
drivers.append(True)
ind = 0
while not drivers[ind]:
	ind += 1
res[0] = ind
ind += 1

def fnd(arr, v, frm, to):
	if frm + 1 == to:
		return frm + 1 if arr[frm] <= v else frm
	m = (frm + to) // 2
	if arr[m] == v:
		return m + 1
	if arr[m] < v:
		return fnd(arr, v, m, to)
	else:
		return fnd(arr, v, frm, m)
for di in range(m):
	ind_next = ind
	while not drivers[ind_next]:
		ind_next += 1
	if ind_next == ind:
		ind += 1
		continue
	if ind_next == len(coords):
		res[di] += ind_next - ind
	else:
		m_ind = fnd(coords, (coords[ind - 1] + coords[ind_next]) // 2, ind, ind_next)
		res[di] += m_ind - ind
		res[di + 1] += ind_next - m_ind
	ind = ind_next + 1
print(' '.join(map(str, res)))


def main():
	one = list(map(int, input().split()))
	location = list(map(int, input().split()))
	flag = list(map(int, input().split()))
	drivers = [location[i] for i in range(len(location)) if flag[i]]
	res = [0] * len(drivers)

	def bs(value):
		(lo, hi) = (0, len(drivers) - 1)
		while lo < hi:
			mid = (lo + hi) // 2
			if drivers[mid] < value:
				lo = mid + 1
			else:
				hi = mid
		return lo
	for i in range(len(location)):
		if not flag[i]:
			lo = bs(location[i])
			if lo != 0 and drivers[lo] - location[i] >= location[i] - drivers[lo - 1]:
				res[lo - 1] += 1
			else:
				res[lo] += 1
	print(' '.join(list(map(str, res))))
main()


def go():
	(n, m) = [int(i) for i in input().split(' ')]
	a = [int(i) for i in input().split(' ')]
	b = [int(i) for i in input().split(' ')]
	o = []
	prev = None
	for i in range(n + m):
		if b[i] == 1:
			if prev is not None:
				c = 0
				p = 0
				for j in range(prev + 1, i):
					if a[i] - a[j] < a[j] - a[prev]:
						c += 1
					else:
						p += 1
				o[-1] += p
				o.append(c)
			else:
				o.append(i)
			prev = i
	if b[i] != 1:
		o[-1] += n + m - prev - 1
	return ' '.join((str(i) for i in o))
print(go())


from math import inf
(n, m) = list(map(int, input().split()))
x = list(map(int, input().split()))
t = list(map(int, input().split()))
riders = []
drivers = [-inf]
for i in range(len(x)):
	if t[i] == 1:
		drivers.append(x[i])
	else:
		riders.append(x[i])
drivers.append(inf)
result = [0] * m
cur = 1
prev = 0
for i in range(len(x)):
	if t[i]:
		cur += 1
		prev += 1
		continue
	if abs(x[i] - drivers[cur]) < abs(x[i] - drivers[prev]):
		result[cur - 1] += 1
	else:
		result[prev - 1] += 1
print(*result)


import bisect
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
t = list(map(int, input().split()))
taxi = []
for i in range(0, n + m):
	if t[i] == 1:
		taxi.append(a[i])
nt = len(taxi)
ans = [0 for i in range(0, nt)]
for i in range(0, n + m):
	if t[i] == 0:
		if a[i] < taxi[0]:
			ans[0] += 1
		elif a[i] > taxi[nt - 1]:
			ans[nt - 1] += 1
		else:
			x = bisect.bisect_left(taxi, a[i], 0, nt)
			if taxi[x] - a[i] < a[i] - taxi[x - 1]:
				ans[x] += 1
			else:
				ans[x - 1] += 1
for i in range(0, nt):
	print(ans[i], end=' ')


from collections import defaultdict
(n, m) = tuple(map(int, input().split()))
x_coords = list(map(int, input().split()))
is_taxist = list(map(int, input().split()))
if m == 1:
	print(n)
	exit(0)
taxists = []
citizens = []
for i in range(n + m):
	if is_taxist[i]:
		taxists.append(x_coords[i])
	else:
		citizens.append(x_coords[i])
c_taxi = 0
n_taxi = c_taxi + 1
result = defaultdict(int)

def dist(a, b):
	return abs(a - b)
for i in range(n):
	while n_taxi < m and (taxists[c_taxi] < citizens[i] and taxists[n_taxi] < citizens[i]):
		c_taxi += 1
		n_taxi += 1
	if n_taxi < m:
		c_d = dist(citizens[i], taxists[c_taxi])
		n_d = dist(citizens[i], taxists[n_taxi])
		if n_d < c_d:
			c_taxi += 1
			n_taxi += 1
	result[c_taxi] += 1
for x in range(m):
	print(result[x], end=' ' if x < m - 1 else '\n')


import sys
(n, m) = [int(w) for w in input().split()]
x = [int(w) for w in input().split()]
t = [int(w) for w in input().split()]
if m == 1:
	print(n)
	sys.exit(0)
p = []
tx = []
for i in range(n + m):
	(tx if t[i] == 1 else p).append(x[i])
a = [0] * m
i = 0
for pi in p:
	while i < m - 1 and pi > (tx[i] + tx[i + 1]) / 2:
		i += 1
	a[i] += 1
print(' '.join((str(ai) for ai in a)))


(n, m) = map(int, input().split())
loc = list(map(int, input().split()))
taxiloc = list(map(int, input().split()))
lasttaxi = 0
tc = 0
taxi = []
length = []
for i in range(n + m):
	if taxiloc[i] == 1:
		tc += 1
		taxi.append(0)
		for j in range(len(length)):
			if loc[i] - loc[length[j]] < loc[length[j]] - loc[lasttaxi]:
				taxi[tc - 1] += 1
			else:
				taxi[tc - 2] += 1
		lasttaxi = i
		length = []
	else:
		length.append(i)
if taxiloc[n + m - 1] != 1:
	taxi[m - 1] += len(length)
for i in range(m):
	taxi[i] = str(taxi[i])
print(' '.join(taxi))


(n, m) = list(map(int, input().split()))
xs = [int(k) for k in input().split()]
ts = [int(k) for k in input().split()]
pos = [-1 for i in range(n + m)]
if ts[0]:
	pos[0] = 0
for i in range(1, n + m):
	pos[i] = pos[i - 1]
	if ts[i]:
		pos[i] += 1
result = [0 for i in range(m)]
left = 0
leftC = 0
right = 0
rightC = 0
for i in range(n + m):
	if ts[i] == 0:
		right = max(i, right)
		while right + 1 < n + m and (not ts[right]):
			right += 1
		(mP, mD) = (0, 20000000)
		if ts[left]:
			mP = pos[left]
			mD = xs[i] - xs[left]
		if ts[right] and xs[right] - xs[i] < mD:
			mD = xs[right] - xs[i]
			mP = pos[right]
		result[mP] += 1
	else:
		left = i
print(*result)


(n, m) = map(int, input().split())
x = [int(i) for i in input().split()]
q = [int(i) for i in input().split()]
p = []
t = []
for i in range(len(q)):
	if q[i] == 0:
		p.append(x[i])
	else:
		t.append(x[i])
ans = [0] * len(t)
i = 0
j = 0
for j in range(len(p)):
	item = p[j]
	if i + 1 < len(t):
		while i + 2 < len(t) and item > t[i + 1]:
			i += 1
		if t[i] <= item <= t[i + 1] or i == 0:
			if abs(item - t[i]) <= abs(item - t[i + 1]):
				ans[i] += 1
			else:
				ans[i + 1] += 1
		else:
			i += 1
	if i == len(t) - 1:
		ans[i] += 1
	j += 1
print(*ans)


(q, w) = map(int, input().split())
a = list(map(int, input().split()))
s = list(map(int, input().split()))
d = []
k = 0
for i in range(0, q + w):
	if s[i]:
		d.append(a[i])
		k = i
d.append(100000000000)
t = 0
t1 = 1
g = 0
for i in a:
	if i == d[t]:
		continue
	elif i - d[t] <= d[t1] - i:
		g += 1
	else:
		print(g, end=' ')
		if d[t1] == i:
			g = 0
		else:
			g = 1
		t += 1
		t1 += 1
print(g)


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
t = list(map(int, input().split()))
d = {}
for i in range(n + m):
	if t[i] == 1:
		d[i] = 0
aux = [float('inf')] * (n + m)
c = -1
for i in range(n + m):
	if t[i] == 1:
		c = i
	elif c != -1:
		aux[i] = x[i] - x[c]
c = -1
left = 0
i1 = t.index(1)
i2 = t[::-1].index(1)
d[i1] += i1
d[n + m - (i2 + 1)] += i2
for i in range(n + m - 1, -1, -1):
	if t[i] == 1:
		c = i
		d[c] += left
		left = 0
	elif c != -1:
		y = x[c] - x[i]
		if y < aux[i] and aux[i] != float('inf'):
			d[c] += 1
		else:
			left += 1
ans = []
for i in d:
	ans.append(d[i])
print(*ans)


import sys
(n, m) = map(int, input().split())
xs = [int(s) for s in input().split()]
ts = [s == '1' for s in input().split()]
tos = []
for (i, x) in enumerate(xs):
	if ts[i]:
		tos.append((i, xs[i]))

def q(xx, pt, ct):
	if pt is None:
		return True
	if xx - pt[1] <= ct[1] - xx:
		return False
	return True
if len(tos) == 1:
	print(n)
	sys.exit(0)
tcc = [0] * len(tos)
i = 1
ct = tos[i]
pt = tos[i - 1]
tcc[0] = pt[0]
tn = 0
c = 0
j = pt[0] + 1
while j < n + m:
	if j == ct[0]:
		pt = ct
		if i + 1 < len(tos):
			i += 1
			ct = tos[i]
	elif q(xs[j], pt, ct):
		tcc[i] += 1
	else:
		tcc[i - 1] += 1
	j += 1
print(' '.join([str(x) for x in tcc]))


(n, m) = map(int, input().split())
coords = list(map(int, input().split()))
taxis = list(map(int, input().split()))
spots = []
riders = []
for i in range(n + m):
	if taxis[i] == 1:
		spots.append(coords[i])
	else:
		riders.append(coords[i])
spots.append(100000000000000)
a = 0
for i in range(n):
	while True:
		if abs(riders[i] - spots[a]) <= abs(riders[i] - spots[a + 1]):
			riders[i] = a
			break
		else:
			a += 1
ans = [0] * m
for i in range(n):
	ans[riders[i]] += 1
out = ''
for i in range(m):
	out += str(ans[i]) + ' '
print(out[:-1])


import bisect
import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
d = list(map(int, input().split()))
typ = list(map(int, input().split()))
N = n + m
r = [0] * m
driver = [d[i] for i in range(N) if typ[i] == 1]
mids = [0] * (m - 1)
for i in range(m - 1):
	mids[i] = (driver[i + 1] + driver[i]) / 2
for (i, t) in enumerate(typ):
	if t == 0:
		r[bisect.bisect_left(mids, d[i])] += 1
print(*r)


(n, m) = [int(x) for x in input().split()]
xs = [int(x) for x in input().split()]
ts = [int(x) for x in input().split()]
taxi_idx = sorted([xs[idx] for idx in range(n + m) if ts[idx] == 1])
passenger_idx = sorted([xs[idx] for idx in range(n + m) if ts[idx] == 0])
a_is = [0] * len(taxi_idx)
t_idx = 0
p_idx = 0
while True:
	if p_idx >= len(passenger_idx):
		break
	if t_idx == len(taxi_idx) - 1:
		a_is[t_idx] += 1
	else:
		while t_idx < len(taxi_idx) - 1:
			d1 = abs(passenger_idx[p_idx] - taxi_idx[t_idx])
			d2 = abs(passenger_idx[p_idx] - taxi_idx[t_idx + 1])
			if d1 > d2:
				t_idx += 1
			else:
				break
		a_is[t_idx] += 1
	p_idx += 1
print(' '.join([str(x) for x in a_is]))


(n, m) = [int(x) for x in input().split()]
x = [int(x) for x in input().split()]
index = [int(x) for x in input().split()]
arr = [0] * m
for i in range(n + m):
	if index[i]:
		arr[0] = i
		last = i
		last_m = 0
		break
for i in range(last + 1, n + m):
	if index[i]:
		count = 0
		if x[i] - x[i - 1] >= x[i - 1] - x[last]:
			arr[last_m] += i - last - 1
		else:
			for j in range(last + 1, i):
				if x[j] - x[last] > x[i] - x[j]:
					arr[last_m + 1] += i - last - 1 - count
					arr[last_m] += count
					break
				else:
					count += 1
		last = i
		last_m += 1
arr[-1] += n + m - last - 1
print(*arr)


GI = lambda : int(input())
GIS = lambda : map(int, input().split())
LGIS = lambda : list(GIS())

def dp(ids, coors):
	driver = None
	l = []
	for (is_driver, coor) in zip(ids, coors):
		if is_driver:
			driver = coor
		elif driver is None:
			l.append(None)
		else:
			l.append(driver)
	return l

def main():
	(riders, drivers) = GIS()
	coors = LGIS()
	ids = LGIS()
	ltr = dp(ids, coors)
	rtl = dp(reversed(ids), reversed(coors))
	rtl.reverse()
	rs = {}
	for (coor, l, r) in zip((coor for (coor, is_driver) in zip(coors, ids) if not is_driver), ltr, rtl):
		if l is None and r is None:
			continue
		if l is None:
			win = r
		elif r is None:
			win = l
		else:
			dl = abs(coor - l)
			dr = abs(coor - r)
			win = l if dl <= dr else r
		rs[win] = rs.get(win, 0) + 1
	for coor in (coor for (coor, is_driver) in zip(coors, ids) if is_driver):
		print(rs.get(coor, 0), end=' ')
	print()
main()


R = lambda : map(int, input().split())
(t, r) = R()
crd = list(R())
occ = list(R())
taxis = [-10 ** 18] + [crd[i] for i in range(len(crd)) if occ[i] == 1] + [10 ** 18]
riders = [crd[i] for i in range(len(crd)) if occ[i] == 0]
ans = [0] * (len(taxis) - 2)
cur = 1
for rider in riders:
	while rider > taxis[cur]:
		cur += 1
	if taxis[cur] - rider < rider - taxis[cur - 1]:
		ans[cur - 1] += 1
	else:
		ans[cur - 2] += 1
print(*ans)


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
t = list(map(int, input().split()))
a = [0] * (m + 2)
b = [0] * (m + 2)
a[0] = 0
a[m] = x[m + n - 1] + 1
l = 1
for i in range(m + n):
	if t[i] == 1:
		a[l] = x[i]
		l += 1
l = 0
for i in range(m + n):
	if t[i] == 0:
		if x[i] - a[l] > a[l + 1] - x[i]:
			b[l + 1] += 1
		else:
			b[l] += 1
	else:
		l += 1
b[1] += b[0]
b[m] += b[m + 1]
for i in range(1, m + 1):
	print(b[i], end=' ')


(n, m) = [*map(int, input().split())]
x = [*map(int, input().split())]
t = [*map(int, input().split())]
a = [0] * m
z = [i for (i, e) in enumerate(t) if e != 0]
if m == 1:
	a[0] = n
else:
	a[0] = z[0]
	for i in range(m - 1):
		d = (x[z[i + 1]] + x[z[i]]) / 2
		for _ in x[z[i] + 1:z[i + 1]]:
			if _ <= d:
				a[i] += 1
			else:
				a[i + 1] += 1
	a[-1] += n + m - z[-1] - 1
print(' '.join(map(str, a)))


import math
(n, m) = map(int, input().split())
x = list(map(int, input().split()))
t = list(map(int, input().split()))
a = [0 for _ in range(m + 2)]
it = []
cur = -1
lst = -1
for i in range(n + m):
	if t[i] == 1:
		cur = i
		a[0] = cur
		break
for i in range(n + m):
	if t[i] == 1:
		lst = i
if cur == -1:
	for i in range(m):
		print(a[i], end=' ')
	print()
else:
	fst = cur
	for i in range(cur + 1, n + m):
		if t[i] == 1:
			it.append((x[i] + x[cur]) / 2)
			cur = i
	j = 0
	for i in range(fst + 1, n + m):
		if t[i] == 0:
			if j < len(it) and x[i] <= it[j]:
				a[j] += 1
			else:
				a[j + 1] += 1
		else:
			j += 1
	a[m - 1] += n + m - lst - 1
	for j in range(m):
		print(a[j], end=' ')
	print()


import sys
import string
from collections import Counter, defaultdict
from math import fsum, sqrt, gcd, ceil, factorial
from operator import *
from itertools import accumulate
inf = float('inf')
flush = lambda : sys.stdout.flush
comb = lambda x, y: factorial(x) // factorial(y) // factorial(x - y)
ip = lambda : input()
ii = lambda : int(input())
r = lambda : map(int, input().split())
rr = lambda : list(r())
(n, k) = r()
arr = [inf] + rr() + [inf]
brr = [1] + rr() + [1]
k += 2
taxi = []
for i in range(n + k):
	if brr[i]:
		taxi.append([i, arr[i]])
m = len(taxi)
if m == 1:
	print(n)
	exit()
ans = [0] * m
for i in range(m - 1):
	for j in range(taxi[i][0] + 1, taxi[i + 1][0]):
		x = abs(arr[j] - taxi[i][1])
		y = abs(arr[j] - taxi[i + 1][1])
		if x <= y:
			ans[i] += 1
		else:
			ans[i + 1] += 1
print(*ans[1:-1])


class Person:

	def __init__(self, x=0, is_taxman=False):
		self.x = x
		self.is_taxman = is_taxman
		self.count = 0
(a, b) = map(int, input().split())
city = [Person() for _ in range(a + b)]
c = 0
for i in input().split():
	city[c].x = int(i)
	c += 1
c = 0
for i in input().split():
	city[c].is_taxman = i == '1'
	c += 1
taxmans = []
for person in city:
	if person.is_taxman:
		taxmans.append(person)
right_taxman = None
left_taxman = None
c = 0
if len(taxmans) > 1:
	right_taxman = taxmans[1]
	left_taxman = taxmans[0]
	c = 1
else:
	right_taxman = taxmans[0]
for person in city:
	if person == right_taxman:
		c += 1
		left_taxman = right_taxman
		if c < len(taxmans):
			right_taxman = taxmans[c]
		else:
			right_taxman = None
		continue
	if person == left_taxman:
		continue
	if left_taxman:
		if right_taxman:
			if person.x - left_taxman.x == right_taxman.x - person.x:
				left_taxman.count += 1
			elif person.x - left_taxman.x < right_taxman.x - person.x:
				left_taxman.count += 1
			else:
				right_taxman.count += 1
		else:
			left_taxman.count += 1
	else:
		right_taxman.count += 1
for i in taxmans:
	print(i.count, end=' ')


from collections import defaultdict
(n, m) = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
is_taxi = [bool(int(i) == 1) for i in input().split()]
middles = []
result = []
prev = None
for (item, flag) in zip(x, is_taxi):
	if flag == True and prev != None:
		middles.append((item + prev) / 2)
	if flag == True:
		prev = item
cur_counter = -1
normals = 0
result.append(0)
for (item, flag) in zip(x, is_taxi):
	if cur_counter < 0 or cur_counter >= len(middles):
		if flag == False:
			result[-1] += 1
		else:
			cur_counter += 1
		continue
	if item > middles[cur_counter]:
		result.append(0)
		cur_counter += 1
	if flag == False:
		result[-1] += 1
print(' '.join([str(x) for x in result]))


(n, m) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
t = [int(x) for x in input().split()]
avg = []
r = -1
s = -1
count = 0
if m == 1:
	print(n)
else:
	for i in range(n + m):
		if t[i] == 1 and s == -1:
			s = a[i]
		elif t[i] == 1 and s != -1:
			r = s
			s = a[i]
			avg.append((r + s) / 2)
	p = 0
	for j in range(n + m):
		if a[j] <= avg[p] and t[j] == 0:
			count += 1
		elif a[j] > avg[p]:
			if p == len(avg) - 1:
				print(count, end=' ')
				print(n + m - j - 1)
				break
			print(count, end=' ')
			if t[j] == 0:
				count = 1
			else:
				count = 0
			p += 1


import math
from collections import deque, defaultdict
from sys import stdin, stdout
input = stdin.readline
listin = lambda : list(map(int, input().split()))
mapin = lambda : map(int, input().split())
(n, m) = mapin()
x = listin()
t = listin()
pas = []
driv = []
for i in range(n + m):
	if t[i]:
		driv.append(x[i])
	else:
		pas.append(x[i])
j = 0
count = [0] * m
for i in pas:
	while j < m - 1:
		if i - driv[j] > driv[j + 1] - i:
			j += 1
		else:
			break
	count[j] += 1
print(*count)


d = sum(map(int, input().split()))
mas = list(map(int, input().split()))
mas.sort()
y = input().split()
(col, rez, r, l, x) = ({}, {}, {}, {}, {})
x[0] = -2000000000
for i in range(1, d + 1):
	col[i] = int(y[i - 1])
	rez[i] = 0
	x[i] = mas[i - 1]
l[0] = 0
r[d + 1] = d + 1
x[d + 1] = 2000000000
for i in range(1, d + 1):
	if col[i] == 1:
		l[i] = i
	else:
		l[i] = l[i - 1]
for i in range(d, 0, -1):
	if col[i] == 1:
		r[i] = i
	else:
		r[i] = r[i + 1]
for i in range(1, d + 1):
	if col[i] == 0:
		if x[r[i]] - x[i] < x[i] - x[l[i]]:
			rez[r[i]] += 1
		else:
			rez[l[i]] += 1
for i in range(1, d + 1):
	if col[i] == 1:
		print(rez[i], end=' ')


(n, m) = [*map(int, input().split())]
places = [*map(int, input().split())]
peoples = [*map(int, input().split())]
rider = []
people = []
ans = [0 for x in range(m)]
index_rider = 0
index_people = 0
for i in range(n + m):
	if peoples[i] == 1:
		rider.append(places[i])
	else:
		people.append(places[i])
len_rider = len(rider)
while True:
	if index_rider == len_rider - 1:
		ans[index_rider] = n
		break
	if n == 0:
		break
	diff1 = abs(rider[index_rider] - people[index_people])
	diff2 = abs(people[index_people] - rider[index_rider + 1])
	if diff1 <= diff2:
		ans[index_rider] += 1
		index_people += 1
		n -= 1
	else:
		index_rider += 1
for val in ans:
	print(val)


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
t = list(map(int, input().split()))
prv = [-1 for i in range(n + m)]
nxt = [-1 for i in range(n + m)]
number = [0 for i in range(n + m)]
last = -1
for i in range(n + m):
	if t[i]:
		last = i
	prv[i] = last
last = -1
for i in range(n + m - 1, -1, -1):
	if t[i]:
		last = i
	nxt[i] = last
count = 0
for i in range(n + m):
	if t[i]:
		number[i] = count
		count += 1
res = [0 for i in range(m)]
for i in range(n + m):
	if not t[i]:
		if nxt[i] == -1:
			res[number[prv[i]]] += 1
		elif prv[i] == -1:
			res[number[nxt[i]]] += 1
		elif x[nxt[i]] - x[i] < x[i] - x[prv[i]]:
			res[number[nxt[i]]] += 1
		else:
			res[number[prv[i]]] += 1
print(' '.join(map(str, res)))


import os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
from collections import Counter
(n, m) = list(map(int, input().split()))
x = list(map(int, input().split()))
t = list(map(int, input().split()))
a = [0] * (n + m)
l = t.index(1)
r = n + m - 1 - t[::-1].index(1)
for i in range(n + m - 1, r - 1, -1):
	a[i] = r
for i in range(l + 1):
	a[i] = l
prevl = l
for i in range(l + 1, r):
	if t[i] == 0:
		a[i] = prevl
	else:
		a[i] = i
		prevl = i
prevr = r
for i in range(r - 1, l, -1):
	if t[i] == 0:
		if x[prevr] - x[i] < x[i] - x[a[i]]:
			a[i] = prevr
	else:
		prevr = i
out = Counter([a[i] for i in range(n + m) if t[i] == 0])
d = [i for i in range(n + m) if t[i] == 1]
output = []
for i in d:
	if i in out:
		output.append(out[i])
	else:
		output.append(0)
print(*output)


(a, b) = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]
d = [int(x) for x in input().split()]
drivers = [0] * b
current_driver_index = -1
position_of_previous = -1
for i in range(a + b):
	if d[i] == 1:
		current_driver_index = current_driver_index + 1
		if position_of_previous == -1:
			drivers[current_driver_index] = i
			position_of_previous = i
		else:
			p_driver = c[position_of_previous]
			c_driver = c[i]
			for j in range(position_of_previous + 1, i):
				if c[j] - p_driver <= c_driver - c[j]:
					drivers[current_driver_index - 1] = drivers[current_driver_index - 1] + 1
				else:
					drivers[current_driver_index] = drivers[current_driver_index] + 1
			position_of_previous = i
	elif i == a + b - 1:
		drivers[current_driver_index] += i - position_of_previous
print(*drivers, sep=' ')


(n, m) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
taxi = []
pesh = []
counter = {}
for i in range(n + m):
	if b[i] == 1:
		taxi.append(a[i])
	else:
		pesh.append(a[i])
i = 0
for item in taxi:
	counter[item] = 0
taxi.append(10 ** 100)
for item in pesh:
	while i < m - 1 and item > (taxi[i] + taxi[i + 1]) / 2:
		i += 1
	counter[taxi[i]] += 1
tot = []
for i in range(len(taxi) - 1):
	tot.append(counter[taxi[i]])
print(*tot)


(n, m) = map(int, input().split())
a = []
b = []
car = []
for i in map(int, input().split()):
	a.append(i)
j = 0
for i in map(int, input().split()):
	b.append(i)
	if b[-1] == 1:
		car.append(a[j])
	j += 1
j = 0
t = 0
ans = [0 for i in range(n + m)]
for i in range(n + m):
	if b[i] == 1:
		t = i + 1
		break
	ans[0] += 1
for i in range(t, n + m):
	if b[i] == 1:
		j += 1
		continue
	if j + 1 < m:
		if abs(a[i] - car[j]) <= abs(a[i] - car[j + 1]):
			ans[j] += 1
		else:
			ans[j + 1] += 1
	else:
		ans[j] += 1
for i in range(m - 1):
	print(ans[i], end=' ')
print(ans[m - 1])


(n, m) = map(int, input().split())
xs = list(map(int, input().split()))
ts = list(map(int, input().split()))
humans = []
taxis = []
for (x, t) in zip(xs, ts):
	if t == 0:
		humans.append(x)
	else:
		taxis.append(x)
ans = [0 for _ in taxis]
for x in humans:
	lo = 0
	hi = len(taxis) - 1
	if taxis[lo] > x:
		ans[0] += 1
		continue
	while lo + 1 < hi:
		mid = lo + hi >> 1
		if taxis[mid] <= x:
			lo = mid
		else:
			hi = mid
	if x - taxis[lo] <= taxis[hi] - x:
		ans[lo] += 1
	else:
		ans[hi] += 1
print(' '.join((str(x) for x in ans)))


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
t = list(map(int, input().split()))
lr = [[-1, -1] for i in range(n + m)]
now = -1
ans = [0] * (n + m)
txindex = []
for i in range(n + m):
	if t[i] == 0:
		lr[i][0] = now
	else:
		txindex.append(i)
		now = i
now = -1
for i in range(n + m - 1, -1, -1):
	if t[i] == 0:
		lr[i][1] = now
	else:
		now = i
for i in range(m + n):
	if t[i] == 0:
		left = lr[i][0]
		right = lr[i][1]
		if left >= 0:
			if right >= 0:
				p1 = x[i] - x[left]
				p2 = x[right] - x[i]
				if p1 <= p2:
					ans[left] += 1
				else:
					ans[right] += 1
			else:
				ans[left] += 1
		else:
			ans[right] += 1
for i in txindex:
	print(ans[i], end=' ')


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
(taxer, runer) = ([], [])
if m == 1:
	print(n)
	exit()
for i in range(n + m):
	if b[i] == 1:
		taxer.append(a[i])
	else:
		runer.append(a[i])
ans = [0] * m
i = 0
for men in runer:
	while i < m - 1 and men > (taxer[i] + taxer[i + 1]) / 2:
		i += 1
	ans[i] += 1
print(*ans)


s = input('').split()
n = int(s[0])
m = int(s[1])
coordinates = input('').split()
for i in range(0, m + n):
	coordinates[i] = int(coordinates[i])
taxid = input('')
taxiplaces = []
for i in range(0, m + n):
	if taxid[2 * i] == '1':
		taxiplaces.append(i)
ans = [0] * m
for i in range(0, m - 1):
	avg = (coordinates[taxiplaces[i]] + coordinates[taxiplaces[i + 1]]) / 2
	j = 0
	while coordinates[taxiplaces[i] + j] <= avg:
		j += 1
	ans[i] += j - 1
	ans[i + 1] += taxiplaces[i + 1] - taxiplaces[i] - j
ans[0] += taxiplaces[0]
ans[m - 1] += m + n - taxiplaces[m - 1] - 1
string = ''
for i in ans:
	string = string + str(i) + ' '
print(string)