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

int main(){
	int N, Q;
	cin >> N >> Q;
	int A[N], B[Q];
	
	for(int i = 0; i < N; i++){
		cin >> A[i];
	}
	for(int i = 0; i < Q; i++){
		cin >> B[i];
	}
	
	for(int i = 0; i < Q; i++){
	
		int sefovGlas = B[i];
		int tmp[N+1];
		copy (A, A+N, tmp);
		tmp[N] = sefovGlas;
		sort(tmp, tmp+N+1);
		
		for(int j = 0; j <= N; j++){
			if(tmp[j] == sefovGlas){
				for(int n = 0; n < N+1;n++) 
					cout << tmp[n];
					cout << "\n";
					
					
					int pre = j;
					int posle = N-1;
					
					if(posle-pre == 1){
						cout << "0";
						cout << "\n";
					}
					else{
						cout << abs(posle-pre);
						cout << "\n";
					}
					break;
				
			}
		}
	}
	
	return 0;
}