You are given two arrays of integers a and b. For each element of the second array b_{j} you should find the number of elements in array a that are less than or equal to the value b_{j}.


-----Input-----

The first line contains two integers n, m (1 ≤ n, m ≤ 2·10^5) — the sizes of arrays a and b.

The second line contains n integers — the elements of array a ( - 10^9 ≤ a_{i} ≤ 10^9).

The third line contains m integers — the elements of array b ( - 10^9 ≤ b_{j} ≤ 10^9).


-----Output-----

Print m integers, separated by spaces: the j-th of which is equal to the number of such elements in array a that are less than or equal to the value b_{j}.


-----Examples-----
Input
5 4
1 3 5 7 9
6 4 2 8

Output
3 2 1 4

Input
5 5
1 2 1 2 5
3 1 4 1 5

Output
4 2 4 2 5

Difficulty: interview

Starter code:

Solutions:
#!/usr/bin/env python3

from bisect import bisect

try:
    while True:
        n, m = map(int, input().split())
        a = list(map(int, input().split()))
        a.sort()
        for x in map(int, input().split()):
            print(bisect(a, x), end=' ')
        print()

except EOFError:
    pass


def bin_search(k):
    l = -1
    r = n-1
    while (r - l > 1):
        h = (l+r) // 2
        if (lst1[h] > k):
            r = h
        else:
            l = h
    if lst1[r] <= k:
        return r+1
    else:
        return r
        
n, m  = [int(x) for x in input().split()]
lst1 = [int(x) for x in input().split()]
lst2 = [int(x) for x in input().split()]
lst1.sort()
for i in range(m):
    print(bin_search(lst2[i]), end = ' ')


a, b = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))
a.sort()
bp = [[b[i], i, 0] for i in range(len(b))]
bp.sort()
a.append(10**15)
ptr = 0
cum = 0
ind = 0;
while ptr < len(a) and ind < len(bp):
    while (bp[ind][0] >= a[ptr]):
        ptr+=1
    bp[ind][2] = ptr
    ind += 1
bp.sort(key = lambda x:x[1])
for i in bp:
    print(i[2], end = ' ')


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()]
resb = dict()
sa = sorted(a)
sb = sorted(b)
i = 0
j = 0
while j < len(sb):
	while i < len(sa) and sa[i] <= sb[j]:
		i += 1
	resb[sb[j]] = i
	j += 1
for i in b:
	print(resb[i], end=' ')


import bisect

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()]
a.sort()
for i in range(m):
    print(bisect.bisect_right(a, b[i]), end=" ")


import sys
#sys.stdin=open("data.txt")
input=sys.stdin.readline

n,m=map(int,input().split())

a=sorted(map(int,input().split()))

for q in map(int,input().split()):
    if q>=a[-1]:
        print(n,end=" ")
    else:
        low=0
        high=n
        while high-low:
            t=(low+high)//2
            if q>=a[t]:
                low=t+1
            else:
                high=t
        print(low,end=" ")


__author__ = 'sandeepmellacheruvu'
from bisect import bisect_right
n, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a.sort()
c = []
for (i, ele) in enumerate(b):
    p = bisect_right(a, ele)
    c.append(p)
for (i, ele) in enumerate(c):
    print(ele, end = " ")
print()

n, m = list(map(int, input().split(' ')))
a = list(sorted(map(int, input().split(' '))))
b = list(map(int, input().split(' ')))
c = sorted(set(b))

l = {}
j = 0
for i in c:
    while j < n and a[j] <= i:
        j += 1
    l[i] = j

s = []
for i in b:
    s.append(l[i])
print(' '.join(map(str, s)))



from math import ceil, modf
from bisect import bisect
n, m = [int(s) for s in input().split()]
a = [int(s) for s in input().split()]
a.sort()
for i in input().split():
    print(bisect(a, int(i)), end = " ")


n, m = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
b = [[int(i), 0] for i in input().split()]
for i in range(m):
    b[i][1] = i
a.sort()
b.sort(key = lambda x: x[0])
ress = [0] * m
i = j = 0
res = 0
while i < len(a) and j < len(b):
    if a[i] <= b[j][0]:
        res += 1
        i += 1
    else:
        ress[b[j][1]] = res
        j += 1
while j < len(b):
    ress[b[j][1]] = res
    j += 1
for i in ress:
    print(i, end = " ")
    


n, m = map(int, input().split())
a = sorted(list(map(int, input().split())))
origB = list(map(int, input().split()))
b = sorted(origB)
counts = {}
c = 0
i = 0
j = 0
while i < n and j < m:
    if a[i] <= b[j]:
        c = c + 1
        i = i + 1
    else:
        counts[b[j]] = c
        j = j + 1
        
while j < m:
    counts[b[j]] = c
    j = j + 1
    
for j in origB:
    print(counts[j], end=' ')


import bisect
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(" ")]

a = sorted(a)
max = a[n-1]
min = a[0]
res = []


for i in range(0,m):
	if b[i] >= max:
		b[i] = n
	else:
		b[i] = bisect.bisect_right(a, b[i])

print(" ".join([str(x) for x in b])) 




import bisect

def __starting_point():

    n , m = [int(x) for x in input().strip().split()]
    a = sorted([int(x) for x in input().strip().split()])
    b = [int(x) for x in input().strip().split()]

    res = []
    for bi in b:
        pos = bisect.bisect_left( a , bi)
        if pos < n and a[pos] == bi:
            res.append( bisect.bisect_right( a , bi ) )
        else:
            res.append( pos )

    print( " ".join([str(x) for x in res]) )

__starting_point()

n, mm = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a.sort()
for i in range(mm):
    b[i] = [b[i], i]
b.sort()
ans = ['0' for i in range(mm)]
last = -1
for i in b:
    l = last
    r = n
    while r - l > 1:
        m = (r + l) // 2
        if a[m] <= i[0]:
            l = m
        else:
            r = m
    last = l
    ans[i[1]] = str(l + 1)
print(' '.join(ans))


#!/usr/bin/env python3
# 600B_query.py - Codeforces.com/problemset/problem/600/B by Sergey 2015

import unittest
import sys

###############################################################################
# Query Class (Main Program)
###############################################################################


def rbound(v, n):
    b = 0
    e = len(v)
    while b != e:
        mid = (b + e + 1) // 2
        if v[mid - 1] <= n:
            b = mid
        else:
            e = mid - 1
    return b


class Query:
    """ Query representation """

    def __init__(self, test_inputs=None):
        """ Default constructor """

        it = iter(test_inputs.split("\n")) if test_inputs else None

        def uinput():
            return next(it) if it else sys.stdin.readline().rstrip()

        # Reading single elements
        [self.n, self.m] = list(map(int, uinput().split()))

        # Reading a single line of multiple elements
        self.numa = list(map(int, uinput().split()))
        self.numb = list(map(int, uinput().split()))

        self.snuma = sorted(self.numa)

    def calculate(self):
        """ Main calcualtion function of the class """

        result = []
        for n in self.numb:
            result.append(rbound(self.snuma, n))

        return str(" ".join(map(str, result)))

###############################################################################
# Unit Tests
###############################################################################


class unitTests(unittest.TestCase):

    def test_single_test(self):
        """ Query class testing """

        # Constructor test
        test = "5 4\n1 3 5 7 9\n6 4 2 8"
        d = Query(test)
        self.assertEqual(d.n, 5)
        self.assertEqual(d.m, 4)

        # Sample test
        self.assertEqual(Query(test).calculate(), "3 2 1 4")

        # Sample test
        test = "5 5\n1 2 1 2 5\n3 1 4 1 5"
        self.assertEqual(Query(test).calculate(), "4 2 4 2 5")

        # Sample test
        test = ""
        # self.assertEqual(Query(test).calculate(), "0")

        # My tests
        test = ""
        # self.assertEqual(Query(test).calculate(), "0")

        # Time limit test
        # self.time_limit_test(5000)

    def time_limit_test(self, nmax):
        """ Timelimit testing """
        import random
        import timeit

        # Random inputs
        test = str(nmax) + " " + str(nmax) + "\n"
        numnums = [str(i) + " " + str(i+1) for i in range(nmax)]
        test += "\n".join(numnums) + "\n"
        nums = [random.randint(1, 10000) for i in range(nmax)]
        test += " ".join(map(str, nums)) + "\n"

        # Run the test
        start = timeit.default_timer()
        d = Query(test)
        calc = timeit.default_timer()
        d.calculate()
        stop = timeit.default_timer()
        print(("\nTimelimit Test: " +
              "{0:.3f}s (init {1:.3f}s calc {2:.3f}s)".
              format(stop-start, calc-start, stop-calc)))

def __starting_point():

    # Avoiding recursion limitaions
    sys.setrecursionlimit(100000)

    if sys.argv[-1] == "-ut":
        unittest.main(argv=[" "])

    # Print the result string
    sys.stdout.write(Query().calculate())

__starting_point()

import bisect
n,m=map(int,input().split(' '))
a=list(map(int,input().split(' ')))
b=list(map(int,input().split(' ')))
a.sort()
ans=[]
for i in b:
    ans.append(bisect.bisect(a,i))
print(str(ans).replace('[', '').replace(']', '').replace(',', ''))

import bisect
n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a = sorted(a)
c = [bisect.bisect_right(a, i) for i in b]
print(' '.join(map(str, c)))


def main():
    input()
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    c = [(a[i], "a") for i in range(len(a))]
    c.extend([(b[i], "b") for i in range(len(b))])
    c.sort(key=lambda x: x[0])
    more_then = {}
    count = 0
    for i in range(len(c)):
        if c[i][1] == 'b':
            more_then[c[i][0]] = i - count
            count += 1
    ans = []
    for i in range(len(b)):
        ans.append(more_then[b[i]])
    print(" ".join(map(str, ans)))

def __starting_point():
    main()
__starting_point()

from bisect import bisect_right
import sys

class Scanner:

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

    def remaining_tokens(self):
        return len(self.current_tokens)

    def nextline(self):
        assert self.remaining_tokens() == 0, "Reading next line with remaining tokens"
        return input()

    def nexttokens(self):
        return self.nextline().split()
    
    def nexttoken(self):
        if len(self.current_tokens) == 0:
            self.current_tokens = self.nexttokens()
        assert self.remaining_tokens() > 0, "Not enough tokens to parse."
        return self.current_tokens.pop(0)

    def nextints(self, n=-1):
        if n == -1:
            return list(map(int, self.nexttokens()))
        else:
            return [self.nextint() for i in range(n)]
    
    def nextint(self):
        return int(self.nexttoken())

def quit():
    return

stdin = Scanner()
nextint = stdin.nextint
nextints = stdin.nextints
nextline = stdin.nextline

m, n = nextints()

a = nextints()
b = nextints()

res = []

a = sorted(a)

for i in b:
    res.append(str(bisect_right(a, i)))

print(" ".join(res))


import bisect
n, m = list(map(int,input().split()))
a = list(map(int,input().split()))
b = list(map(int,input().split()))
a.sort()
res = []
for i in range(m):
    res.append(bisect.bisect_right(a, b[i]))
print(' '.join(map(str,res)))


import bisect
n, m = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
a.sort()
res = []
for i in range(m):
    res.append(bisect.bisect_right(a, b[i]))
print(' '.join(map(str,res)))

"""
Codeforces Educational Round 2

Problem 600 B.

@author yamaton
@date 2015-11-30
"""

import bisect


def solve(xs, ys, n, m):
    xs.sort()
    return [bisect.bisect_right(xs, y) for y in ys]


def main():
    n, m = list(map(int, input().split()))
    xs = [int(c) for c in input().split()]
    ys = [int(c) for c in input().split()]
    assert len(xs) == n
    assert len(ys) == m
    result = solve(xs, ys, n, m)
    print(*result)


def __starting_point():
    main()

__starting_point()

import bisect

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

r = []
for bb in b:
	i = bisect.bisect_right(a, bb)
	r.append(str(i))

print(' '.join(r))