#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

int main()
{
	int n; cin>>n;

	if (n == 1)
	{
		cout<<1;
		exit(0);
	}
	else
	{
		vector<int> ans(n, -1);
		int i = 1;
		int count = 0;

		while (count < n - 1)
		{
			int I = -1, J = -1;

			for (int i = 0; i < n; i++)
			{
				if (ans[i] == -1)
				{
					if (I == -1)
						I = i;
					else
					{
						J = i;
						break;
					}
				}
			}

			int fir, sec;

			cout<<"? "<<(I + 1)<<" "<<(J + 1);
			cout.flush();
			cin>>fir;

			if (fir == -1)
				exit(0);

			cout<<"? "<<(J + 1)<<" "<<(I + 1);
			cout.flush();
			cin>>sec;

			if (sec == -1)
				exit(0);

			if (fir > sec)
				ans[I] = fir;
			else
				ans[J] = sec;

			count++;
		}

		for (int i = 0; i < n; i++)
		{
			if (ans[i] == -1)
			{
				ans[i] = n;
				break;
			}
		}

		cout<<"! ";
		for (int i = 0; i < n; i++)
		{
			cout<<ans[i]<<" ";
			exit(0);
		}
	}

	return 0;
}


#include <bits/stdc++.h>

#define int ll
typedef long long ll;
const int INF = 0x3f3f3f3f3f;
const int mod = 1e9 + 7;
const int maxn = 1e4 + 10;
const int N = 50;
using namespace std;

int a[maxn],vis[maxn]={0};

void solve() {
    int n;
    cin>>n;
    for (int i = 1; i<n; ++i) {
        int x,y;
        cout<<"? "<<i<<" "<<i+1<<endl;
//        cout.flush();
        cin>>x;
        cout<<"? "<<i+1<<" "<<i<<endl;
//        cout.flush();
        cin>>y;
        if (x>y) a[i]=x,vis[x]=1;
        else a[i+1]=y,vis[y]=1;
    }
    for(int i=1;i<=n;i++) if(!vis[i]) a[n]=i;
    cout<<"! ";
    for(int i=1;i<=n;i++) cout<<a[i]<<" ";
    cout<<endl;
}

signed main() {
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    int _ = 1;
    cin >> _;
    while (_--) {
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>

#define int ll
typedef long long ll;
const int INF = 0x3f3f3f3f3f;
const int mod = 1e9 + 7;
const int maxn = 1e4 + 10;
const int N = 50;
using namespace std;

int a[maxn],vis[maxn]={0};

void solve() {
    int n;
    cin>>n;
    int now=1;
    for (int i = 2; i<=n; ++i) {
        int x,y;
        cout<<"? "<<now<<" "<<i<<endl;
        cout.flush();
        cin>>x;
        cout<<"? "<<i<<" "<<now<<endl;
        cout.flush();
        cin>>y;
        if (x>y){
            a[now]=x,vis[x]=1,now=i;
        }
        else{
            a[i]=y,vis[y]=1;
        }
    }
    for(int i=1;i<=n;i++) if(!vis[i]) {a[now]=i;break;}
    cout<<"! ";
    for(int i=1;i<=n;i++) cout<<a[i]<<" ";
    cout<<endl;
}

signed main() {
    ios::sync_with_stdio(0);cin.tie(0),cout.tie(0);
    int _ = 1;
//    cin >> _;
    while (_--) {
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>

#define int ll
typedef long long ll;
const int INF = 0x3f3f3f3f3f;
const int mod = 1e9 + 7;
const int maxn = 1e4 + 10;
const int N = 50;
using namespace std;

int a[maxn],vis[maxn]={0};

void solve() {
    int n;
    cin>>n;
    int now=1;
    for (int i = 2; i<=n; ++i) {
        int x,y;
        cout<<"? "<<now<<" "<<i<<endl;
        cout.flush();
        cin>>x;
        cout<<"? "<<i<<" "<<now<<endl;
        cout.flush();
        cin>>y;
        if (x>y) a[now]=x,vis[x]=1,now=i;
        else a[i]=y,vis[y]=1;
    }
    for(int i=1;i<=n;i++) if(!vis[i]) {a[now]=i;break;}
    cout<<"! ";
    for(int i=1;i<=n;i++) cout<<a[i]<<" ";
    cout<<endl;
}

signed main() {
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int _ = 1;
    cin >> _;
    while (_--) {
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>

#define int ll
typedef long long ll;
const int INF = 0x3f3f3f3f3f;
const int mod = 1e9 + 7;
const int maxn = 1e4 + 10;
const int N = 50;
using namespace std;

int a[maxn],vis[maxn]={0};

void solve() {
    int n;
    cin>>n;
    int now=1;
    for (int i = 2; i<n; ++i) {
        int x,y;
        cout<<"? "<<now<<" "<<i+1<<endl;
        cout.flush();
        cin>>x;
        cout<<"? "<<i+1<<" "<<now<<endl;
        cout.flush();
        cin>>y;
        if (x>y) a[now]=x,vis[x]=1,now=i;
        else a[i+1]=y,vis[y]=1;
    }
    for(int i=1;i<=n;i++) if(!vis[i]) a[now]=i;
    cout<<"! ";
    for(int i=1;i<=n;i++) cout<<a[i]<<" ";
    cout<<endl;
}

signed main() {
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    int _ = 1;
    cin >> _;
    while (_--) {
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>

#define int ll
typedef long long ll;
const int INF = 0x3f3f3f3f3f;
const int mod = 1e9 + 7;
const int maxn = 1e4 + 10;
const int N = 50;
using namespace std;

int a[maxn],vis[maxn]={0};

void solve() {
    int n;
    cin>>n;
    for (int i = 1; i<n; ++i) {
        int x,y;
        cout<<"? "<<i<<i+1<<endl;
        cout.flush();
        cin>>x;
        cout<<"? "<<i+1<<i<<endl;
        cout.flush();
        cin>>y;
        if (x>y) a[i]=x,vis[x]=1;
        else a[i+1]=y,vis[y]=1;
    }
    for(int i=1;i<=n;i++) if(!vis[i]) a[n]=i;
    cout<<"! ";
    for(int i=1;i<=n;i++) cout<<a[i]<<" ";
    cout<<endl;
}

signed main() {
//    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    int _ = 1;
    cin >> _;
    while (_--) {
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int maxn = 1e4 + 5;
int vis[maxn] = {0};
int p[maxn];

void init() {

}

void solve() {
    int n;
    cin >> n;
    int now = 1;
    int a, b;
    for (int i = 2; i <= n; i++) {
        cout << "? " << now << " " << i << endl;
        cout.flush();
        cin >> a;
        cout << "? " << i << " " << now << endl;
        cout.flush();
        cin >> b;
        if (a > b) {
            p[now] = a;
            now = i;
            vis[a] = 1;
        } else {
            p[i] = b;
            vis[b] = 1;
        }
    }
    int flag;
    for (int i = 1; i <= n; i++) {
        if (!vis[i]) {
            flag = i;
            break;
        }
    }
    p[now] = flag;
    cout << "! ";
    for (int i = 1; i <= n; i++) {
        cout << p[i] << " ";
    }
    cout << endl;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int __ = 1;
    //cin>>__;
    while (__--) {
        //init();
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>

#define int ll
typedef long long ll;
const int INF = 0x3f3f3f3f3f;
const int mod = 1e9 + 7;
const int maxn = 1e4 + 10;
const int N = 50;
using namespace std;

int a[maxn],vis[maxn]={0};

void solve() {
    int n;
    cin>>n;
    for (int i = 1; i<n; ++i) {
        int x,y;
        cout<<"? "<<i<<i+1;
        cout.flush();
        cin>>x;
        cout<<"? "<<i+1<<i;
        cout.flush();
        cin>>y;
        if (x>y) a[i]=x,vis[x]=1;
        else a[i+1]=y,vis[y]=1;
    }
    for(int i=1;i<=n;i++) if(!vis[i]) a[n]=i;
    cout<<"! ";
    for(int i=1;i<=n;i++) cout<<a[i]<<" ";
    cout<<endl;
}

signed main() {
//    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    int _ = 1;
    cin >> _;
    while (_--) {
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>

#define int ll
typedef long long ll;
const int INF = 0x3f3f3f3f3f;
const int mod = 1e9 + 7;
const int maxn = 1e4 + 10;
const int N = 50;
using namespace std;

int a[maxn],vis[maxn]={0};

void solve() {
    int n;
    cin>>n;
    int now=1;
    for (int i = 2; i<=n; ++i) {
        int x,y;
        cout<<"? "<<now<<" "<<i<<endl;
        fflush(stdout);
        cin>>x;
        cout<<"? "<<i<<" "<<now<<endl;
        fflush(stdout);
        cin>>y;
        if (x>y){
            a[now]=x,vis[x]=1,now=i;
        }
        else{
            a[i]=y,vis[y]=1;
        }
    }
    for(int i=1;i<=n;i++) if(!vis[i]) {a[now]=i;break;}
    cout<<"! ";
    for(int i=1;i<=n;i++) cout<<a[i]<<" ";
    cout<<endl;
}

signed main() {
    ios::sync_with_stdio(0);cin.tie(0),cout.tie(0);
    int _ = 1;
    cin >> _;
    while (_--) {
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>

#define int ll
typedef long long ll;
const int INF = 0x3f3f3f3f3f;
const int mod = 1e9 + 7;
const int maxn = 1e4 + 10;
const int N = 50;
using namespace std;

int a[maxn],vis[maxn]={0};

void solve() {
    int n;
    cin>>n;
    int now=1;
    for (int i = 2; i<=n; ++i) {
        int x,y;
        cout<<"? "<<now<<" "<<i<<endl;
        cout.flush();
        cin>>x;
        cout<<"? "<<i<<" "<<now<<endl;
        cout.flush();
        cin>>y;
        if (x>y){
            a[now]=x,vis[x]=1,now=i;
        }
        else{
            a[i]=y,vis[y]=1;
        }
    }
    for(int i=1;i<=n;i++) if(!vis[i]) {a[now]=i;break;}
    cout<<"! ";
    for(int i=1;i<=n;i++) cout<<a[i]<<" ";
    cout<<endl;
}

signed main() {
    ios::sync_with_stdio(0);cin.tie(0),cout.tie(0);
    int _ = 1;
    cin >> _;
    while (_--) {
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>

#define int ll
typedef long long ll;
const int INF = 0x3f3f3f3f3f;
const int mod = 1e9 + 7;
const int maxn = 1e4 + 10;
const int N = 50;
using namespace std;

int a[maxn],vis[maxn]={0};

void solve() {
    int n,x,y,now=1;
    cin>>n;
    for (int i = 2; i<=n; ++i) {
        cout<<"? "<<now<<" "<<i<<endl,cout.flush(),cin>>x;
        cout<<"? "<<i<<" "<<now<<endl,cout.flush(),cin>>y;
        x>y?(a[now]=x,vis[x]=1,now=i):(a[i]=y,vis[y]=1);
    }
    for(int i=1;i<=n;i++) if(!vis[i]) a[now]=i;
    cout<<"! ";
    for(int i=1;i<=n;i++) cout<<a[i]<<" ";
    cout<<endl;
}

signed main() {
    ios::sync_with_stdio(0);cin.tie(0),cout.tie(0);
    int _ = 1;
//    cin >> _;
    while (_--) {
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>

#define int ll
typedef long long ll;
const int INF = 0x3f3f3f3f3f;
const int mod = 1e9 + 7;
const int maxn = 1e4 + 10;
const int N = 50;
using namespace std;

int a[maxn],vis[maxn]={0};

void solve() {
    int n;
    cin>>n;
    for (int i = 1; i<n; ++i) {
        int x,y;
        cout<<"? "<<i<<i+1;
        cout.flush();
        cin>>x;
        cout<<"? "<<i+1<<i;
        cout.flush();
        cin>>y;
        if (x>y) a[i]=x,vis[x]=1;
        else a[i+1]=y,vis[y]=1;
    }
    for(int i=1;i<=n;i++) if(!vis[i]) a[n]=i;
    cout<<"! ";
    for(int i=1;i<=n;i++) cout<<a[i]<<" ";
    cout<<endl;
}

signed main() {
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    int _ = 1;
    cin >> _;
    while (_--) {
        solve();
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
    ios::sync_with_stdio(!cin.tie(NULL));
    int n;
    cin>>n;
    int arr[n]={0},i=0,j=1;
    while(j<n && i<n)
    {
        int x,y;
        cout<<"?"<<" "<<i<<" "<<j;
        cin>>x;
        cout<<"?"<<" "<<j<<" "<<i;
        cin>>y;
        if(x>y)
        {
            arr[i]=x;
            i=j;
            j=i+1;
        }
        else
        {
            arr[j]=y;
            j++;
        }
    }
    cout<<"! ";
    for(int i=0;i<n;i++)
    {
        if(arr[i]==0)cout<<n<<" ";
        else cout<<arr[i]<<" ";

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define forn(i,n) for(int i=0;i<n;i++)
#define free(i,a,b) for(int i = a; i < b; i++)
#define sf(n) scanf("%lld", &n)
#define sff(a,b) scanf("%lld %lld", &a, &b)
#define sfff(a,b,c) scanf("%lld %lld %lld", &a, &b, &c)
#define pfn(n) printf("%lld\n", n)
#define pfs(n) printf("%lld ", n)
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define ll long long int
#define f find
#define ub upper_bound
#define lb lower_bound
#define ld long double
#define in insert
#define bs binary_search
#define le length()
const ll max_i=1e16+7;
#define np(s) next_permutation(s.begin(),s.end())
const int dx[]={1,0,-1,0,-1,1,1,-1};
const int dy[]={0,1,0,-1,-1,1,-1,1};
const char dir[]={'D','R','U','L'};
//it gives the lexicographically smallest string//
 int GCD(int a,int b)
    {
        if(b==0) return a;
        else return GCD(b,a%b);
    }

void solve()
{
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  int t=1;
  cin>>t;
  while(t--)
  {
    int n,temp=-1;
    map<int,vector<int>> m;
    cin>>n;
    int arr[n]={0};
    for(int i=0;i<n-1;i++)
    {
        int x,y;
        printf("? %d %d",i,i+1);
        fflush(stdout);
        scanf("%d",x)
        printf("? %d %d",i+1,i);
        fflush(stdout);
        scanf("%d",y);
        if(x>y)
        {
            arr[i]=x;
            m[i+1].pb(y);
        }
        else
        {
            arr[i+1]=y;
            m[i].pb(x);
        }
    }
    set<int> s;
    for(int i=0;i<n;i++)
    if(arr[i]==0) s.pb(arr[i]);
    for(int i=0;i<n;i++)
    {
        if(arr[i]==0)
        {
            if(m[i].size()==1)
            {
                for(auto itr=s.begin();itr!=s.end();itr++)
                {
                    if(i==0)
                    {
                        if(*itr%arr[i+1]==m[i][0])
                        {
                            arr[i]=*itr;
                            s.erase(itr);
                            itr--;
                            break;
                        }
                    }
                    else
                    {
                         if(*itr%arr[i-1]==m[i][0])
                        {
                            arr[i]=*itr;
                            s.erase(itr);
                            itr--;
                            break;
                        }
                    }
                }
            }
            else
            {
                 for(auto itr=s.begin();itr!=s.end();itr++)
                {
                    if(*itr%arr[i-1]==m[i][0] && *itr%arr[i+1]==m[i][1])
                    {
                            arr[i]=*itr;
                            s.erase(itr);
                            itr--;
                            break;
                    }
                }

            }
        }
    }
    cout<<"! ";
    for(int i=0;i<n;i++) cout<<arr[i]<<" ";
    cout<<endl;
  }
}
int main()
{
  #ifndef ONLINE_JUDGE
  freopen("input1.txt", "r",stdin);
  freopen("output1.txt","w",stdout);
  #endif
    solve();
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define forn(i,n) for(int i=0;i<n;i++)
#define free(i,a,b) for(int i = a; i < b; i++)
#define sf(n) scanf("%lld", &n)
#define sff(a,b) scanf("%lld %lld", &a, &b)
#define sfff(a,b,c) scanf("%lld %lld %lld", &a, &b, &c)
#define pfn(n) printf("%lld\n", n)
#define pfs(n) printf("%lld ", n)
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define ll long long int
#define f find
#define ub upper_bound
#define lb lower_bound
#define ld long double
#define in insert
#define bs binary_search
#define le length()
const ll max_i=1e16+7;
#define np(s) next_permutation(s.begin(),s.end())
const int dx[]={1,0,-1,0,-1,1,1,-1};
const int dy[]={0,1,0,-1,-1,1,-1,1};
const char dir[]={'D','R','U','L'};
//it gives the lexicographically smallest string//
 int GCD(int a,int b)
    {
        if(b==0) return a;
        else return GCD(b,a%b);
    }

void solve()
{
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  int t=1;
  cin>>t;
  while(t--)
  {
    int n,temp=-1;
    map<int,vector<int>> m;
    cin>>n;
    int arr[n]={0};
    for(int i=0;i<n-1;i++)
    {
        int x,y;
        cout<<"?"<<" "<<i<<" "<<i+1;
        fflush(stdout);
        scanf("%d",x)
        cout<<"?"<<" "<<i+1<<" "<<i;
        fflush(stdout);
        scanf("%d",y);
        if(x>y)
        {
            arr[i]=x;
            m[i+1].pb(y);
        }
        else
        {
            arr[i+1]=y;
            m[i].pb(x);
        }
    }
    set<int> s;
    for(int i=0;i<n;i++)
    if(arr[i]==0) s.insert(arr[i]);
    for(int i=0;i<n;i++)
    {
        if(arr[i]==0)
        {
            if(m[i].size()==1)
            {
                for(auto itr=s.begin();itr!=s.end();itr++)
                {
                    if(i==0)
                    {
                        if(*itr%arr[i+1]==m[i][0])
                        {
                            arr[i]=*itr;
                            s.erase(itr);
                            itr--;
                            break;
                        }
                    }
                    else
                    {
                         if(*itr%arr[i-1]==m[i][0])
                        {
                            arr[i]=*itr;
                            s.erase(itr);
                            itr--;
                            break;
                        }
                    }
                }
            }
            else
            {
                 for(auto itr=s.begin();itr!=s.end();itr++)
                {
                    if(*itr%arr[i-1]==m[i][0] && *itr%arr[i+1]==m[i][1])
                    {
                            arr[i]=*itr;
                            s.erase(itr);
                            itr--;
                            break;
                    }
                }

            }
        }
    }
    cout<<"! ";
    for(int i=0;i<n;i++) cout<<arr[i]<<" ";
    cout<<endl;
  }
}
int main()
{
  #ifndef ONLINE_JUDGE
  freopen("input1.txt", "r",stdin);
  freopen("output1.txt","w",stdout);
  #endif
    solve();
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
    ios::sync_with_stdio(!cin.tie(NULL));
    int n;
    cin>>n;
    int arr[n]={0},i=0,j=1;
    while(j<n && i<n)
    {
        int x,y;
        cout<<"?"<<" "<<i<<" "<<j<<endl;
        cin>>x;
        cout<<"?"<<" "<<j<<" "<<i<<endl;
        cin>>y;
        if(x>y)
        {
            arr[i]=x;
            i=j;
            j=i+1;
        }
        else
        {
            arr[j]=y;
            j++;
        }
    }
    cout<<"! ";
    for(int i=0;i<n;i++)
    {
        if(arr[i]==0)cout<<n<<" ";
        else cout<<arr[i]<<" ";
    }
    cout<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define forn(i,n) for(int i=0;i<n;i++)
#define free(i,a,b) for(int i = a; i < b; i++)
#define sf(n) scanf("%lld", &n)
#define sff(a,b) scanf("%lld %lld", &a, &b)
#define sfff(a,b,c) scanf("%lld %lld %lld", &a, &b, &c)
#define pfn(n) printf("%lld\n", n)
#define pfs(n) printf("%lld ", n)
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define ll long long int
#define f find
#define ub upper_bound
#define lb lower_bound
#define ld long double
#define in insert
#define bs binary_search
#define le length()
const ll max_i=1e16+7;
#define np(s) next_permutation(s.begin(),s.end())
const int dx[]={1,0,-1,0,-1,1,1,-1};
const int dy[]={0,1,0,-1,-1,1,-1,1};
const char dir[]={'D','R','U','L'};
//it gives the lexicographically smallest string//
 int GCD(int a,int b)
    {
        if(b==0) return a;
        else return GCD(b,a%b);
    }

void solve()
{
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  int t=1;
  cin>>t;
  while(t--)
  {
    int n,temp=-1;
    map<int,vector<int>> m;
    cin>>n;
    int arr[n]={0};
    for(int i=0;i<n-1;i++)
    {
        int x,y;
        cout<<"?"<<" "<<i<<" "<<i+1;
        fflush(stdout);
        scanf("%d",x);
        cout<<"?"<<" "<<i+1<<" "<<i;
        fflush(stdout);
        scanf("%d",y);
        if(x>y)
        {
            arr[i]=x;
            m[i+1].pb(y);
        }
        else
        {
            arr[i+1]=y;
            m[i].pb(x);
        }
    }
    set<int> s;
    for(int i=0;i<n;i++)
    if(arr[i]==0) s.insert(arr[i]);
    for(int i=0;i<n;i++)
    {
        if(arr[i]==0)
        {
            if(m[i].size()==1)
            {
                for(auto itr=s.begin();itr!=s.end();itr++)
                {
                    if(i==0)
                    {
                        if(*itr%arr[i+1]==m[i][0])
                        {
                            arr[i]=*itr;
                            s.erase(itr);
                            itr--;
                            break;
                        }
                    }
                    else
                    {
                         if(*itr%arr[i-1]==m[i][0])
                        {
                            arr[i]=*itr;
                            s.erase(itr);
                            itr--;
                            break;
                        }
                    }
                }
            }
            else
            {
                 for(auto itr=s.begin();itr!=s.end();itr++)
                {
                    if(*itr%arr[i-1]==m[i][0] && *itr%arr[i+1]==m[i][1])
                    {
                            arr[i]=*itr;
                            s.erase(itr);
                            itr--;
                            break;
                    }
                }

            }
        }
    }
    cout<<"! ";
    for(int i=0;i<n;i++) cout<<arr[i]<<" ";
    cout<<endl;
  }
}
int main()
{
  #ifndef ONLINE_JUDGE
  freopen("input1.txt", "r",stdin);
  freopen("output1.txt","w",stdout);
  #endif
    solve();
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
    ios::sync_with_stdio(!cin.tie(NULL));
    int n;
    cin>>n;
    int arr[n]={0},i=0,j=1;
    while(j<n && i<n)
    {
        int x,y;
        cout<<"?"<<" "<<i+1<<" "<<j+1<<endl;
        cin>>x;
        cout<<"?"<<" "<<j+1<<" "<<i+1<<endl;
        cin>>y;
        if(x>y)
        {
            arr[i]=x;
            i=j;
            j=i+1;
        }
        else
        {
            arr[j]=y;
            j++;
        }
    }
    cout<<"! ";
    for(int i=0;i<n;i++)
    {
        if(arr[i]==0)cout<<n<<" ";
        else cout<<arr[i]<<" ";
    }
    cout<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define forn(i,n) for(int i=0;i<n;i++)
#define free(i,a,b) for(int i = a; i < b; i++)
#define sf(n) scanf("%lld", &n)
#define sff(a,b) scanf("%lld %lld", &a, &b)
#define sfff(a,b,c) scanf("%lld %lld %lld", &a, &b, &c)
#define pfn(n) printf("%lld\n", n)
#define pfs(n) printf("%lld ", n)
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define ll long long int
#define f find
#define ub upper_bound
#define lb lower_bound
#define ld long double
#define in insert
#define bs binary_search
#define le length()
const ll max_i=1e16+7;
#define np(s) next_permutation(s.begin(),s.end())
const int dx[]={1,0,-1,0,-1,1,1,-1};
const int dy[]={0,1,0,-1,-1,1,-1,1};
const char dir[]={'D','R','U','L'};
//it gives the lexicographically smallest string//
 int GCD(int a,int b)
    {
        if(b==0) return a;
        else return GCD(b,a%b);
    }

void solve()
{
  ios::sync_with_stdio(!cin.tie(NULL));
  int t=1;
  //cin>>t;
  while(t--)
  {
    int n;
    cin>>n;
    int arr[n]={0},i=0,j=1;
    while(j<n && i<n)
    {
        int x,y;
        cout<<"?"<<" "<<i<<" "<<j;
        cin>>x;
        cout<<"?"<<" "<<j<<" "<<i;
        cin>>y;
        if(x>y)
        {
            arr[i]=x;
            i=j;
            j=i+1;
        }
        else
        {
            arr[j]=y;
            j++;
        }
    }
    cout<<"! ";
    for(int i=0;i<n;i++)
    {
        if(arr[i]==0)cout<<n<<" ";
        else cout<<arr[i]<<" ";
    }
  }
}
int main()
{
  #ifndef ONLINE_JUDGE
  freopen("input1.txt", "r",stdin);
  freopen("output1.txt","w",stdout);
  #endif
    solve();
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
    ios::sync_with_stdio(!cin.tie(NULL));
    int n;
    cin>>n;
    int arr[n]={0},i=0,j=1;
    while(j<n && i<n)
    {
        int x,y;
        cout<<"?"<<" "<<i<<" "<<j;
        cin>>x;
        cout<<"?"<<" "<<j<<" "<<i;
        cin>>y;
        if(x>y)
        {
            arr[i]=x;
            i=j;
            j=i+1;
        }
        else
        {
            arr[j]=y;
            j++;
        }
    }
    cout<<"! ";
    for(int i=0;i<n;i++)
    {
        if(arr[i]==0)cout<<n<<" ";
        else cout<<arr[i]<<" ";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define forn(i,n) for(int i=0;i<n;i++)
#define free(i,a,b) for(int i = a; i < b; i++)
#define sf(n) scanf("%lld", &n)
#define sff(a,b) scanf("%lld %lld", &a, &b)
#define sfff(a,b,c) scanf("%lld %lld %lld", &a, &b, &c)
#define pfn(n) printf("%lld\n", n)
#define pfs(n) printf("%lld ", n)
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define ll long long int
#define f find
#define ub upper_bound
#define lb lower_bound
#define ld long double
#define in insert
#define bs binary_search
#define le length()
const ll max_i=1e16+7;
#define np(s) next_permutation(s.begin(),s.end())
const int dx[]={1,0,-1,0,-1,1,1,-1};
const int dy[]={0,1,0,-1,-1,1,-1,1};
const char dir[]={'D','R','U','L'};
//it gives the lexicographically smallest string//
 int GCD(int a,int b)
    {
        if(b==0) return a;
        else return GCD(b,a%b);
    }

void solve()
{
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  int t=1;
  cin>>t;
  while(t--)
  {
    int n,temp=-1;
    map<int,vector<int>> m;
    cin>>n;
    int arr[n]={0};
    for(int i=0;i<n-1;i++)
    {
        int x,y;
        cout<<"?"<<" "<<i<<" "<<i+1;
        fflush(stdout);
        scanf("%d",x);
        cout<<"?"<<" "<<i+1<<" "<<i;
        fflush(stdout);
        scanf("%d",y);
        if(x>y)
        {
            arr[i]=x;
            m[i+1].pb(y);
        }
        else
        {
            arr[i+1]=y;
            m[i].pb(x);
        }
    }
    set<int> s;
    for(int i=0;i<n;i++)
    if(arr[i]==0) s.insert(arr[i]);
    for(int i=0;i<n;i++)
    {
        if(arr[i]==0)
        {
            if(m[i].size()==1)
            {
                for(auto itr=s.begin();itr!=s.end();itr++)
                {
                    if(i==0)
                    {
                        if(*itr%arr[i+1]==m[i][0])
                        {
                            arr[i]=*itr;
                            s.erase(itr);
                            itr--;
                            break;
                        }
                    }
                    else
                    {
                         if(*itr%arr[i-1]==m[i][0])
                        {
                            arr[i]=*itr;
                            s.erase(itr);
                            itr--;
                            break;
                        }
                    }
                }
            }
            else
            {
                 for(auto itr=s.begin();itr!=s.end();itr++)
                {
                    if(*itr%arr[i-1]==m[i][0] && *itr%arr[i+1]==m[i][1])
                    {
                            arr[i]=*itr;
                            s.erase(itr);
                            itr--;
                            break;
                    }
                }

            }
        }
    }
    cout<<"! ";
    for(int i=0;i<n;i++) cout<<arr[i]<<" ";
    cout<<endl;
    fflush(stdout);

  }
}
int main()
{
  #ifndef ONLINE_JUDGE
  freopen("input1.txt", "r",stdin);
  freopen("output1.txt","w",stdout);
  #endif
    solve();
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define ff first
#define ss second
#define vi vector<ll>
#define vii vector<vector<ll>>
#define vpi vector<pii>
#define mod 1000000007
#define MOD 1000000007
#define full(a) a.begin(),a.end()
#define inf INT_MAX
#define minf INT_MIN
#define dd double
#define fori(x,n) for(ll i=x;i<n;i++)
#define modd 998244353
#define umap unordered_map<ll,ll>
#define mmap map<ll,ll>
#define mm 100000000

int32_t main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    ll n;
    cin>>n;

    ll result[n];
    ll maxa = 0;

    fori(2,n+1){
      cout<<"? "<<i<<" 1";
      cout.flush();
      cin>>result[i-1];
      maxa = max(maxa,result[i-1]);
    }

    ll index[maxa]={0};
    ll p[n];
    p[0] = maxa;

    for(int i=2;i<=n;i++){
      ll res;
      cout<<"? 1 "<<i;
      cout.flush();
      cin>>res;
      p[i-1]=(index[res])*maxa + res;
      index[res]++;
    }

    cout<<"! ";

    fori(0,n){
      cout<<p[i]<<" ";
    }
    cout.flush();

return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define ff first
#define ss second
#define vi vector<ll>
#define vii vector<vector<ll>>
#define vpi vector<pii>
#define mod 1000000007
#define MOD 1000000007
#define full(a) a.begin(),a.end()
#define inf INT_MAX
#define minf INT_MIN
#define dd double
#define fori(x,n) for(ll i=x;i<n;i++)
#define modd 998244353
#define umap unordered_map<ll,ll>
#define mmap map<ll,ll>
#define mm 100000000

int32_t main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    ll n;
    cin>>n;

    ll result[n];
    ll maxa = 0;

    fori(2,n+1){
      cout<<"? "<<i<<" 1"<<endl;
      cout.flush();
      cin>>result[i-1];
      maxa = max(maxa,result[i-1]);
    }

    ll index[maxa]={0};
    ll p[n];
    p[0] = maxa;

    for(int i=2;i<=n;i++){
      ll res;
      cout<<"? 1 "<<i<<endl;
      cout.flush();
      cin>>res;
      p[i-1]=(index[res])*maxa + res;
      index[res]++;
    }

    fori(0,n){
      if(i==0)cout<<"! ";
      cout<<p[i]<<" ";
    }
    cout<<endl;
    cout.flush();

return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define ff first
#define ss second
#define vi vector<ll>
#define vii vector<vector<ll>>
#define vpi vector<pii>
#define mod 1000000007
#define MOD 1000000007
#define full(a) a.begin(),a.end()
#define inf INT_MAX
#define minf INT_MIN
#define dd double
#define fori(x,n) for(ll i=x;i<n;i++)
#define modd 998244353
#define umap unordered_map<ll,ll>
#define mmap map<ll,ll>
#define mm 100000000

int32_t main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    ll n;
    cin>>n;

    ll result[n];
    ll maxa = 0;

    fori(2,n+1){
      cout<<"? "<<i<<" 1";
      cout.flush()
      cin>>result[i-1];
      maxa = max(maxa,result[i-1]);
    }

    ll index[maxa]={0};
    ll p[n];
    p[0] = maxa;

    for(int i=2;i<=n;i++){
      ll res;
      cout<<"? 1 "<<i;
      cout.flush()
      cin>>res;
      p[i-1]=(index[res])*maxa + res;
      index[res]++;
    }

    cout<<"! ";

    fori(0,n){
      cout<<p[i]<<" ";
    }
    cout.flush();

return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define ff first
#define ss second
#define vi vector<ll>
#define vii vector<vector<ll>>
#define vpi vector<pii>
#define mod 1000000007
#define MOD 1000000007
#define full(a) a.begin(),a.end()
#define inf INT_MAX
#define minf INT_MIN
#define dd double
#define fori(x,n) for(ll i=x;i<n;i++)
#define modd 998244353
#define umap unordered_map<ll,ll>
#define mmap map<ll,ll>
#define mm 100000000

int32_t main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    ll n;
    cin>>n;

    ll result[n];
    ll maxa = 0;

    fori(2,n+1){
      cout<<"? "<<i<<" 1"<<endl;
      cout.flush();
      cin>>result[i-1];
      maxa = max(maxa,result[i-1]);
    }

    vi index(maxa,0);
    if(maxa==1){
      fori(0,n){
      if(i==0)cout<<"! ";
      cout<<i+1<<" ";}
      cout<<endl;
      cout.flush();
    }
    else{

    ll p[n];
    p[0] = maxa;
     index[0]=2;
    for(int i=2;i<=n;i++){
      ll res;
      cout<<"? 1 "<<i<<endl;
      cout.flush();
      cin>>res;

      p[i-1]=(index[res])*maxa + res;
      index[res]++;

    }

    fori(0,n){
      if(i==0)cout<<"! ";
      cout<<p[i]<<" ";
    }
    cout<<endl;
    cout.flush();

   }

return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define ff first
#define ss second
#define vi vector<ll>
#define vii vector<vector<ll>>
#define vpi vector<pii>
#define mod 1000000007
#define MOD 1000000007
#define full(a) a.begin(),a.end()
#define inf INT_MAX
#define minf INT_MIN
#define dd double
#define fori(x,n) for(ll i=x;i<n;i++)
#define modd 998244353
#define umap unordered_map<ll,ll>
#define mmap map<ll,ll>
#define mm 100000000

int32_t main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    ll n;
    cin>>n;

    ll result[n];
    ll maxa = 0;

    fori(2,n+1){
      cout<<"? "<<i<<" 1"<<endl;
      cout.flush();
      cin>>result[i-1];
      maxa = max(maxa,result[i-1]);
    }

    vi index(maxa,0);

    ll p[n];
    p[0] = maxa;
     index[0]=2;
    for(int i=2;i<=n;i++){
      ll res;
      cout<<"? 1 "<<i<<endl;
      cout.flush();
      cin>>res;

      p[i-1]=(index[res])*maxa + res;
      index[res]++;

    }

    fori(0,n){
      if(i==0)cout<<"! ";
      cout<<p[i]<<" ";
    }
    cout<<endl;
    cout.flush();

return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define ff first
#define ss second
#define vi vector<ll>
#define vii vector<vector<ll>>
#define vpi vector<pii>
#define mod 1000000007
#define MOD 1000000007
#define full(a) a.begin(),a.end()
#define inf INT_MAX
#define minf INT_MIN
#define dd double
#define fori(x,n) for(ll i=x;i<n;i++)
#define modd 998244353
#define umap unordered_map<ll,ll>
#define mmap map<ll,ll>
#define mm 100000000

ll ask(ll x,ll y){
  cout<<"? "<<x+1<<" "<<y+1<<endl;
  ll res;
  cin>>res;
  return res;
}

int32_t main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    ll n;
    cin>>n;

    ll mx = 0;

    vi ans(n,-1);

    fori(1,n){
      ll a = ask(mx,i);
      ll b = ask(i,mx);

      if(a>b){
        ans[mx]=a;
        mx=i;
      }
      else{
        ans[i]=b;
      }
    }

    ans[mx]=n;

    fori(0,n){
      if(i==0)cout<<"! ";
      cout<<ans[i]<<" ";
    }
    cout<<endl;
return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define ff first
#define ss second
#define vi vector<ll>
#define vii vector<vector<ll>>
#define vpi vector<pii>
#define mod 1000000007
#define MOD 1000000007
#define full(a) a.begin(),a.end()
#define inf INT_MAX
#define minf INT_MIN
#define dd double
#define fori(x,n) for(ll i=x;i<n;i++)
#define modd 998244353
#define umap unordered_map<ll,ll>
#define mmap map<ll,ll>
#define mm 100000000

int32_t main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    ll n;
    cin>>n;

    ll result[n];
    ll maxa = 0;

    fori(2,n+1){
      cout<<"? "<<i<<" 1"<<endl;
      cout.flush();
      cin>>result[i-1];
      maxa = max(maxa,result[i-1]);
    }

    vi index(maxa,0);
    if(maxa==1){
      fori(0,n){
      if(i==0)cout<<"! ";
      cout<<i+1<<" ";}
      cout<<endl;
      cout.flush();
      exit(0);
    }

    ll p[n];
    p[0] = maxa;
     index[0]=2;
    for(int i=2;i<=n;i++){
      ll res;
      cout<<"? 1 "<<i<<endl;
      cout.flush();
      cin>>res;

      p[i-1]=(index[res])*maxa + res;
      index[res]++;

    }

    fori(0,n){
      if(i==0)cout<<"! ";
      cout<<p[i]<<" ";
    }
    cout<<endl;
    cout.flush();

return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define ff first
#define ss second
#define vi vector<ll>
#define vii vector<vector<ll>>
#define vpi vector<pii>
#define mod 1000000007
#define MOD 1000000007
#define full(a) a.begin(),a.end()
#define inf INT_MAX
#define minf INT_MIN
#define dd double
#define fori(x,n) for(ll i=x;i<n;i++)
#define modd 998244353
#define umap unordered_map<ll,ll>
#define mmap map<ll,ll>
#define mm 100000000

int32_t main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    ll n;
    cin>>n;

    ll result[n];
    ll maxa = 0;

    fori(2,n+1){
      cout<<"? "<<i<<" 1"<<endl;
      cout.flush();
      cin>>result[i-1];
      maxa = max(maxa,result[i-1]);
    }

    vi index(maxa,0);
    if(maxa==1){
      fori(0,n){
      if(i==0)cout<<"! ";
      cout<<i+1<<" ";
      cout<<endl;
      cout.flush();
    }

    ll p[n];
    p[0] = maxa;
     index[0]=2;
    for(int i=2;i<=n;i++){
      ll res;
      cout<<"? 1 "<<i<<endl;
      cout.flush();
      cin>>res;

      p[i-1]=(index[res])*maxa + res;
      index[res]++;

    }

    fori(0,n){
      if(i==0)cout<<"! ";
      cout<<p[i]<<" ";
    }
    cout<<endl;
    cout.flush();

return 0;
}


import bisect

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

a = map(int, raw_input().split())
a.sort()
b = map(int, raw_input().split())

notas = []

for i in b:
  try:
    notas.append(str(bisect.bisect_right(a, i, 0, len(a))))
  except:
    notas = [0]

print " ".join(notas)


import bisect

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

a = map(int, raw_input().split())
a.sort()
b = map(int, raw_input().split())

notas = []

for i in b:
  notas.add(str(bisect.bisect_right(a, i, 1, len(a))))

print " ".join(notas)


r1=lambda:input()
r2=lambda:map(int,raw_input().split())
r3=lambda:list(map(int,raw_input().split()))
n,m=r2()
lst1=r3()
lst1.sort()
lst2=r3()
def bs(array, target):
    pv=0
    lower = 0
    upper = len(array)
    cn=0
    while cn<30:
        x = lower + (upper - lower) // 2
        val = array[x]

        if target >= val:
            if lower == x:
                break
            lower = x
        elif target < val:
            upper = x
        cn=cn+1
    return upper
for i in range(0,m):
  print bs(lst1,lst2[i]),


import bisect
n, m = map(int, raw_input().strip().split(' '))
a = map(int, raw_input().strip().split(' '))
b = map(int, raw_input().strip().split(' '))
a.sort()
result = []
for x in b:
    result.append(bisect.bisect(a, x))
print ' '.join(map(str, result))


import sys

[n, m] = map(lambda x: int(x), sys.stdin.next().split(' '))
a = map(lambda x: (int(x), 0, 0), sys.stdin.next().split(' '))
b = map(lambda x: (int(x[1]), 1, x[0]), enumerate(sys.stdin.next().split(' ')))

c = sorted(a + b)
solution = [0] * m

counter = 0
for i in range(n + m):
    if c[i][1] == 0:
        counter += 1
    else:
        solution[c[i][2]] = counter

print(' '.join(map(str, solution)))


import bisect as bi
n,m=map(int,raw_input().split())
a=map(int,raw_input().split())
b=map(int,raw_input().split())

a.sort()
for i in b:
    c=bi.bisect(a,i)
    print c


def binary(a,i,n):
    first=0
    p=0
    mid=0
    last=n-1
    if n==1:
        if a[0]<i:return 1
        else:return 0
    if i >= a[n-1]:return n
    elif i<a[0]:return 0
    while last<n and last>=0 and first<n and first>=0 and last>=first:
        mid=(first+last)/2
        if a[mid]>i:
            last=mid-1
        elif a[mid]<i:
            first=mid+1
        else:
            p=1
            mid=last=first
            break

    if p==0 and a[last]>i:mid=last-1
    if p==0 and a[first]>i:mid=first-1

    j=mid+1
    r=0
    while p==1 and j<n and a[j]==a[mid]:
        j+=1
        r+=1

    j=mid-1
    q=0
    while p==1 and j>0 and a[j]==a[mid]:
        j-=1
        p+=1

    return mid+1+r+q

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

a.sort()
for i in b:
    c=binary(a,i,n)
    print c


def binary(a,i,n):
    first=0
    p=0
    last=n-1
    if n==1:
        if a[0]<i:return 1
        else:return 0
    while last>=first and first>0 and first <n and last>0 and last<n:
        mid=(first+last)/2
        if a[mid]>i:
            last=mid-1
        elif a[mid]<i:
            first=mid+1
        else:
            p=1
            mid=last=first
            break

    if p==0 and a[last]>i:mid=last-1
    if p==0 and a[first]>i:mid=first-1

    j=mid+1
    r=0
    while p==1 and j<n and a[j]==a[mid]:
        j+=1
        r+=1

    j=mid-1
    q=0
    while p==1 and j>0 and a[j]==a[mid]:
        j-=1
        p+=1

    return mid+1+r+q

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

a.sort()
for i in b:
    c=binary(a,i,n)
    print c


def binary(a,i,n):
    first=0
    p=0
    last=n-1
    if n==1:
        if a[0]<i:return 1
        else:return 0
    while last>=first:
        mid=(first+last)/2
        if a[mid]>i:
            last=mid-1
        elif a[mid]<i:
            first=mid+1
        else:
            p=1
            mid=last=first
            break

    if p==0 and a[last]>i:mid=last-1
    if p==0 and a[first]>i:mid=first-1

    j=mid+1
    r=0
    while p==1 and j<n and a[j]==a[mid]:
        j+=1
        r+=1

    j=mid-1
    q=0
    while p==1 and j>0 and a[j]==a[mid]:
        j-=1
        p+=1

    return mid+1+r+q

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

a.sort()
for i in b:
    c=binary(a,i,n)
    print c


def binary(a,i,n):
    first=0
    p=0
    last=n-1
    while last>=first:
        mid=(first+last)/2
        if a[mid]>i:
            last=mid-1
        elif a[mid]<i:
            first=mid+1
        else:
            p=1
            mid=last=first
            break

    if p==0 and a[last]>i:mid=last-1
    if p==0 and a[first]>i:mid=first-1

    j=mid+1
    r=0
    while p==1 and j<n and a[j]==a[mid]:
        j+=1
        r+=1

    j=mid-1
    q=0
    while p==1 and j>0 and a[j]==a[mid]:
        j-=1
        p+=1

    return mid+1+r+q

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

a.sort()
for i in b:
    c=binary(a,i,n)
    print c


s = raw_input().split(" ")
m = int(s[0])
n = int(s[1])

f1 = map(int,raw_input().split(" "))
f2 = map(int, raw_input().split(" "))

a = []

for i in f2:
	a.append(i)

freq =[]

f1.sort()
f2.sort()

aux = []

for i in range(f2[-1]+1):
	freq.append(0)

for j in xrange(n):
	if j == n-1:
		if f2[j] !=  f2[j-1]:
				aux.append(f2[j]);
	else:
		if(f2[j] != f2[j+1]):
			aux.append(f2[j]);

i = 0
im= 0

while True:
	if(im > len(aux) or i > n-1):
			break

	if(aux[im] >= f1[i]):
			freq[aux[im]] += 1
			i+=1
			if(im == len(aux) -1):
				freq[aux[im]] += freq[aux[im-1]]

 	else:
		if(im != 0 and not(im==len(aux)-1)):
				freq[aux[im]] += freq[aux[im-1]]

		im+=1

		if(im > len(aux) or i > n-1):
			break

for y in a:
	print freq[y],


s = raw_input().split(" ")
m = int(s[0])
n = int(s[1])

f1 = map(int,raw_input().split(" "))
f2 = map(int, raw_input().split(" "))

f1.sort()
aux = sorted(set(f2))

i= 0
j =0
dic = {}

while True:
	if(j >= len(aux)):
		break

	if i == m:
		dic[aux[j]] = i

		j+=1
	else:
		if f1[i] > aux[j]:
			dic[aux[j]] = i
			j+=1
		else:
			i+=1

for x in f2:
	print dic[x],


import bisect

m, n = raw_input().split(' ')
l1 = map(int, raw_input().split(' '))
l2 = map(int, raw_input().split(' '))

l1.sort()

c = [0 for i in l2]
ind = 0
for j in l2:
    count = bisect.bisect_right(l1, j)
#     count=0
#     for i in l1:
#         if i<=j: count+=1
    c[ind] = count
    ind += 1

c = ' '.join(map(str, c))
print(c)


m,n = raw_input().split(' ')
l1 = map(int,raw_input().split(' '))
l2 = map(int,raw_input().split(' '))

c = [0 for i in l2]
ind=0
for j in l2:
    count=0
    for i in l1:
        if i<=j: count+=1
    c[ind]=count
    ind+=1

c = ' '.join(map(str, c))
print(c)


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

a = list(map(int, raw_input().split()))
b = list(map(int, raw_input().split()))

a.sort()
uva = list(b)
b.sort()

ia, ib = 0, 0

qntd = 0
dic = {}

while ia <= n and ib < m:
    if ia == n:
        dic[b[ib]] = qntd
        ib += 1
    elif b[ib] >= a[ia]:
        qntd += 1
        ia += 1
    else:
        dic[b[ib]] = qntd
        ib += 1

for i in xrange(m):
    print dic[uva[i]],
print


# questao: http://codeforces.com/problemset/problem/600/B
# coding: utf-8

ent1 = map(int, raw_input().split())
a_lista = map(int, raw_input().split())
b_lista = map(int, raw_input().split())

acumulador = {}
aux = 0

b_sorted = sorted(b_lista)
a_sorted = sorted(a_lista)

i = 0
j = 0

while (j < len(b_lista)):
    if (i < len(a_lista) and a_sorted[i] <= b_sorted[j]):
        aux += 1
        i += 1
    else:
        acumulador[b_sorted[j]] = aux
        j += 1

resposta = ""

for i in b_lista:
    resposta += str(acumulador[i]) + " "

resposta = resposta.strip()
print resposta


def getNextKey(elem, keys):
	keys.sort()
	for i in xrange(len(keys) - 1, -1, -1):
		if keys[i] < elem:
			return keys[i]
	return False
n, m = map(int, raw_input().split())
first_array = map(int, raw_input().split())
second_array = map(int, raw_input().split())
first_array.sort()

obj = {}
for i in xrange(len(first_array) - 1, -1, -1):
	if not obj.get(first_array[i]):
		obj[first_array[i]] = i + 1
out = ""
for i in xrange(len(second_array)):
	if i == len(second_array) - 1:
		if obj.get(second_array[i]):
			out += str(obj.get(second_array[i]))
		else:
			a = getNextKey(second_array[i], obj.keys())
			if a:
				out += str(obj.get(a))
			else:
				out += '0'
	else:
		if obj.get(second_array[i]):
			out += str(obj.get(second_array[i])) + " "
		else:
			a = getNextKey(second_array[i], obj.keys())
			if a:
				out += str(obj.get(a)) + " "
			else:
				out += '0 '
print out


def binary_search(array, integer, begin, end):
	if begin >= end:
		return False
	middle = (begin + end) / 2
	if array[middle] == integer:
		for i in xrange(middle + 1, end + 1):
			if array[i] == integer:
				middle = i
			else:
				break
		return middle
	elif array[middle] > integer:
		if begin == end - 1:
			return False
		return binary_search(array, integer, begin, middle)
	elif array[middle] < integer and array[middle + 1] > integer:
		return middle
	elif array[middle] < integer and array[middle + 1] != integer:
		if begin == end - 1:
			return end
		return binary_search(array, integer, middle, end)
	else:
		for i in xrange(middle + 1, end + 1):
			if array[i] == integer:
				middle = i
			else:
				break
		return middle

n, m = map(int, raw_input().split())
first_array = map(int, raw_input().split())
second_array = map(int, raw_input().split())
first_array.sort()

retorno = []

for i in second_array:
	qntd = binary_search(first_array, i, 0, len(first_array) - 1)
	if type(qntd) == int:
		retorno.append(qntd + 1)
	else:
		retorno.append(0)

out = ""
for i in xrange(len(retorno)):
	if i == len(retorno) - 1:
		out += str(retorno[i])
	else:
		out += str(retorno[i]) + " "

print out


n, m = map(int, raw_input().split())
first_array = map(int, raw_input().split())
second_array = map(int, raw_input().split())
first_array.sort()

obj = {}
for i in xrange(len(first_array) - 1, -1, -1):
	if not obj.get(first_array[i]):
		obj[first_array[i]] = i + 1
out = ""
maior = max(first_array)
menor = min(first_array)
for i in xrange(len(second_array)):
	if i == len(second_array) - 1:
		if obj.get(second_array[i]):
			out += str(obj.get(second_array[i]))
		else:
			if second_array[i] > maior:
				out += obj.get(maior)
			else:
				if second_array[i] < menor:
					out += '0'
				else:
					j = second_array[i]
					while not obj.get(j):
						j -= 1
					out += str(obj.get(j))
	else:
		if obj.get(second_array[i]):
			out += str(obj.get(second_array[i])) + " "
		else:
			if second_array[i] > maior:
				out += obj.get(maior) + " "
			else:
				if second_array[i] < menor:
					out += '0 '
				else:
					j = second_array[i]
					while not obj.get(j):
						j -= 1
					out += str(obj.get(j)) + " 		"
print out


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


def binary_search(array, integer, begin, end):
	if begin >= end:
		return False
	middle = (begin + end) / 2
	if array[middle] == integer:
		for i in xrange(middle + 1, end + 1):
			if array[i] == integer:
				middle = i
			else:
				break
		return middle
	elif array[middle] > integer:
		if begin == end - 1:
			return False
		return binary_search(array, integer, begin, middle)
	elif array[middle] < integer and array[middle + 1] > integer:
		return middle
	elif array[middle] < integer and array[middle + 1] != integer:
		if begin == end - 1:
			return end
		return binary_search(array, integer, middle, end)
	else:
		for i in xrange(middle + 1, end + 1):
			if array[i] == integer:
				middle = i
			else:
				break
		return middle

n, m = map(int, raw_input().split())
first_array = map(int, raw_input().split())
second_array = map(int, raw_input().split())
first_array.sort()

retorno = []

for i in second_array:
	qntd = binary_search(first_array, i, 0, len(first_array) - 1)
	if type(qntd) == int:
		retorno.append(qntd + 1)
	else:
		retorno.append(0)
# e
out = ""
for i in xrange(len(retorno)):
	if i == len(retorno) - 1:
		out += str(retorno[i])
	else:
		out += str(retorno[i]) + " "

print out


n, m = map(int, raw_input().split())
first_array = map(int, raw_input().split())
second_array = map(int, raw_input().split())
first_array.sort()

obj = {}
for j in xrange(len(second_array)):
	if not obj.get(second_array[j]):
		for i in xrange(len(first_array)-1, -1, -1):
			if first_array[i] <= second_array[j]:
				obj[second_array[j]] = i + 1
				break
out = ""
for i in xrange(len(second_array)):
	if i == len(second_array) - 1:
		if obj.get(second_array[i]):
			out += str(obj.get(second_array[i]))
		else:
			out += '0'
	else:
		if obj.get(second_array[i]):
			out += str(obj.get(second_array[i])) + " "
		else:
			out += "0 "
print out


n, m = map(int, raw_input().split())
first_array = map(int, raw_input().split())
second_array = map(int, raw_input().split())
first_array.sort()

obj = {}
for i in xrange(len(first_array) - 1, -1, -1):
	if not obj.get(first_array[i]):
		obj[first_array[i]] = i + 1
out = ""
maior = max(first_array)
menor = min(first_array)
for i in xrange(len(second_array)):
	if i == len(second_array) - 1:
		if obj.get(second_array[i]):
			out += str(obj.get(second_array[i]))
		else:
			if second_array[i] > maior:
				out += str(obj.get(maior))
			else:
				if second_array[i] < menor:
					out += '0'
				else:
					j = second_array[i]
					while not obj.get(j):
						j -= 1
					out += str(obj.get(j))
	else:
		if obj.get(second_array[i]):
			out += str(obj.get(second_array[i])) + " "
		else:
			if second_array[i] > maior:
				out += str(obj.get(maior)) + " "
			else:
				if second_array[i] < menor:
					out += '0 '
				else:
					j = second_array[i]
					while not obj.get(j):
						j -= 1
					out += str(obj.get(j)) + " "
print out


def binary_search(array, integer, begin, end):
	if begin >= end:
		return False
	middle = (begin + end) / 2
	if array[middle] == integer:
		for i in xrange(middle + 1, end + 1):
			if array[i] == integer:
				middle = i
			else:
				break
		return middle
	elif array[middle] > integer:
		if begin == end - 1:
			return False
		return binary_search(array, integer, begin, middle)
	elif array[middle] < integer and array[middle + 1] > integer:
		return middle
	elif array[middle] < integer and array[middle + 1] != integer:
		if begin == end - 1:
			return end
		return binary_search(array, integer, middle, end)
	else:
		for i in xrange(middle + 1, end + 1):
			if array[i] == integer:
				middle = i
			else:
				break
		return middle

n, m = map(int, raw_input().split())
first_array = map(int, raw_input().split())
second_array = map(int, raw_input().split())
first_array.sort()

retorno = []

for i in second_array:
	qntd = binary_search(first_array, i, 0, len(first_array) - 1)
	if type(qntd) == int:
		retorno.append(qntd + 1)
	else:
		retorno.append(0)

out = ""
for i in xrange(len(retorno)):
	if i == len(retorno) - 1:
		out += str(retorno[i])
	else:
		out += str(retorno[i]) + " "

print out
# vai


n, m = map(int, raw_input().split())
first_array = map(int, raw_input().split())
second_array = map(int, raw_input().split())
first_array.sort()

obj = {}
for i in xrange(len(first_array) - 1, -1, -1):
	if not obj.get(first_array[i]):
		obj[first_array[i]] = i + 1
out = ""
maior = max(first_array)
menor = min(first_array)
for i in xrange(len(second_array)):
	if i == len(second_array) - 1:
		if obj.get(second_array[i]):
			out += str(obj.get(second_array[i]))
		else:
			if second_array[i] > maior:
				out += obj.get(maior)
			else:
				if second_array[i] < menor:
					out += '0'
				else:
					j = second_array[i]
					while not obj.get(j):
						j -= 1
					out += str(obj.get(j))
	else:
		if obj.get(second_array[i]):
			out += str(obj.get(second_array[i])) + " "
		else:
			if second_array[i] > maior:
				out += obj.get(maior) + " "
			else:
				if second_array[i] < menor:
					out += '0 '
				else:
					j = second_array[i]
					while not obj.get(j):
						j -= 1
					out += str(obj.get(j)) + " "
print out


def binary_search(array, integer, begin, end):
	if begin >= end:
		return False
	middle = (begin + end) / 2
	if array[middle] == integer:
		for i in xrange(middle, end + 1):
			if array[i] == integer:
				middle = i
		return middle
	elif array[middle] > integer:
		return binary_search(array, integer, begin, middle)
	elif array[middle] < integer and array[middle + 1] > integer:
		return middle
	elif array[middle] < integer and array[middle + 1] != integer:
		return binary_search(array, integer, middle, end)
	else:
		return middle + 1

n, m = map(int, raw_input().split())
first_array = map(int, raw_input().split())
second_array = map(int, raw_input().split())
first_array.sort()

retorno = []

for i in second_array:
	qntd = binary_search(first_array, i, 0, len(first_array) - 1)
	if type(qntd) == int:
		retorno.append(qntd + 1)
	else:
		retorno.append(0)

out = ""
for i in xrange(len(retorno)):
	if i == len(retorno) - 1:
		out += str(retorno[i])
	else:
		out += str(retorno[i]) + " "

print out


def binary_search(array, integer, begin, end):
	if begin >= end:
		return False
	middle = (begin + end) / 2
	if array[middle] == integer:
		for i in xrange(middle + 1, end + 1):
			if array[i] == integer:
				middle = i
			else:
				break
		return middle
	elif array[middle] > integer:
		if begin == end - 1:
			return False
		return binary_search(array, integer, begin, middle)
	elif array[middle] < integer and array[middle + 1] > integer:
		return middle
	elif array[middle] < integer and array[middle + 1] != integer:
		if begin == end - 1:
			return end
		return binary_search(array, integer, middle, end)
	else:
		for i in xrange(middle + 1, end + 1):
			if array[i] == integer:
				middle = i
			else:
				break
		return middle

n, m = map(int, raw_input().split())
first_array = map(int, raw_input().split())
second_array = map(int, raw_input().split())
first_array.sort()

obj = {}

for i in xrange(len(first_array) - 1, -1, -1):
	if not obj.get(first_array[i]):
		obj[first_array[i]] = i + 1
out = ""
for i in xrange(len(second_array)):
	if i == len(second_array) - 1:
		if obj.get(second_array[i]):
			out += str(obj.get(second_array[i]))
		else:
			index = binary_search(first_array, second_array[i], 0, len(first_array) - 1)
			if index:
				out += str(obj.get(first_array[index]))
			else:
				out += "0"
	else:
		if obj.get(second_array[i]):
			out += str(obj.get(second_array[i])) + " "
		else:
			index = binary_search(first_array, second_array[i], 0, len(first_array) - 1)
			if index or index == 0:
				out += str(obj.get(first_array[index])) + " "
			else:
				out += "0 "
print out


n, m = map(int, raw_input().split())
first_array = map(int, raw_input().split())
second_array = map(int, raw_input().split())
first_array.sort()

out = ""
for i in second_array:
	for j in xrange(len(first_array) - 1, -1, -1):
		if first_array[j] <= i:
			if i == second_array[-1]:
				out += str(j+1)
			else:
				out += str(j+1) + " "
			break

print out


import bisect

# def bsearch(l,a)

n,m=map(int,raw_input().split())
a=map(int,raw_input().split())
a.sort()
b=map(int,raw_input().split())
l=''
for i in b:
    l+=str( bisect.bisect(a,i))+' '
print l


lena,lenb = raw_input().split(" ")
arraya = raw_input().split(" ")
arrayb = raw_input().split(" ")
for i in arrayb:
	contador = 0
	for j in arraya:
		if j <= i:
			contador += 1
	print contador,


def busca_binaria (lista,x):
	primeiro = 0
	ultimo = len(lista) - 1
	while primeiro <= ultimo:
		meio = (primeiro + ultimo) / 2
		if primeiro == ultimo:
			if lista[primeiro] <= x:
				return primeiro + 1
			elif lista[primeiro] > x:
				return primeiro
		if lista[meio] <= x:
			primeiro = meio + 1
		elif lista[meio] > x:
			ultimo = meio

lena,lenb = raw_input().split(" ")
arraya = (map(int,raw_input().split(" ")))
arraya.sort()
arrayb = (map(int,raw_input().split(" ")))
resposta = ""
for i in xrange(len(arrayb)):
	if i == 0:
		resposta += str(busca_binaria(arraya,arrayb[i]))
	else:
		resposta += " " + str(busca_binaria(arraya,arrayb[i]))
print resposta


lena,lenb = raw_input().split(" ")
arraya = (map(int,raw_input().split(" ")))
arraya.sort()
arrayb = (map(int,raw_input().split(" ")))
for i in arrayb:
	for j in range(len(arraya)-1,-1,-1):
		if arraya[j] <= i:
			print j+1,
			break


lena,lenb = raw_input().split(" ")
arraya = (map(int,raw_input().split(" ")))
arraya.sort()
arrayb = (map(int,raw_input().split(" ")))
for i in arrayb:
	for j in range(len(arraya)-1,-1,-1):
		if arraya[0] > i:
			print 0,
			break
		if arraya[j] <= i:
			print j+1,
			break


def busca_binaria(lista, x):
    primeiro = 0
    ultimo = len(lista) - 1
    while primeiro <= ultimo:
        meio = (primeiro + ultimo) / 2
        if primeiro == ultimo:
            if lista[primeiro] <= x:
                return primeiro + 1
            elif lista[primeiro] > x:
                return primeiro
        if lista[meio] <= x:
            primeiro = meio + 1
        elif lista[meio] > x:
            ultimo = meio

x, y = map(int, raw_input().split())

a = map(int, raw_input().split())
b = map(int, raw_input().split())

a.sort()

string = ""
for i in xrange(len(b)):
    if i == 0:
        string += str(busca_binaria(a, b[i]))
    else:
        string += " "
        string += str(busca_binaria(a, b[i]))

print string


'''input
5 4
1 3 5 7 9
6 4 2 8
'''

def binary_search(a, x, start, end):
	if start >= end:
		if a[start] <= x:
			return start
		else:
			return start - 1

	mid = (start + end) // 2

	if a[mid] <= x:
		return binary_search(a, x, mid + 1, end)

	else:
		return binary_search(a, x, start, mid - 1)

n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
b = list(map(int, input().split()))
for i in range(m):
	print(binary_search(a, b[i], 0, n - 1) + 1, end = ' ')


'''input
5 4
1 3 5 7 9
6 4 2 8
'''

def binary_search(a, x, start, end):
	if start >= end:
		if a[start] <= x:
			return start
		else:
			return start - 1

	mid = (start + end) // 2

	if a[mid] <= x:
		return binary_search(a, x, mid + 1, end)

	else:
		return binary_search(a, x, start, mid - 1)

n, m = list(map(int, raw_input().split()))
a = list(map(int, raw_input().split()))
a.sort()
b = list(map(int, raw_input().split()))
for i in xrange(m):
	print(binary_search(a, b[i], 0, n - 1) + 1),


f = open("codeForces600B.in", "r")

if f.mode == "r":
    firstLine = f.readline()
    a = map(int, f.readline().split())
    b = map(int, f.readline().split())
    f.close

a.sort()
answerList = []

def findLess(compareNum):
    low = 0
    high = len(a) - 1
    answer = 0
    while (low <= high):
        mid = (low + high) // 2
        if compareNum >= a[mid]:
            low = mid + 1
            answer = mid
        elif compareNum < a[mid]:
            high = mid - 1
    if compareNum >= a[answer]:
        return answer + 1
    else:
        return answer

for i in b:
    answerList.append(str(findLess(i)))
print " ".join(answerList)


firstLine = raw_input("")
a = map(int, raw_input("").split())
b = map(int, raw_input("").split())

print a
print b
print firstLine

a.sort()
answerList = []

def findLess(compareNum):
    low = 0
    high = len(a) - 1
    answer = 0
    while (low <= high):
        mid = (low + high) // 2
        if compareNum >= a[mid]:
            low = mid + 1
            answer = mid
        elif compareNum < a[mid]:
            high = mid - 1
    if compareNum >= a[answer]:
        return answer + 1
    else:
        return answer

for i in b:
    answerList.append(str(findLess(i)))
print " ".join(answerList)


firstLine = raw_input("")
a = map(int, raw_input("").split())
b = map(int, raw_input("").split())

a.sort()
answerList = []

def findLess(compareNum):
    low = 0
    high = len(a) - 1
    answer = 0
    while (low <= high):
        mid = (low + high) // 2
        if compareNum >= a[mid]:
            low = mid + 1
            answer = mid
        elif compareNum < a[mid]:
            high = mid - 1
    if compareNum >= a[answer]:
        return answer + 1
    else:
        return answer

for i in b:
    answerList.append(str(findLess(i)))
print " ".join(answerList)


def binary_search(i):
    left = 0
    right = len(a) - 1
    while left <= right:
        m = (left + right) // 2
        if a[m] <= i:
            left = m + 1
        else:
            right = m - 1
    return left

inutil = raw_input()
a = list(map(int, raw_input().split()))
b = list(map(int, raw_input().split()))

a = sorted(a)
solution = ''
for i in b:
    solution += str(binary_search(i)) + ' '

print(solution)


import bisect
n,m = map(int,raw_input().split())
s = sorted(map(int,raw_input().split()))
a = map(int,raw_input().split())
#print s,a
for i in a:
	print bisect.bisect_right(s,i),


from collections import Counter
n,m = map(int,raw_input().split())
s = Counter(map(int,raw_input().split()))
a = map(int,raw_input().split())
b1,b2=zip(*sorted(zip(s.keys(),s.values())))
b1 = list(b1)
b2 = list(b2)
#print b1,b2
for i in xrange(1,len(b2),1):
	b2[i]+=b2[i-1]
#print b1,b2
def r(s,a,b,c):
	if b-a==0:
		if s[a]<c:
			return a
		else:
			return a-1
	else:
		if s[(b+a)/2]>c:
			return r(s,a,(b+a)/2,c)
		elif s[(b-a)/2]<c:
			return r(s,(b+a)/2+1,b,c)
		else:
			return (b+a)/2
for i in a:
	print b2[r(b1,0,n-1,i)],


import bisect
n,m = map(int,raw_input().split())
s = sorted(map(int,raw_input().split()))
a = map(int,raw_input().split())
print s,a
for i in a:
	print bisect.bisect_right(s,i),


def binsearch(x):
	ini = 0
	fim = len(a) - 1
	while ini <= fim:
		 meio = (ini + fim) / 2
		 if a[meio] <= x:
			  ini = meio+1
		 else:
			  fim = meio-1
	return ini

lista = []

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

a = map(int, raw_input().split())
b = map(int, raw_input().split())

a.sort()

for i in range(len(b)):
	lista.append(binsearch(b[i]))

for e in range(len(lista)):
     print lista[e],


def buscaBinaria(vetor, elemento):
    inicio = 0
    fim = len(vetor) - 1

    while inicio <= fim:
        meio = (inicio + fim) // 2
        if vetor[meio] <= elemento:
            soma = meio + 1
            inicio = meio + 1
        else:
            if elemento < vetor[meio]:
                fim = meio
            else:
                inicio = meio + 1
    return soma

sizeA, sizeB = map(int,raw_input().split())
n = map(int,raw_input().split())
m = map(int,raw_input().split())

n.sort()

for i in range(len(m)):
    if i < len(m) - 1:
        print buscaBinaria(n, m[i]),
    else:
        print buscaBinaria(n, m[i])


tamanhoA, tamanhoB = map(int,raw_input().split())
A = map(int,raw_input().split())
B = map(int,raw_input().split())
final = []

for i in xrange(len(B)):
    cont = 0
    for j in xrange(len(A)):
        if B[i] >= A[j]:
            cont += 1
        if j == len(A) - 1:
            final.append(cont)

for i in range(len(final)):
    if i < len(final) - 1:
        print final[i],

    else:
        print final[i]


def buscaBinaria(vetor, elemento):
    inicio = 0
    fim = len(vetor) - 1

    while inicio <= fim:
        meio = (inicio + fim) // 2
        if vetor[meio] <= elemento:
            soma = meio + 1
            inicio = meio + 1
        else:
            fim = meio - 1
    return soma

sizeA, sizeB = map(int,raw_input().split())
n = map(int,raw_input().split())
m = map(int,raw_input().split())

n.sort()

for i in range(len(m)):
    if i < len(m) - 1:
        print buscaBinaria(n, m[i]),
    else:
        print buscaBinaria(n, m[i])


def buscaBinaria(vetor, elemento):
    inicio = 0
    fim = len(vetor) - 1
    soma = 0

    while inicio <= fim:
        meio = (inicio + fim) // 2
        if vetor[meio] <= elemento:
            soma = meio + 1
            inicio = meio + 1
        else:
            if elemento < vetor[meio]:
                fim = meio - 1
            else:
                inicio = meio + 1
    return soma

sizeA, sizeB = map(int,raw_input().split())
n = map(int,raw_input().split())
m = map(int,raw_input().split())

n.sort()

for i in range(len(m)):
    if i < len(m) - 1:
        print buscaBinaria(n, m[i]),
    else:
        print buscaBinaria(n, m[i])


def buscaBinaria(vetor, elemento):
    inicio = 0
    fim = len(vetor) - 1

    while inicio <= fim:
        meio = (inicio + fim) // 2
        if vetor[meio] <= elemento:
            soma = meio + 1
            inicio = meio + 1
        else:
            if elemento < vetor[meio]:
                fim = meio - 1
            else:
                inicio = meio + 1
    return soma

sizeA, sizeB = map(int,raw_input().split())
n = map(int,raw_input().split())
m = map(int,raw_input().split())

n.sort()

for i in range(len(m)):
    if i < len(m) - 1:
        print buscaBinaria(n, m[i]),
    else:
        print buscaBinaria(n, m[i])


def bb(vetor, tamanho, chave):
    inicio = 0
    fim = tamanho - 1
    while inicio <= fim:
        meio = (inicio + fim) / 2
        if vetor[meio] <= chave:
            soma = meio + 1
            inicio = meio + 1
        else:
            fim = meio - 1
    return soma

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

n.sort()

for i in range(len(m)):
    if i < len(m) - 1:
        print bb(n, len(n), m[i]),
    else:
        print bb(n, len(n), m[i])


from bisect import bisect_right

r=lambda:map(int,raw_input().split())
n,m=r();a=r();b=r()

a=sorted(a)
for x in b:
    print bisect_right(a,x),


from sys import stdin
from bisect import bisect_left,bisect_right
n,m=map(int,stdin.readline().split())
a=map(int,stdin.readline().split())
a.sort()
b=map(int,stdin.readline().split())

for i in range(m):
    print bisect_right(a,b[i]),


def upper_bound(nums, target):
    l, r = 0, len(nums) - 1
    while l <= r:
        mid = l + (r - l) / 2
        if nums[mid] > target:
            r = mid - 1
        else:
            l = mid + 1
    return l

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

a.sort()

for i in b:
	if i >= a[len(a)-1]: print len(a),
	elif i < a[0]: print 0,
	else: print upper_bound(a, i),


def binary_search(array, target):
    lower = 0
    upper = len(array)
    while lower < upper:
        x = lower + (upper - lower) // 2
        smaller = array[x]
        bigger = array[x+1]
        if target >= smaller and target < bigger:
			return x
        elif target > smaller:
            if lower == x:
                break
            lower = x
        elif target < smaller:
            upper = x

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

a.sort()

for i in b:
	if i >= a[len(a)-1]: print len(a),
	elif i < a[0]: print 0,
	else: print binary_search(a, i) +1,


raw_input()
first = map(int, raw_input().split())
second = map(int, raw_input().split())
first.sort()
for i, j in enumerate(second):
    second[i] = (j, i)
second.sort()
ans = [0]*len(second)
a = 0
b = 0
while a < len(first) and b < len(second):
    if second[b][0] < first[a]:
        ans[second[b][1]] = a
        b += 1
    else:
        a += 1
if a == len(first):
    while b < len(second):
        ans[b] = len(first)
        b += 1
print " ".join(map(str, ans))


raw_input()
first = map(int, raw_input().split())
second = map(int, raw_input().split())
first.sort()
for i, j in enumerate(second):
    second[i] = (j, i)
second.sort()
ans = [0]*len(second)
a = 0
b = 0
while a < len(first) and b < len(second):
    if second[b][0] < first[a]:
        ans[second[b][1]] = a
        b += 1
    else:
        a += 1
if a == len(first):
    while b < len(second):
        ans[second[b][1]] = len(first)
        b += 1
print " ".join(map(str, ans))


sizes = map(int, raw_input().split())
s_a = sizes[0]
s_b = sizes[1]

a = map(int, raw_input().split())
b = map(int, raw_input().split())

result = []
for i in range(s_b):
	summ = 0
	for j in range(s_a):
		if b[i] >= a[j]: summ += 1
	result.append(summ)

print " ".join(str(x) for x in result)


sizes = map(int, raw_input().split())
s_a = sizes[0]
s_b = sizes[1]

a = map(int, raw_input().split())
b = map(int, raw_input().split())
a.sort()

result = []
for i in range(s_b):
	summ = 0
	for j in range(s_a):
		if b[i] >= a[j]: summ += 1
		else: break
	result.append(summ)

print " ".join(str(x) for x in result)


sizes = map(int, raw_input().split())
s_a = sizes[0]
s_b = sizes[1]

a = map(int, raw_input().split())
b = map(int, raw_input().split())

a.sort()
original = b[:]
mapp = {}
for i in range(s_b):
	mapp[b[i]] = 0
b.sort()

result = []
a_i = s_a-1
b_i = s_b-1
while b_i >= 0:
	while (a_i >= 0) and (a[a_i] > b[b_i]):
		a_i -= 1
	an = len(a[:a_i+1])
	mapp[b[b_i]] = an
	b_i -= 1

for i in original:
	result.append(mapp[i])

print " ".join(str(x) for x in result)


sizes = map(int, raw_input().split())
s_a = sizes[0]
s_b = sizes[1]

a = map(int, raw_input().split())
b = map(int, raw_input().split())

a.sort()
original = b[:]
mapp = {}
for i in range(s_b):
	mapp[b[i]] = 0
b.sort()

result = []
a_i = s_a-1
b_i = s_b-1
while b_i >= 0:
	while a[a_i] > b[b_i]:
		a_i -= 1
	an = len(a[:a_i+1])
	mapp[b[b_i]] = an
	b_i -= 1

for i in original:
	result.append(mapp[i])

print " ".join(str(x) for x in result)


sizes = map(int, raw_input().split())
s_a = sizes[0]
s_b = sizes[1]

a = map(int, raw_input().split())
b = map(int, raw_input().split())

a.sort()
original = b[:]
mapp = {}
b.sort()

result = ""
a_i = s_a-1
b_i = s_b-1
while b_i >= 0:
	while (a_i >= 0) and (a[a_i] > b[b_i]):
		a_i -= 1
	mapp[b[b_i]] = a_i+1
	b_i -= 1

for i in range(s_b):
	if i == s_b-1: result += str(mapp[original[i]])
	else: result += (str(mapp[original[i]]) + " ")

print result


l=lambda: map(int, raw_input().split())
import bisect
n,m=l()
a,b=l(),l()
a.sort()
ans=[]
for e in b:
    ans.append(bisect.bisect(a,e))
print ' '.join(map(str,ans))


#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2015 vivek9ru <vivek9ru@Vivek9RU>
#
# Distributed under terms of the MIT license.

from math import acos,asin,atan,sqrt,pi,sin,cos,tan,ceil,floor
import re
from operator import itemgetter as ig

n,m=map(int,raw_input().split())
a=map(int,raw_input().split())
c=map(int,raw_input().split())
l=len(c)
e=len(a)
b=[]
for i in range(l):
	b.append([c[i],i])
a.sort()
b.sort()
c=[0]*l
j=0
for i in range(l):
	while j<e and a[j]<=b[i][0]:
		j+=1
	c[b[i][1]]=j

for i in c:
	print i,
print

exit(0)


alalala = raw_input()
array1 = map(int, raw_input().split())
array1.sort()
array2 = map(int, raw_input().split())
lista = []
maior_anterior = 0
cont_maior = 0
cont = 0

for i in range(len(array2)):
    if array2[i] >= array1[maior_anterior]:
        for j in range(maior_anterior, len(array1)):
            if array2[i] >= array1[j]:
                maior_anterior = j
                cont += 1
            else:
                maior_anterior = j
                cont_maior = cont

                break
    elif array2[i] < array1[maior_anterior]:
        cont = 0
        for j in range(len(array1)):
            if array2[i] >= array1[j]:
                maior_anterior = j
                cont += 1
            else:
                maior_anterior = j
                cont_maior = cont
                break

    lista.append(str(cont))

print ' '.join(lista)


abc = raw_input()
a1 = map(int, raw_input().split())
a1.sort()
a2 = map(int, raw_input().split())
a_pointer = 0
b_pointer = 0
size = len(a2)
counter = 0

while a_pointer < size:
    try:
        if a2[a_pointer] >= a1[b_pointer]:
            counter += 1
            b_pointer += 1
        else:
            print counter,
            counter = 0
            b_pointer = 0
            a_pointer += 1

    except IndexError:
        print counter,
        counter = 0
        b_pointer = 0
        a_pointer += 1


alalala = raw_input()
array1 = map(int, raw_input().split())
array1.sort()
array2 = map(int, raw_input().split())

for element in array2:
    count = 0

    for i in array1:
        if element >= i:
            count += 1
        else:
            break

    print count,


raw_input()
a1 = map(int, raw_input().split())
a1.sort()
a2 = map(int, raw_input().split())

for element in a2:
    low = 0
    high = len(a1) - 1

    while low <= high:
        mid = low + (high - low) / 2

        if a1[mid] > element:
            high = mid - 1

        else:
            low = mid + 1

    print low,


lalala = raw_input()
array1 = map(int, raw_input().split())
array1.sort()
array2 = map(int, raw_input().split())
lista = []
maior_anterior = 0
anterior = 0

for i in range(len(array2)):
    if array2[i] >= array1[maior_anterior]:
        for j in range(maior_anterior, len(array1)):
            if array2[i] >= array1[j]:
                anterior = j
            else:
                maior_anterior = j
                anterior = 0
                break
    elif array2[i] < array1[maior_anterior]:
        for j in range(len(array1)):
            if array2[i] >= array1[j]:
                anterior = j
            else:
                maior_anterior = j
                break

    if not i == len(array2) - 1:
        lista.append(str(j))

if array2[i] >= array1[j]:
    lista.append(str(j + 1))

else:
    lista.append(str(j))

print ' '.join(lista)


array1 = map(int, raw_input().split())
array1.sort()
array2 = map(int, raw_input().split())
lista = []
maior_anterior = 0
anterior = 0

for i in range(len(array2)):
    if array2[i] >= array1[maior_anterior]:
        for j in range(maior_anterior, len(array1)):
            if array2[i] >= array1[j]:
                anterior = j
            else:
                maior_anterior = j
                anterior = 0
                break
    elif array2[i] < array1[maior_anterior]:
        for j in range(len(array1)):
            if array2[i] >= array1[j]:
                anterior = j
            else:
                maior_anterior = j
                break

    if not i == len(array2) - 1:
        lista.append(str(j))

if array2[i] >= array1[j]:
    lista.append(str(j + 1))

else:
    lista.append(str(j))

print ' '.join(lista)


def busca_binaria(lista, x):
    primeiro = 0
    ultimo = len(lista) - 1
    while primeiro <= ultimo:
        meio = (primeiro + ultimo) / 2
        if primeiro == ultimo:
            if lista[primeiro] == x or lista[primeiro] < x:
                return primeiro + 1
            elif lista[primeiro] > x:
                return primeiro
        if lista[meio] == x or lista[meio] < x:
            primeiro = meio + 1
        elif lista[meio] > x:
            ultimo = meio

x, y = map(int, raw_input().split())

a = map(int, raw_input().split())
b = map(int, raw_input().split())

a.sort()

string = ""
for i in range(len(b)):
    if i == 0:
        string += str(busca_binaria(a, b[i]))
    else:
        string += " "
        string += str(busca_binaria(a, b[i]))

print string


def busca_binaria(lista, x):
    primeiro = 0
    ultimo = len(lista) - 1
    while primeiro <= ultimo:
        meio = (primeiro + ultimo) / 2
        if primeiro == ultimo:
            if lista[primeiro] <= x:
                return primeiro + 1
            elif lista[primeiro] > x:
                return primeiro
        if lista[meio] <= x:
            primeiro = meio + 1
        elif lista[meio] > x:
            ultimo = meio

x, y = map(int, raw_input().split())

a = map(int, raw_input().split())
b = map(int, raw_input().split())

a.sort()

string = ""
for i in xrange(len(b)):
    if i == 0:
        string += str(busca_binaria(a, b[i]))
    else:
        string += " "
        string += str(busca_binaria(a, b[i]))

print string


x, y = map(int, raw_input().split())

a = map(int, raw_input().split())
b = map(int, raw_input().split())

dic = {}
for i in a:
    if i in dic:
        dic[i] += 1
    else:
        dic[i] = 1

lista = []
for i in b:
    cont = 0
    for j in range(i + 1):
        if j in dic:
            cont += dic[j]
    lista.append(cont)
lista = str(lista)

saida = ""
for i in lista:
    if i not in ",][":
        saida += i
print saida


x, y = map(int, raw_input().split())

a = map(int, raw_input().split())
b = map(int, raw_input().split())

a.sort()

aux = 0
lista = ""
while aux < len(b):
    cont = 0
    for i in a:
        if i <= b[aux]:
            cont += 1
        else:
            break
    if aux == 0:
        lista += str(cont)
    else:
        lista += " "
        lista += str(cont)
    aux += 1
print lista


def busca_binaria(lista, x):
    primeiro = 0
    ultimo = len(lista) - 1
    while primeiro <= ultimo:
        meio = (primeiro + ultimo) / 2
        if primeiro == ultimo:
            if lista[primeiro] == x or lista[primeiro] < x:
                return primeiro + 1
            elif lista[primeiro] > x:
                return primeiro
        if lista[meio] == x or lista[meio] < x:
            primeiro = meio + 1
        elif lista[meio] > x:
            ultimo = meio

x, y = map(int, raw_input().split())

a = map(int, raw_input().split())
b = map(int, raw_input().split())

a.sort()

string = ""
for i in xrange(len(b)):
    if i == 0:
        string += str(busca_binaria(a, b[i]))
    else:
        string += " "
        string += str(busca_binaria(a, b[i]))

print string


import sys

n, m = sys.stdin.readline().strip().split(' ')
n = int(n)
m = int(m)
arr = sys.stdin.readline().strip().split(' ')
arr.sort()
brr = sys.stdin.readline().strip().split(' ')
for i in xrange(m):
    left = 0
    right = n
    while left < right:
        mid = (left + right) / 2
        if int(arr[mid]) <= int(brr[i]):
            left = mid + 1
        else:
            right = mid
    print left,
print


import sys

n, m = sys.stdin.readline().strip().split(' ')
n = int(n)
m = int(m)
arr = [int(x) for x in sys.stdin.readline().strip().split(' ')]
arr.sort()
brr = [int(x) for x in sys.stdin.readline().strip().split(' ')]
for i in xrange(m):
    left = 0
    right = n
    while left < right:
        mid = (left + right) / 2
        if arr[mid] <= brr[i]:
            left = mid + 1
        else:
            right = mid
    print left,
print


import sys
from bisect import bisect_right

f = sys.stdin

f.readline()
a = sorted(map(int, f.readline().split()))
b = map(int, f.readline().split())
print " ".join([str(bisect_right(a, x)) for x in b])


from sys import setrecursionlimit
setrecursionlimit(20000)
n,t = map(int, raw_input().split())
a = map(int, raw_input().split())
b = map(int, raw_input().split())
a.sort()
def bb(x,y,v):
	m = (x+y)/2
	if x == y:
		return m
	if a[m] < v:
		 return bb(m+1,y,v)
	elif a[m] > v:
		return bb(x,m,v)
	else:
		return m
def conta(m,v):
	if a[m]<=v:
		while m<len(a)-1 and a[m]==a[m+1]:
			m+=1
		return m

	elif a[m]>v:
		while m>=0 and a[m]==a[m-1]:
			m-=1
		return m-1
lista = []

for i in b:
	print conta(bb(0,len(a),i),i)+1,


from sys import setrecursionlimit
setrecursionlimit(20000)
n,t = map(int, raw_input().split())
a = map(int, raw_input().split())
b = map(int, raw_input().split())
a.sort()
def bb(x,y,v):
	m = (x+y)/2
	if x == y:
		return m
	if a[m] <= v:
		 return bb(m+1,y,v)
	elif a[m] > v:
		return bb(x,m,v)

lista = []

for i in b:
	print bb(0,len(a),i),


numeros = map(int, raw_input().split())
numeros2 = map(int, raw_input().split())
soma = numeros[1]
numeros2.sort()
rtn = 0
cont = 0
for i in xrange(len(numeros2)):
	if soma - numeros2[i]>0:
		soma -= numeros2[i]>0
		cont+=1
		rtn = cont
	elif soma - numeros2[i]==0:
		soma -= numeros2[i]>0
		cont +=1
		rtn = cont
		break
	else:
		break
print rtn


from sys import setrecursionlimit
setrecursionlimit(20000)
n,t = map(int, raw_input().split())
a = map(int, raw_input().split())
b = map(int, raw_input().split())
a.sort()
def bb(x,y,v):
	m = (x+y)/2
	if x == y:
		return m
	if a[m] < v:
		 return bb(m+1,y,v)
	elif a[m] > v:
		return bb(x,m,v)
	else:
		return m
def conta(m,v):
	if a[m]<=v:
		while m<len(a)-1 and a[m]==a[m+1]:
			m+=1
		return m

	elif a[m]>v:
		while m>=0 and a[m]==a[m-1]:
			m-=1
		return m
lista = []

for i in b:
	print conta(bb(0,len(a)-1,i),i)+1,


# coding: utf-8

# In[16]:

S = raw_input()
S = raw_input()
a = [int(i) for i in S.split(' ')]
S =raw_input()
b = [int(i) for i in S.split(' ')]

# In[17]:

line_output = ''
for i in b:
    out = 0
    for j in a:
        if (i >= j):
            out += 1
    line_output += str(out)+" "
print line_output[0:-1]


# coding: utf-8

# In[90]:

def binary_search(A,key):
    left = -1
    right = len(A)
    while right > left + 1:
        middle = (left + right) // 2
        if A[middle] > key:
            right = middle
        else:
            left = middle
    return left+1

# In[93]:

S = raw_input()
S = raw_input()
a = [int(i) for i in S.split(' ')]
a.sort()
S =raw_input()
b = [int(i) for i in S.split(' ')]
lineout=''
for i in b:
    lineout += str(binary_search(a, i))+' '
print lineout

# In[ ]:

# In[ ]:


import bisect

junk, a, b = [map(int, raw_input().split()) for i in xrange(3)]
a = sorted(a)

print ' '.join(map(str, [bisect.bisect_right(a, b_i) for b_i in b]))


from bisect import bisect
from sys import stdin,stdout
n,k = map(int,raw_input().split())
a = map(int,stdin.readline().split())
b = map(int,stdin.readline().split())
a.sort()
for i in xrange(k):
    e = bisect.bisect(a,b[i])
    if i == k-1:stdout.write(str(e)+'\n')
    else:stdout.write(str(e)+' ')


def bb(l,x,n):
    p,u,c = 0,n-1,l.count(x)
    while p <= u:
        m = (p+u)/2
        if x == l[m]:return m+c
        else:
            if x < l[m]:u = m-1
            else:p = m+1
    if l[m]>x:return m
    else: return m+1
n,k = map(int,raw_input().split())
a = map(int,raw_input().split())
b = map(int,raw_input().split())
a.sort()
for i in xrange(k):
    e = bb(a,b[i],n)
    if i == k-1:print e
    else:print e,


from sys import stdin,stdout
import bisect
n,k = map(int,stdin.readline().split())
a = map(int,stdin.readline().split())
b = map(int,stdin.readline().split())
a.sort()
for i in xrange(k):
    e = bisect.bisect(a,b[i])
    if i == k-1:stdout.write(str(e)+'\n')
    else:stdout.write(str(e)+' ')


n,m = raw_input().split()
a = map(int,raw_input().split())
b = map(int,raw_input().split())
a.sort()
for i in b:
    c = 0
    if i in a: print a.index(i) + a.count(i),
    else:
        while True:
            c+=1
            if i-c == 0:
                print 0,
                break
            if i-c in a:
                print a.index(i-c) + a.count(i-c),
                break


import bisect
n,k = map(int,raw_input().split())
a = map(int,raw_input().split())
b = map(int,raw_input().split())
a.sort()
for i in xrange(k):
    e = bisect.bisect(a,b[i])
    if i == k-1:print e
    else:print e,


def bb(l,x,n):
    p,u = 0,n-1
    while p <= u:
        m = (p+u)/2
        if x == l[m]:return m
        else:
            if x < l[m]:u = m-1
            else:p = m+1
    if l[m]>x:return m
    else: return m+1
n,k = map(int,raw_input().split())
a = map(int,raw_input().split())
b = map(int,raw_input().split())
a.sort()
for i in xrange(k):
    e = bb(a,b[i],n)
    c = a.count(b[i])
    if i == k-1:print e + c
    else:print e + c,


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

a = map(int, raw_input().split())
b = map(int, raw_input().split())

# ordena a e b, pq?
# nao precisamos do indice apenas saber a ordem dos elementos pra imprimir
# por isso mantemos b e sorted_b.
sorted_a = sorted(a)
sorted_b = sorted(b)

ans = {}
i = 0
j = 0
while j < len(b):
	while i < len(sorted_a) and sorted_a[i] <= sorted_b[j]:
		if sorted_b[j] not in ans:
			ans[sorted_b[j]] = 1
		else:
			ans[sorted_b[j]] += 1
		i += 1
	j += 1
	if j < len(b):
		ans[sorted_b[j]] = ans[sorted_b[j-1]]

for e in b:
	print ans[e],


def transformaEmInt(lista, tamanho):

	for i in xrange(tamanho):

		lista[i] = int(lista[i])

def buscaMenores(inicio, fim, lista, elemento):

	while True:

		meio = (fim + inicio) / 2

		if inicio > fim:

			 break

		elif inicio == fim:

			if lista[inicio] <= elemento: inicio += 1

			break

		elif lista[meio] <= elemento:

			inicio = meio + 1

		else:

			fim = meio - 1

	return inicio

tamanhoA, tamanhoB = map(int, raw_input().split())

listaA = raw_input().split()
listaB = raw_input().split()

transformaEmInt(listaA, tamanhoA)
transformaEmInt(listaB, tamanhoB)

listaA.sort()
print listaA
#biblioteca = {}

saida = ''
for num in listaB:

	if num >= listaA[-1]:

		numsMenores = tamanhoA

	#elif biblioteca.has_key(num):

	#	numsMenores = biblioteca[num]

	else:

		numsMenores = buscaMenores(0,tamanhoA - 1, listaA, num)

	#	biblioteca[num] = numsMenores

	saida += str(numsMenores) + ' '

print saida[:-1]


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

a = map(int, raw_input().split())
b = map(int, raw_input().split())

# ordena a e b, pq?
# nao precisamos do indice apenas saber a ordem dos elementos pra imprimir
# por isso mantemos b e sorted_b.
sorted_a = sorted(a)
sorted_b = sorted(b)

ans = {}
i = 0
j = 0
while i < len(a) and j < len(b):
	while i < len(sorted_a) and sorted_a[i] <= sorted_b[j]:
		if sorted_b[j] not in ans:
			ans[sorted_b[j]] = 1
		else:
			ans[sorted_b[j]] += 1
		i += 1
	j += 1
	if j < len(b):
		ans[sorted_b[j]] = ans[sorted_b[j-1]]

for e in b:
	print ans[e],


def transformaEmInt(lista, tamanho):

	for i in xrange(tamanho):

		lista[i] = int(lista[i])

def buscaMenores(inicio, fim, lista, elemento):

	while True:

		meio = (fim + inicio) / 2

		if inicio > fim:

			 break

		elif inicio == fim:

			if lista[inicio] <= elemento: inicio += 1

			break

		elif lista[meio] <= elemento:

			inicio = meio + 1

		else:

			fim = meio - 1

	return inicio

tamanhoA, tamanhoB = map(int, raw_input().split())

listaA = raw_input().split()
listaB = raw_input().split()

transformaEmInt(listaA, tamanhoA)
transformaEmInt(listaB, tamanhoB)

listaA.sort()
#biblioteca = {}

saida = ''
for num in listaB:

	if num >= listaA[-1]:

		numsMenores = tamanhoA

	#elif biblioteca.has_key(num):

	#	numsMenores = biblioteca[num]

	else:

		numsMenores = buscaMenores(0,tamanhoA - 1, listaA, num)

	#	biblioteca[num] = numsMenores

	saida += str(numsMenores) + ' '

print saida[:-1]


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

a = map(int, raw_input().split())
b = map(int, raw_input().split())

# ordena a e b, pq?
# nao precisamos do indice apenas saber a ordem dos elementos pra imprimir
# por isso mantemos b e sorted_b.
sorted_a = sorted(a)
sorted_b = sorted(b)

ans = {}
i = 0
j = 0
while j < len(b):
	if sorted_b[j] not in ans:
		ans[sorted_b[j]] = 0
	while i < len(sorted_a) and sorted_a[i] <= sorted_b[j]:
		ans[sorted_b[j]] += 1
		i += 1
	j += 1
	if j < len(b):
		ans[sorted_b[j]] = ans[sorted_b[j-1]]

for e in b:
	print ans[e],


from bisect import bisect_right

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

a.sort()

print ' '.join(str(bisect_right(a, bj)) for bj in b)


#Construction

n,m=map(int,raw_input().split())
a=map(int,raw_input().split());a.sort();b=map(int,raw_input().split())
for _ in b:
    i=0
    while i<n and a[i]<=_:i+=1
    print i,


# logii

n,m=map(int,raw_input().split())
a=map(int,raw_input().split())
b=map(int,raw_input().split())
a.sort()
for _ in xrange(m):
    c,d=0,0
    i=0;j=n-1
    while i<=j:
        if a[i]>b[_]:break
        if a[j]<=b[_]:c=n-d;break
        c+=1;d+=1;i+=1;j-=1
    print c,


# logii--hop

n,m=map(int,raw_input().split())
a=map(int,raw_input().split());b=map(int,raw_input().split());a.sort()
for _ in xrange(m):
    i,j=0,n-1
    ans=0
    while i<=j:
        k=(i+j)/2
        if a[k]<=b[_]:
            i=k+1;ans=k
        else:
            j=k-1

    print ans+1 if b[_]>=a[ans] else\
          ans


#include<queue>
#include<cstdio>
#include<cstring>
using namespace std;
const int N=405,inf=1e9;
struct Link{int w,to,val,nxt;}l[N*10];
int n1,n2,de[N],m,R,B,head[N],tot=1;
int S,T,SS,TT,pre[N],dis[N],vis[N],cnt;
char ch1[N],ch2[N];
inline void add(int x,int y,int w,int val){
	l[++tot].w=w;l[tot].to=y;l[tot].val=val;
	l[tot].nxt=head[x];head[x]=tot;
}
inline void Add(int x,int y,int d,int u,int val){
	add(x,y,u-d,val),add(y,x,0,-val);
	de[y]+=d,de[x]-=d;
}
inline bool spfa(){
	memset(dis,0x3f,sizeof dis);
	memset(pre,0,sizeof pre);
	queue<int>q;q.push(SS);dis[SS]=0;
	while(!q.empty()){
		int x=q.front();q.pop();
		for(int i=head[x];i;i=l[i].nxt){
			int y=l[i].to;
			if(l[i].w&&dis[y]>dis[x]+l[i].val){
				pre[y]=i;dis[y]=dis[x]+l[i].val;
				if(!vis[y]) q.push(y),vis[y]=1;
			}
		}
		vis[x]=0;
	}
	return dis[TT]<inf;
}
inline int EK(int ans=0,int t=0){
	while(t=1e9,spfa()){
		//cout<<t<<"      asas"<<endl;
		for(int i=TT;i!=SS;i=l[pre[i]^1].to) t=min(t,l[pre[i]].w);
		for(int i=TT;i!=SS;i=l[pre[i]^1].to) l[pre[i]].w-=t,l[pre[i]^1].w+=t;
		ans+=t*dis[TT];//printf("%d asas %d\n",t,ans);
	}
	return ans;
}
int main(){
	scanf("%d%d%d%d%d",&n1,&n2,&m,&R,&B);
	scanf("%s%s",ch1+1,ch2+1);cnt=n1+n2;
	S=++cnt,T=++cnt,SS=++cnt,TT=++cnt;

	for(int i=1,x,y;i<=m;++i){
		scanf("%d%d",&x,&y);
		Add(x,y+n1,0,1,R);
		Add(y+n1,x,0,1,B);
	}
	for(int i=1;i<=n1;++i){
		if(ch1[i]=='R') Add(S,i,1,inf,0);
		if(ch1[i]=='B') Add(i,T,1,inf,0);
		if(ch1[i]=='U') Add(S,i,0,inf,0),Add(i,T,0,inf,0);
	}
	for(int i=1;i<=n2;++i){
		if(ch2[i]=='R') Add(i+n1,T,1,inf,0);
		if(ch2[i]=='B') Add(S,i+n1,1,inf,0);
		if(ch2[i]=='U') Add(S,i+n1,0,inf,0),Add(i+n1,T,0,inf,0);
	}
	for(int i=1;i<=cnt-2;++i)
		if(de[i]>0) Add(SS,i,0,de[i],0);
		else if(de[i]<0) Add(i,TT,0,-de[i],0);
	Add(T,S,0,inf,0);
	int ans=EK();
	for(int i=head[SS];i;i=l[i].to)
		if(l[i].w){puts("-1");return 0;}
	printf("%d\n",ans);

	for(int i=2;i<4*m+1;i+=4){
		if(!l[i].w) putchar('R');
		else if(!l[i+2].w) putchar('B');
		else putchar('U');
	}
	return puts(""),0;
}


#include<bits/stdc++.h>
#define N 550
using namespace std;
int n,n1,n2,m,vr,vb,S,T,S2,T2;
char s[N],s2[N],an[N];
int val[N];
int du[N];
int he[N],ne[N*N],to[N*N],w[N*N],c[N*N],tot=1;
const int inf=0x3f3f3f3f;
inline void addedge(int x,int y,int l,int z,int co){
	to[++tot]=y;ne[tot]=he[x];he[x]=tot;w[tot]=z-l;c[tot]=co;
	to[++tot]=x;ne[tot]=he[y];he[y]=tot;w[tot]=0;c[tot]=-co;
	du[y]+=l;du[x]-=l;
}
int dis[N],vis[N],pre[N];
inline bool spfa(){
	memset(dis,0x3f,sizeof(int)*(n+1));
	memset(vis,0,sizeof(int)*(n+1));
	queue<int>q;
	dis[S]=0;q.push(S);
	while(q.size()){
		int g=q.front();q.pop();vis[g]=0;
		for(int i=he[g];i;i=ne[i]){
			if(w[i]&&dis[to[i]]>dis[g]+c[i]){
				dis[to[i]]=dis[g]+c[i];
				pre[to[i]]=i;
				if(!vis[to[i]])vis[to[i]]=1,q.push(to[i]);
			}
		}
	}
	return dis[T]<inf;
}
int main(){
	scanf("%d%d%d%d%d",&n1,&n2,&m,&vr,&vb);
	scanf("%s%s",s+1,s2+1);
	n=n1+n2;S2=++n;T2=++n;S=++n;T=++n;
	for(int i=1,x,y;i<=m;++i){
		scanf("%d%d",&x,&y);
		addedge(x,y+n1,0,1,vr);
		addedge(y+n1,x,0,1,vb);
	}
	for(int i=1;i<=n1;++i){
		if(s[i]=='U')addedge(S2,i,0,inf,0),addedge(i,T2,0,inf,0);
		else if(s[i]=='R')addedge(S2,i,1,inf,0);
		else addedge(i,T2,1,inf,0);
	}

	for(int i=n1+1;i<=n1+n2;++i){
		if(s2[i-n1]=='U')addedge(S2,i,0,inf,0),addedge(i,T2,0,inf,0);
		else if(s2[i-n1]=='B')addedge(S2,i,1,inf,0);
		else addedge(i,T2,1,inf,0);
	}
	addedge(T2,S2,0,inf,0);
	int an2=0;
	for(int i=1;i<S;++i){
		if(du[i]>0)addedge(S,i,0,du[i],0),++an2;
		else if(du[i]<0)addedge(i,T,0,-du[i],0);
	}
//	cout<<an2<<endl;
	int ans=0;
	while(spfa()){
//		puts("yes");
		for(int i=T;i!=S;i=to[pre[i]^1])
			--w[pre[i]],++w[pre[i]^1];
		ans+=dis[T];--an2;
	}
//	cout<<an2<<endl;
	if(an2)return puts("-1"),0;
	cout<<ans<<endl;
	for(int i=1,j=2;i<=m;++i,j+=4){
		if(!w[j])putchar('R');
		else if(!w[j+2])putchar('B');
		else putchar('U');
	}
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define cri const register int
#define re register
using namespace std;
int fa[410],to[20010],la[20010],fl[20010],da[20010],du[410],cnt=1;
const int inf=1e9;
int dis[410],v[410],pre[410],que[200010],S,T;
inline void add(cri x,cri y,cri l,cri r,cri k){
	to[++cnt]=y,la[cnt]=fa[x],fa[x]=cnt,fl[cnt]=r-l,da[cnt]=k;
	to[++cnt]=x,la[cnt]=fa[y],fa[y]=cnt,fl[cnt]=0,da[cnt]=-k;
	du[x]-=l;du[y]+=l;
}
inline char spfa(int l=1,int r=0){
	for(int i=0;i<=T;i++) dis[i]=inf;
	que[++r]=S;dis[S]=0;
	while(l<=r){
		cri x=que[l++];v[x]=0;
		for(int i=fa[x];i;i=la[i]) if(fl[i]&&dis[to[i]]>dis[x]+da[i]){
			dis[to[i]]=dis[x]+da[i];pre[to[i]]=i;
			if(!v[to[i]]) que[++r]=to[i];
		}
	}
	return dis[T]!=dis[0];
}
inline int dfs(cri x,cri cp){
	int mn=inf;
	for(int i=pre[T];i;i=pre[to[i^1]]) mn=min(mn,fl[i]);
	for(int i=pre[T];i;i=pre[to[i^1]]) fl[i]-=mn,fl[i^1]+=mn;
	return mn;
}
char s1[210],s2[210];
inline int read(re int a=0,re char ch=getchar()){
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9') a=(a<<3)+(a<<1)+(ch^48),ch=getchar();
	return a;
}
int main(){
	cri n1=read(),n2=read(),m=read(),R=read(),B=read();
	cri s=n1+n2+1,t=s+1;S=t+1;T=t+2;
	scanf("%s%s",s1+1,s2+1);
	for(int i=1;i<=m;i++){
		cri x=read(),y=read();
		add(x,y+n1,0,1,R);
		add(y+n1,x,0,1,B);
	}
	for(int i=strlen(s1+1);i;i--){
		if(s1[i]=='R') add(s,i,1,inf,0);
		if(s1[i]=='B') add(i,t,1,inf,0);
		if(s1[i]=='U') add(s,i,0,inf,0),add(i,t,0,inf,0);
	}
	for(int i=strlen(s2+1);i;i--){
		if(s2[i]=='B') add(s,i+n1,1,inf,0);
		if(s2[i]=='R') add(i+n1,t,1,inf,0);
		if(s2[i]=='U') add(s,i+n1,0,inf,0),add(i+n1,t,0,inf,0);
	}
	add(t,s,0,inf,0);
	int sum=0,sumflow=0;
	for(int i=1;i<=t;i++){
		if(du[i]>0) sumflow+=du[i],add(S,i,0,du[i],0);
		if(du[i]<0) add(i,T,0,-du[i],0);
	}
	while(spfa()){
		cri D=dis[T],F=dfs(S,inf);
		sumflow-=F;sum+=D*F;
	}
	if(sumflow) return puts("-1"),0;
	cout<<sum<<endl;
	for(int i=2;i<=m*4;i+=4)
		if(fl[i]&&!fl[i+2]) putchar('B');
		else if(!fl[i]&&fl[i+2]) putchar('R');
		else putchar('U');

}


#include<queue>
#include<cstdio>
#include<cstring>
using namespace std;
const int N=605,inf=1e9;
struct Link{int w,to,val,nxt;}l[N*10];
int n1,n2,de[N],m,R,B,head[N],tot=1;
int S,T,SS,TT,pre[N],dis[N],vis[N],cnt;
char ch1[N],ch2[N];
inline void add(int x,int y,int w,int val){
	l[++tot].w=w;l[tot].to=y;l[tot].val=val;
	l[tot].nxt=head[x];head[x]=tot;
}
inline void Add(int x,int y,int d,int u,int val){
	add(x,y,u-d,val),add(y,x,0,-val);
	de[y]+=d,de[x]-=d;
}
inline bool spfa(){
	memset(dis,0x3f,sizeof dis);
	memset(pre,0,sizeof pre);
	queue<int>q;q.push(SS);dis[SS]=0;
	while(!q.empty()){
		int x=q.front();q.pop();
		for(int i=head[x];i;i=l[i].nxt){
			int y=l[i].to;
			if(l[i].w&&dis[y]>dis[x]+l[i].val){
				pre[y]=i;dis[y]=dis[x]+l[i].val;
				if(!vis[y]) q.push(y),vis[y]=1;
			}
		}
		vis[x]=0;
	}
	return dis[TT]<inf;
}
inline int EK(int ans=0,int t=0){
	while(t=1e9,spfa()){
		//cout<<t<<"      asas"<<endl;
		for(int i=TT;i!=SS;i=l[pre[i]^1].to) t=min(t,l[pre[i]].w);
		for(int i=TT;i!=SS;i=l[pre[i]^1].to) l[pre[i]].w-=t,l[pre[i]^1].w+=t;
		ans+=t*dis[TT];//printf("%d asas %d\n",t,ans);
	}
	return ans;
}
int main(){
	scanf("%d%d%d%d%d",&n1,&n2,&m,&R,&B);
	scanf("%s%s",ch1+1,ch2+1);cnt=n1+n2;
	S=++cnt,T=++cnt,SS=++cnt,TT=++cnt;

	for(int i=1,x,y;i<=m;++i){
		scanf("%d%d",&x,&y);
		Add(x,y+n1,0,1,R);
		Add(y+n1,x,0,1,B);
	}
	for(int i=1;i<=n1;++i){
		if(ch1[i]=='R') Add(S,i,1,inf,0);
		if(ch1[i]=='B') Add(i,T,1,inf,0);
		if(ch1[i]=='U') Add(S,i,0,inf,0),Add(i,T,0,inf,0);
	}
	for(int i=1;i<=n2;++i){
		if(ch2[i]=='R') Add(i+n1,T,1,inf,0);
		if(ch2[i]=='B') Add(S,i+n1,1,inf,0);
		if(ch2[i]=='U') Add(S,i+n1,0,inf,0),Add(i+n1,T,0,inf,0);
	}
	for(int i=1;i<=cnt-2;++i)
		if(de[i]>0) Add(SS,i,0,de[i],0);
		else if(de[i]<0) Add(i,TT,0,-de[i],0);
	Add(T,S,0,inf,0);
	int ans=EK();
	for(int i=head[SS];i;i=l[i].nxt)
		if(l[i].w){puts("-1");return 0;}
	printf("%d\n",ans);

	for(int i=2;i<=4*m+1;i+=4){
		if(!l[i].w) putchar('R');
		else if(!l[i+2].w) putchar('B');
		else putchar('U');
	}
	return puts(""),0;
}


#include<bits/stdc++.h>
#define N 550
using namespace std;
int n,n1,n2,m,vr,vb,S,T,S2,T2;
char s[N],s2[N],an[N];
int val[N];
int du[N];
int he[N],ne[N*N],to[N*N],w[N*N],c[N*N],tot=1;
const int inf=0x3f3f3f3f;
inline void addedge(int x,int y,int z,int co){
	to[++tot]=y;ne[tot]=he[x];he[x]=tot;w[tot]=z;c[tot]=co;
	to[++tot]=x;ne[tot]=he[y];he[y]=tot;w[tot]=0;c[tot]=-co;
}
int dis[N],vis[N],pre[N];
inline bool spfa(){
	memset(dis,0x3f,sizeof(int)*(n+1));
	memset(vis,0,sizeof(int)*(n+1));
	queue<int>q;
	dis[S]=0;q.push(S);
	while(q.size()){
		int g=q.front();q.pop();vis[g]=0;
		for(int i=he[g];i;i=ne[i]){
			if(w[i]&&dis[to[i]]>dis[g]+c[i]){
				dis[to[i]]=dis[g]+c[i];
				pre[to[i]]=i;
				if(!vis[to[i]])vis[to[i]]=1,q.push(to[i]);
			}
		}
	}
	return dis[T]<inf;
}
int main(){
	scanf("%d%d%d%d%d",&n1,&n2,&m,&vr,&vb);
	scanf("%s%s",s+1,s2+1);
	n=n1+n2;S=++n;T=++n;
	for(int i=1,x,y;i<=m;++i){
		scanf("%d%d",&x,&y);
		addedge(x,y+n1,1,vr);
		addedge(y+n1,x,1,vb);
	}
	for(int i=1;i<=n1;++i){
		if(s[i]=='U')addedge(S,i,inf,0);
		else if(s[i]=='R')addedge(S,i,1,0);
		else addedge(i,T,1,0);
	}
	for(int i=n1+1;i<=n1+n2;++i){
		if(s2[i-n1]=='U')addedge(i,T,inf,0);
		else if(s2[i-n1]=='B')addedge(S,i,1,0);
		else addedge(i,T,1,0);
	}
	int ans=0;
	while(spfa()){
		for(int i=T;i!=S;i=to[pre[i]^1])
			--w[pre[i]],++w[pre[i]^1];
		ans+=dis[T];
//		cout<<ans<<endl;
	}
	cout<<ans<<endl;
	for(int i=1,j=2;i<=m;++i,j+=4){
		if(!w[j])putchar('R');
		else if(!w[j+2])putchar('B');
		else putchar('U');
	}
	return 0;
}