<image>

William is hosting a party for n of his trader friends. They started a discussion on various currencies they trade, but there's an issue: not all of his trader friends like every currency. They like some currencies, but not others.

For each William's friend i it is known whether he likes currency j. There are m currencies in total. It is also known that a trader may not like more than p currencies.

Because friends need to have some common topic for discussions they need to find the largest by cardinality (possibly empty) subset of currencies, such that there are at least ⌈ n/2 ⌉ friends (rounded up) who like each currency in this subset.

Input

The first line contains three integers n, m and p (1 ≤ n ≤ 2 ⋅ 10^5, 1 ≤ p ≤ m ≤ 60, 1 ≤ p ≤ 15), which is the number of trader friends, the number of currencies, the maximum number of currencies each friend can like.

Each of the next n lines contain m characters. The j-th character of i-th line is 1 if friend i likes the currency j and 0 otherwise. It is guaranteed that the number of ones in each line does not exceed p.

Output

Print a string of length m, which defines the subset of currencies of the maximum size, which are liked by at least half of all friends. Currencies belonging to this subset must be signified by the character 1.

If there are multiple answers, print any.

Examples

Input


3 4 3
1000
0110
1001


Output


1000


Input


5 5 4
11001
10101
10010
01110
11011


Output


10001

Note

In the first sample test case only the first currency is liked by at least ⌈ 3/2 ⌉ = 2 friends, therefore it's easy to demonstrate that a better answer cannot be found.

In the second sample test case the answer includes 2 currencies and will be liked by friends 1, 2, and 5. For this test case there are other currencies that are liked by at least half of the friends, but using them we cannot achieve a larger subset size.

Source: codeforces | Difficulty: VERY_HARD
Tags: Dynamic programming

Bit manipulation

Complete search

Probability


Solutions:
import os
import sys
from io import BytesIO, IOBase

def main():

	def popCount(a):
		cnt = 0
		for i in range(60):
			if a & 1 << i:
				cnt += 1
		return cnt
	(n, m, p) = map(int, input().split())
	person = []
	for _ in range(n):
		person.append(int(input(), base=2))
	base = 0
	for i in range(m):
		cnt = 0
		for j in range(n):
			if person[j] & 1 << i:
				cnt += 1
		if cnt >= (n + 1) // 2:
			base |= 1 << i
	for i in range(n):
		person[i] &= base
	person.sort(reverse=True)
	keys = []
	cnt = {}
	for elem in person:
		if elem in cnt:
			cnt[elem] += 1
		else:
			cnt[elem] = 1
			keys.append(elem)
	for b in range(60):
		if base & 1 << b == 0:
			continue
		toAdd = []
		toAddVal = []
		for key in cnt:
			if key & 1 << b:
				if key ^ 1 << b in cnt:
					cnt[key ^ 1 << b] += cnt[key]
				else:
					toAdd.append(key ^ 1 << b)
					toAddVal.append(cnt[key])
		for i in range(len(toAdd)):
			cnt[toAdd[i]] = toAddVal[i]
	maxAns = 0
	for key in cnt:
		if cnt[key] < (n + 1) // 2:
			continue
		if popCount(maxAns) < popCount(key):
			maxAns = key
	print('0' * (m - len(bin(maxAns)) + 2) + bin(maxAns)[2:])
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')
main()


import sys
import bisect
from bisect import bisect_left as lb
input_ = lambda : sys.stdin.readline().strip('\r\n')
from math import log
from math import gcd
from math import atan2, acos
from random import randint
sa = lambda : input_()
sb = lambda : int(input_())
sc = lambda : input_().split()
sd = lambda : list(map(int, input_().split()))
sflo = lambda : list(map(float, input_().split()))
se = lambda : float(input_())
sf = lambda : list(input_())
flsh = lambda : sys.stdout.flush()
mod = 10 ** 9 + 7
mod1 = 998244353
gp = []
cost = []
dp = []
mx = []
ans1 = []
ans2 = []
special = []
specnode = []
a = 0
kthpar = []

def dfs(root, par):
	if par != -1:
		dp[root] = dp[par] + 1
	for i in range(1, 20):
		if kthpar[root][i - 1] != -1:
			kthpar[root][i] = kthpar[kthpar[root][i - 1]][i - 1]
	for child in gp[root]:
		if child == par:
			continue
		kthpar[child][0] = root
		dfs(child, root)
ans = 0
b = []

def hnbhai(tc):
	(n, m, p) = sd()
	a = []
	for i in range(n):
		a.append(sa())
	ans = ''
	mx = -1
	for _ in range(40):
		ind = randint(0, 10 ** 6) % n
		pos = []
		num = 0
		cnt = 0
		for i in range(m):
			if a[ind][i] == '1':
				pos.append(i)
				num |= 1 << i
				cnt += 1
		dp = [0] * (1 << cnt)
		for i in a:
			nn = 0
			for j in range(len(pos)):
				if i[pos[j]] == '1':
					nn |= 1 << j
			dp[nn] += 1
		for i in range(len(pos)):
			for j in range(1 << cnt):
				if j >> i & 1:
					dp[j ^ 1 << i] += dp[j]
		for i in range(1 << cnt):
			if 2 * dp[i] >= n and bin(i)[2:].count('1') > mx:
				temp = ['0'] * m
				for j in range(len(pos)):
					if i >> j & 1:
						temp[pos[j]] = '1'
				mx = bin(i)[2:].count('1')
				ans = ''.join(temp)
	print(ans)
for _ in range(1):
	hnbhai(_ + 1)


import sys
input = sys.stdin.readline
from random import shuffle
(n, m, p) = map(int, input().split())
A = [input()[:-1] for _ in range(n)]
order = list(range(n))
shuffle(order)
best = 0
sub = '0' * m
for it in range(min(n, 10)):
	x = order[it]
	bits = [j for j in range(m) if A[x][j] == '1']
	sz = len(bits)
	cnt = [0] * (1 << sz)
	for i in range(n):
		cur = sum((1 << j for j in range(sz) if A[i][bits[j]] == '1'))
		cnt[cur] += 1
	for i in range(sz):
		for mask in range(1 << sz):
			if mask & 1 << i:
				cnt[mask ^ 1 << i] += cnt[mask]
	for mask in range(1 << sz):
		if 2 * cnt[mask] >= n and bin(mask).count('1') > best:
			best = bin(mask).count('1')
			sub = ['0'] * m
			for i in range(sz):
				if mask >> i & 1:
					sub[bits[i]] = '1'
			sub = ''.join(sub)
print(sub)


import random
from math import ceil
import os
import sys
from io import BytesIO, IOBase
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')
(n, m, p) = map(int, input().split())
A = []
for _ in range(n):
	A.append(input())
num_iter = 20
mx_bit_cnt = 0
ans = None

def solve(i):
	global n, m, p, mx_bit_cnt, ans
	I = [idx for idx in range(m) if A[i][idx] == '1']
	L = len(I)
	C = [0] * (1 << L)
	for j in range(n):
		cur = 0
		for l in range(L):
			if A[j][I[l]] == '1':
				cur += 1 << l
		C[cur] += 1
	for i in range(L):
		for mask in range((1 << L) - 1, -1, -1):
			if mask & 1 << i:
				C[mask ^ 1 << i] += C[mask]
	for mask in range(1 << L):
		bit_cnt = bin(mask).count('1')
		if C[mask] < ceil(n / 2):
			continue
		if bit_cnt >= mx_bit_cnt:
			mx_bit_cnt = bit_cnt
			temp = ['0'] * m
			for l in range(L):
				if mask & 1 << l:
					temp[I[l]] = '1'
			ans = ''.join(temp)
while num_iter:
	num_iter -= 1
	i = random.randint(0, n - 1)
	solve(i)
print(ans)


import random
from collections import defaultdict
import math
import os
import sys
from io import BytesIO, IOBase
from types import GeneratorType
from collections import defaultdict
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')
(n, m, p) = map(int, input().split())
b = []
for j in range(n):
	s = input()
	c = []
	for j in s:
		c.append(int(j))
	b.append(c)
tot = 0
ans = ['0' for i in range(m)]
atleast = math.ceil(n / 2)
for i in range(10):
	ind = random.randint(-10 ** 18, 10 ** 18) % n
	req = b[ind]
	d1 = []
	d = defaultdict(lambda : 0)
	l = 0
	for j in range(m):
		if req[j] == 1:
			d[l] = j
			d1.append(j)
			l += 1
	ma = 1 << l
	cnt = [0 for i in range(ma)]
	for j in range(n):
		req = 0
		c = 0
		for k in d1:
			if b[j][k] == 1:
				req += 1 << c
			c += 1
		cnt[req] += 1
	for i in range(l):
		for mask in range(ma):
			if mask & 1 << i:
				cnt[mask ^ 1 << i] += cnt[mask]
	for mask in range(ma):
		if cnt[mask] >= atleast:
			req = ['0' for k in range(m)]
			total = 0
			for u in range(16):
				if mask & 1 << u:
					req[d[u]] = '1'
					total += 1
			if total > tot:
				tot = total
				ans = req
print(''.join(ans))


import random
import sys
from sys import stdin

def popcnt(x):
	ret = 0
	while x > 0:
		ret += x % 2
		x //= 2
	return ret
(n, m, p) = map(int, stdin.readline().split())
s = [stdin.readline()[:-1] for i in range(n)]
ans = 0
anslis = ['0'] * m
for loop in range(8):
	v = random.randint(0, n - 1)
	vbits = []
	for i in range(m):
		if s[v][i] == '1':
			vbits.append(i)
	dp = [0] * 2 ** len(vbits)
	vbits.reverse()
	for i in range(n):
		now = 0
		for j in vbits:
			now *= 2
			if s[i][j] == '1':
				now += 1
		dp[now] += 1
	vbits.reverse()
	for j in range(len(vbits)):
		for i in range(len(dp)):
			if i & 2 ** j == 0:
				dp[i] += dp[i | 2 ** j]
	for i in range(len(dp)):
		if dp[i] >= (n + 1) // 2:
			pc = popcnt(i)
			if ans < pc:
				ans = pc
				anslis = [0] * m
				for j in range(len(vbits)):
					if 2 ** j & i > 0:
						anslis[vbits[j]] = 1
print(''.join(map(str, anslis)))